Improvements for 2.0 upgrade shell
Reported by euromark | January 2nd, 2012 @ 09:14 AM | in 2.1.3
the shell should respect the -app param that usually works in
all shell scripts.
meaning:
E:\...\trunk2\lib\Cake\Console>cake -app E:\...\trunk2\site upgrade all
It simply goes into self destruction mode. The getcwd() command
seems to find itself (the console folder) as root and finds the
folder "Console" and moves it away. The result:
Console/AppShell.php
Console/Shell.php
are missing after that operation! and the console is then broken
due to missing console files.
They are now in a subfolder "Console" inside the "Console" folder
(of course!)
$cwd (line 128 UpgradeShell.php) should be the current app path though - as the console correctly shows:
Current Paths:
app: site
working: E:...\trunk2\site
root: E:...\trunk2
core: E:...\trunk2\lib
Only the other way around works as expected (site = app folder):
E:\...\trunk2\site>E:\...\trunk2\lib\Cake\Console\cake upgrade all
So the above paths are not used inside this particular
shell.
Needed me a while to find out what the problem was.
LOST/WRONG files
a totally different file ended up to be the new AppModel
(code_completion.php in the app folder).
the app_model.php itself got deleted, though, as well.
some libs just got lost like MyLazyModel in tools plugin "libs".
nowhere to be seen after the upgrade.
same with MyBoostrap.php (which only contained some boostrap
additions).
although it seems like App::import('Lib', 'Tools.MyBootstrap'); doesnt work anymore at all (thats another topic, though, i guess - probably because it doesnt contain a class - seems kind of strange).
"Datasource class could not be found" maybe an existing
database.php could be rewritten right away to the new standard.
'driver' => "mysql(i)" >>> 'datasource' =>
'Database/Mysql' added etc
Important:
a new task "webroot" should be added to cake care of the new
dispatcher process.
it should then update or better replace the old index.php and
test.php with the current 2.0 version.
__construct() that used to work in 1.3 should be upgraded to
work with 2.0
e.g. for helpers
function construct() { parent::construct(); ...
}
becomes
function construct($View) {
parent::construct($View); ... }
same for other classes.
the components are renamed and correctly relocated but they still extend "Object":
class CustomComponent extends Object {
this should probably be "Component", though.
and the "class AuthExtComponent extends AuthComponent" has not been moved at all for some reason (still auth_ext.php in /controllers/components).
The shell should remove old empty folders (views, controllers,
models, ...).
if they dont contain anything anymore, they could be as well
removed directly by the shell in "upgrade locations".
"upgrade helpers" fatal errors. it would be good to clarify if plugins have to be enabled with the new 2.0 syntax in the bootstrap etc. maybe the shell could enable them for the upgrade process to avoid this missing plugin error here which obviously kills the rest of the process. as the "way to go" seems to be just to start the shell on the old app folder the automatic enabling seems to make more sense to me [CakePlugin::loadAll()?].
the shell seems to be inconsistent within the different
tasks.
so despite some comments like "Yes, enable plugins in bootstrap
before running upgrade. When upgrading plugins for each plugin add
plugin option like: cake upgrade all -p Blog" the shell
automatically adjusted all plugins itself. without specifying the
plugin.
but some tasks might need this option, though.
not all helpers have been moved. some (plugins helpers) are still in the old "helpers" folder which is now capitalized ("Helpers"). thats probably the reason why they are not found anymore...
I propose a task "upgrade legacy" in order to easy the change
from 1.3 to 2.0
there are already hundreds or thousands of manual adjustments to
make.
if all deprecated classes and methods need to be addressed as well,
this makes huge projects almost impossible to upgrade.
there are for intance File and Folder classes which could easily
be arranged to still work.
this way we can address this problem later as soon as the code runs
again and we have time to cover this.
my proposal:
App::import('Core', 'Folder'); becomes App::import('Lib',
'Folder');
and we copy the old Folder class to the /app/Lib folder (same for
File etc).
A quick solution to avoid having to change the complete File/Folder
access throughout the application which can be a disaster if forced
to do so while in the middle of upgrading. there is no rush here.
stuff like that can be taken care of later.
ok - after many hours of testing and debugging I need a break
:)
after all, the shell already seems to cover quite a bit. that's
really great!
these improvements and it will still be a lot to do manually. but
at least most of the things that can be automated are done for you
:)
Comments and changes to this ticket
-

