#2117 open
euromark

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

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.

New-ticket Create new ticket

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.