Jose Lorenzo Rodríguez October 19th, 2011 @ 09:29 AM
- → Tag set to defect, upgradeshell
- → Milestone set to 2.0.1
Nice list. Want to volunteer for a patch too?
-
euromark October 19th, 2011 @ 10:11 AM
needed quite a while to gather ;)
would like to but i am kinda short on time now.
maybe I have to postpone the upgrade process for a while now.I can try to cover some of the above points. but not all of them.
-
euromark October 19th, 2011 @ 12:00 PM
a short correction:
legacy should change the App::import to
App::uses('Folder', 'Utility');etc
just saw that cake2 has those files now in Utility -
euromark October 19th, 2011 @ 02:29 PM
here is my first piece of enhancement:
https://github.com/XTAIN/cakephp/commit/f99426849713be8e1965088d1af...- legacy
- webroot
- deleting of old empty folders
enjoy
-
euromark October 19th, 2011 @ 05:09 PM
I also added
-
database.php
-
constructors (helpers)
https://github.com/XTAIN/cakephp/commit/821a77f47cdab678212657c14bf...
-
-
euromark October 23rd, 2011 @ 06:10 PM
ok, several days of work left me with some more details on what goes wrong with the current upgrade script as well as what enhancements it could need.
first of all the _findFiles() iterator illegally collects all plugin files - even if not asked (-p xyz).
therefore I needed to implement a little hack
maybe it can be solved otherwise.the order should be: first locations, then the rest.
I added some more tasks:
-
paginator (should only be triggered once in order to fully work)
-
report (finds and logs further issues that need to be fixed manually)
the complete patch:
https://github.com/XTAIN/cakephp/commit/57b13c1fb4a4e05080a3c5947a0...enjoy
PS: is there more stuff report() could notify about?
currently open issues:
- the -app param issue from above
- the auto-enabling or notification about CakePlugin::loadAll()
- inconsistency with plugin param (now -p xyz would also trigger app files - at least the other way around is fixed now)
- not sure if "git mv" works. usually you cannot add empty folders afaik. svn move does work, though.
- param -l should log all console output lines to log.txt in TMP (otherwise output useless as too many lines cannot be displayed and are truncated after a while)
- param -p * should process all plugins (having more than 20 plugins makes it really time consuming to update them all explicitly)
- locations has some bugs with certain file names. e.g. "auth.php" and "auth_ext.php" lets "auth_ext.php" unmoved.
- code_completion__.php (or any other similar file I presume) in app folder still wants to be moved to the place where AppModel.php now is. seems to be a bug of locations, as well
-
-
euromark October 23rd, 2011 @ 06:58 PM
I managed to create a complete log file by overriding the out() method:
public function out($message = null, $newlines = 1) { if (!empty($this->params['log'])) { $file = TMP.'log.txt'; if (!empty($this->appendLogFile)) { $flag = FILE_APPEND; } else { $flag = null; $this->appendLogFile = true; } file_put_contents($file, trim($message).str_repeat(PHP_EOL, $newlines), $flag); } return parent::out($message, $newlines); }For instance
cake upgrade report -lThis is quite useful for manual confirmation that everything went down as planned.
-

majna October 24th, 2011 @ 06:15 AM
Report:
$this->viewPath = 'elements'-> Elements Used in controllers (usually for ajax callas)Nice work tnx.
-
euromark October 24th, 2011 @ 06:21 AM
uppercase then?
I guess some of those things could easily be done as automatic replacements, as well.
I'd rather use the report only for things that cannot be done at all using regexp replacements.
sounds easy enough to me to add this pretty quick. -
euromark October 24th, 2011 @ 07:32 AM
I just added it to the replacements. thx!
also found another one: <cake:noncache> becomes <!--nocache-->and I added command "group" besides "all"
/** * Run all defined upgrade steps one at a time * * Use params to define (at least two - otherwise you can run it standalone): * cake upgrade group controllers components ... * * Or use Configure: * Configure::write('UpgradeGroup.cc', array('controllers', 'components', ...)); * and * cake upgrade group cc * NOTE: group names cannot be one of the commands to run! * * @return void */ public function group() { $subCommands = $this->OptionParser->subcommands(); $commands = $this->args; if (count($commands) === 1) { $commands = (array)Configure::read('UpgradeGroup' . $commands[0]); } if (empty($commands)) { $this->error(__d('cake_console', 'No group found. Please use args or Configure to define groups')); } foreach ($commands as $command) { if (!in_array($command, $subCommands)) { $this->err(__d('cake_console', 'Invalid command \'%s\' - skipping', $command)); continue; } } foreach($subCommands as $command) { $name = $command->name(); if ($name === 'all' || $name === 'group' || !in_array($name, $commands)) { continue; } $this->out(__d('cake_console', 'Running %s', $name)); $this->$name(); } }useful if you want to run all commands except for one or two!
-

Jose Lorenzo Rodríguez October 30th, 2011 @ 07:38 PM
- → Milestone changed from 2.0.1 to 2.0.2
-

Jose Lorenzo Rodríguez November 2nd, 2011 @ 11:35 PM
- → Milestone changed from 2.0.2 to 2.0.3
-

-
euromark November 18th, 2011 @ 04:49 PM
This is the final version of my enhanced upgrade shell
https://github.com/XTAIN/cakephp/commit/917e8a867b28a552374b407e336...This version supports now on top of the original commands/tasks:
- paginator (switching param 1/2)
- database (driver => datasource)
- legacy (file/folder, could be extended for other core classes)
- name (removal)
- constructors (type declaration for objects)
- webroot (htaccess, index.php, test.php)
- report (can be extended to report more)
- views (nocache attr)
- controllers (viewPath Elements)
- routes (adding cake and plugin default routes)
- group call (using Configure or params you can run specific groups of commands only)
- tests (adjusting some calls)
Tested with multiple larger cake1.3 apps which have been upgraded to 2.0 (windows and svn).
Feel free to use some or all of this patch.
The CorrectShell has some commands that might also be interesting:
- i18n (simplyfing __() calls)
- request (getClientIp)
- forms (post to itself simplified in 2.0)
- vis (visibility adjustments)
Maybe you want to make them part of the UpgradeShell, as well.
Link:
https://github.com/dereuromark/upgrade/blob/master/Console/Command/... -

Jose Lorenzo Rodríguez November 28th, 2011 @ 10:24 AM
- → Milestone changed from 2.0.4 to 2.0.5
-

Mark Story December 28th, 2011 @ 08:17 PM
- → Tag changed from defect, upgradeshell to enhancement, upgradeshell
It doesn't seem like this is a defect with the current upgrade shell, but more a set of improvements that could ease upgrading.
-

-

-

-

Jose Lorenzo Rodríguez February 5th, 2012 @ 06:22 PM
- → Milestone changed from 2.0.6 to 2.0.7
-

-

-

-

Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Source available from github
Repository is at http://github.com/cakephp/cakephp
Creating a bug report
When creating a bug report, please include as much relevant information as possible. Please include code to reproduce the issue. Or even better, make a unit test. Either change an existing test or add a new test to show that the expected behavior is not occuring.