Cakephp从1.3升级到2.1 [英] Cakephp Upgrade from 1.3 to 2.1

查看:251
本文介绍了Cakephp从1.3升级到2.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:我问的问题不完全涵盖我在做这个升级有多深!如果你绊倒这个,我希望我的推送的答案对你有用



所以,为了努力让论坛插件工作,我决定将cakephp从1.3升级到2.1



(这是因为论坛插件使用的是CakeDC utils,它们已经达到了cakephp 2.0,的论坛不清楚哪个工具使用它...)



好吧,所以我已经运行了蛋糕升级魔术的东西,根据这里找到的说明:



http://book.cakephp.org/2.0/en/console-and-shells/upgrade-shell.html#upgrade-shell



并且我运行升级程序,它说它做了一堆东西,它看起来像做了一堆的东西。



现在当我访问我的网站,它是下降 - 没有任何反应。



apache中的错误日志为:


58:04 2012] [错误] [客户端173.45.125.112] PHP致命错误:找不到应用程序核心文件。请创建/cake_install/app/config/core.php,并确保PHP可读。 in /cake_install/cake/libs/configure.php on line 393


文件不存在的原因是它已更改到升级中的大写CConfig。我缺少什么?

解决方案

mensch给出的答案不是我需要的 - 我从来没有碰过index.php文件 - 所以我会详细说明我在这里尝试。



我使用这个网站作为指南,但与我自己的评论太!
http://www.paulmarshall.us/blog/migrating- from-cakephp-13-to-cakephp-20



(我也发现这个:https://github.com/dereuromark/upgrade 如果上面的教程失败我可能会有一个镜头我不太热衷于它,虽然,我喜欢超详尽的文档,不

 在您的应用程序引导程序中插入`CakePlugin :: loadAll();`以确保此插件已加载

这对我来说是没有意义的...你可以指定文件夹的文件夹吗? line?etc ...我会尝试,并且特别关于我做了什么!)



首先,我注意到index.php,我的蛋糕使用不是与cake2.1代码一起来的index.php。不确定为什么是这种情况,但我复制了新2.1 index.php(是的,这是应用程序/ webroot / index.php文件),现在我有一个新的错误:


注意:未定义的索引:在/ cake_install/lib/Cake/Core/Configure.php的第94行中的错误注意:未定义的索引:/ cake_install / lib / Core / Configure.php on line 95致命错误:类名必须是第126行的/cake_install/lib/Cake/Error/ErrorHandler.php中的有效对象或字符串


(其中cake_install是我的蛋糕应用程序所在的文件夹)



现在正在处理...



现在我看到升级工具没有升级core.php文件 - 在app / Config(对于2.1,app / config为1.3) - 升级工具是什么真的吗?我已经剪切和粘贴2.1版本(即,从2.1代码的zip文件,我把/app/Config/core.php,并将其移动到我的/ app / Config目录),并确保盐和安全值被交换。就是这样。



仍然没有运气。所以现在我升级了database.php文件(也在app / Config或app / config)〜我改变了

  'driver'=> 'mysqli',

 'datasource'=> 'Database / Mysqli',

随机配置文件很有趣!



啊,好吧,所以升级到核心和数据库改变错误消息...这是好吗?仍然不确定他们多么vaunted升级脚本做了...它只是改变了文件名?


警告(2):file_put_contents(/cake_install/app/tmp/logs/error.log):无法开启串流: Permission denied [CORE / Cake / Log / Engine / FileLog.php,line 69]



注意(1024):请更改应用程序中的Security.cipherSeed /Config/core.php到您的应用程序特定的数字(仅数字)种子值[CORE / Cake / Utility / Debugger.php,第810行]



致命错误:第31行中的/cake_install/lib/Cake/View/Helper/HtmlHelper.php中找不到类'AppHelper'


所以我777的/ cake_install / app / tmp / logs /文件夹(chmod 777 -R文件夹)和



...猜猜我从来没有升级密码种子。好吧,组成一个新的数字! (密码种子做什么,你问嗯,好吧,bing没有多大帮助 - 我读的代码。似乎用于加密/解密从cookie?好,我可以生活的)



Bootstrap.php



我将zip文件中的引导程序移动到我的版本(感谢一点,升级脚本!没有进行任何更改,我想我将需要加载插件虽然...我确信,有很多文档,尽管(hah!)




致命错误:在/ cake_install / lib / Cake / View / Helper中没有找到类'AppHelper' HtmlHelper.php在第31行上


当然,那些。。的蛋糕升级器无法做另一次升级。检查此页:
http://book.cakephp.org /2.0/en/appendices/2-1-migration-guide.html



好的,现在我必须创建文件 - 就像他们在该页面。唯一的窍门是,是的,它是在应用程序文件夹,没有,我的应用程序/ View文件夹,蛋糕制作没有一个帮助器子文件夹...所以对于AppHelper.php我不得不做一个帮手子文件夹在/ app / View /.



...



HEY!现在我得到一个背景和一个标志...和这些:


注意(8):未定义变量:loggedIn [APP / top_menu.html,第3行]



注意(8):未定义的变量:html [APP / pages / top_menu.html,第25行]



致命错误:在第25行在/cake_install/app/pages/top_menu.html中对非对象的成员函数link()调用


很好。某种酷的新蛋糕2功能,这意味着我不能使用$ html?这似乎......奇怪的适当,真的。



令人难以置信。现在我需要改变如何$ this->数据工作?为什么??为什么??为什么这个暴徒不知道apis倾向于是固定合同,而不是浮动的想法...。没关系,最常用的蛋糕行我现在...错了。



这是我运行的:
find。我从scala或django开发, -type f -exec sed -i / $ this-> data / $ this-> request-> data / g'{} \;



到/ app目录这样做。这2.1 ...它更好地认真真棒...每个人都需要做的工作量,以获得它。这是我假设,一个正常的日子与低级语言工作。



很奇怪,$ html问题是由于某人不喜欢小写引起的?人们只能想到:
未定义var when在CakePHP 2.0中使用Html Helper
解决方法是:(感谢SO中的另一篇文章)


find 。 -type f -exec sed -i'/ $ html / $ this-> Html / g'{} \;


自然与$ session -



找到相同的问题。 -type f -exec sed -i / $ session / $ this-> Session / g'{} \;



...



事情就来了!现在我有不可修改的错误:


无法找到控制器类PagesController。


哦,对于...的爱,所以我需要移动的PagesController在这里找到:



lib / Cake / /skel/Controller/PagesController.php



并放在这里



app / Controller /



现在我有了

$



b
$ b

找不到帮助程序类JavascriptHelper。



这不是太糟糕了 - 你不会找到任何引用JavascriptHelper ,但是你会在$ helpers数组中找到对Javascript的引用。后端在词Helper中添加了额外的混淆。无论如何,我通过我的PHP文件搜索任何$ helpers数组,并找到一个,在AppController(2.1)类。



我不喜欢也不明白helpers - javascript的,反正 - 所以我从来没有使用过他们。我必须盲目地跟着一个教程在某一点,并添加它在...但我不需要它,所以它就来了!



现在我需要清理所有的ctp文件,我有,我使用要求,以确保使用正确的html。再次,我将使用find命令从上面为此(将其指向视图而不是视图文件夹)
叹了。好吧,不,这不是那么简单,是吗?我之前的位置:



require(app / View / Pages / man_front.html)





require(/cake_folder/app/View/Pages/man_front.html)



文件夹是我所有的蛋糕的东西是不确定为什么这是,但一个简单的发现固定它:

  find。-type f -exec sed -i / app\ / View\ / Pages / \ / cake_folder\ / app\ / View\ / Pages / g'{} \; 

(\会depowera /)



已经做了所有的事情,并让你的网站达到某种可接受的水平,接下来,你可能现在找到一些数据库问题:


警告(2):mysqli :: mysqli()期望参数1为字符串,数组给定[CORE / Cake / Model / ConnectionManager.php,第101行]



致命错误:调用未定义的方法mysqli :: getSchemaName()in /cake_install/lib/Cake/Model/Model.php on line 3383


当然,没有更多的mysqli支持。编辑database.php使用mysql(即我刚刚删除了结尾i)



(什么是peeps在cakephp ??? API是什么意思是不要改变一切,如果它会破坏现有的代码,永远不是改变!OBAMAAAAA!〜下一次升级,我会推我所有的代码django或春天或scala,红润的废话。)



下一个问题是我使用的组件 - 我得到一个蛋糕错误说:


缺少插件



错误:应用程序正在尝试从上传器插件加载文件



错误:确保您的插件上传器位于app / Plugin目录中并已加载




 <?php 
CakePlugin :: load('Uploader');




加载所有插件:如果您希望一次加载所有插件,请在您的应用程序/ Config / bootstrap.php文件中使用以下行:




  CakePlugin :: loadAll (); 

所以...不仅是所有的代码都被淘汰了,尼斯。



解决方案是创建一个app / Plugin文件夹(是的,神奇的升级程序不会这样做),然后看看你的插件。现在!这与您的组件不同!我不知道怎么回事 - 查看我的问题可能的答案:组件和插件在cakephp 2.1? - 但现在,我们只是看着PLUGIN文件夹,和插件一般。看起来像在蛋糕1.3,插件列出像这样:


var $ components = array('Uploader.Uploader',.. 。);


这是一个点符号。我可以住在那里。在我的情况下,我需要获取最新版本的Uploader插件(幸运的是,升级为2.x兼容!),并将其放在app / Plugin文件夹



所以我得到:

  app 
插件
上传者
配置
Locale
<其他文件也在这里!>

现在似乎有效了,hooray!



下一个错误是:


警告(2):foreach()提供的参数无效[CORE / Cake / Utility / Set .php,line 1048]



警告(2):array_multisort()[http://php.net/function.array-multisort]:期望参数#1要作为数组或排序标志[CORE / Cake / Utility / Set.php,line 1087]



警告(2):array_unique数组,null给出[CORE / Cake / Utility / Set.php,line 1089]



警告(2):foreach



警告(2):无法修改标题信息 - 已发送的标题(输出开始于/ cake_install / lib / Cake / Utility /Debugger.php:761)[CORE / Cake / Network / CakeResponse.php,line 395]


这很清楚。我很高兴我知道错误是在我的代码。好的错误消息!



现在我看到,愚弄我,认为如果第一个数组为空,Set :: Sort实用程序将继续工作!真的,cakephp人站立,不是在巨人的肩膀上,而是在他们的额头上。



看来,新的2.1升级已经取消了这种破旧的做法,所以现在我需要检查之前任何设置:排序调用,以避免如果有问题的数组空或null。精细。足够简单,但... geeze。




  • 我只是投入了



    if $ theArray)){
    Set :: sort($ theArray,...);
    }






现在我得到FormHelper错误 - 它看起来像$ form在视图中现在变为$ this-> Form,所以我有另一个快速脚本替换这: p>


找到。 -type f -exec sed -i'/ $ form / $ this-> Form / g'{} \;


现在我得到的下一个错误是:


致命错误:/ cake_install / lib / Cake / View / Helper / FormHelper中不支持的操作数类型.php on line 1804


现在他们已经搞错了FormHelper中的select方法 - 我有这个:


echo $ this-> Form-> select('treatment_id',$ treatments,null,array =>' - 选择治疗率 - '));


我现在有:


echo $ this-> Form-> select('treatment_id',$ treatments,array('empty'=>' - select treatment to rate - ') );


现在我的一个组件 - 实际上,You_tube_loader_component - 被打破了。我需要修改它,使标题读为:

  class YouTubeLoaderComponent extends Component {
function __construct(ComponentCollection $ collection ,$ settings = array()){
parent :: __ construct($ collection,$ settings);
...
}
}

默认的uname和密码的valeus - 现在我把它们在...部分,而不是搞砸与神秘的设置数组!



is:


警告(2):非法偏移类型[CORE / Cake / Model / Model.php,第2689行]



警告(2):非法偏移类型[CORE / Cake / Model / Model.php,line 2665]


Soooo这是一个问题,不是在蛋糕1.3中,而是在2.1



问题是在控制器操作被引用,有一个没有类型参数的find调用。也就是说,我有


$ results = $ this-> User-> find(array(...),array 。),null,false);


其中我应该有:

  $ results = $ this-> User-> find('first',array(
'conditions'=> array(User.id=> ;($ this-> Auth-> user(id))),
'fields'=> array(User.confirmed)

);另一个问题是,无论什么原因,检查:


$ b


$ this-> set('loggedIn',$ this-> Auth-> user('id'));


< blockquote>

没有工作。显然(虽然不确定如何/为什么),cakePHP auth在2.x将不再存储所有的用户的细节到会话。我不知道详细信息存储到会话,或如何修改它们 - 查看! - 但是我的代码没有保存id值,所以上面的检查总是将loggedIn值设置为false。



为了补救,我修改了调用read :


$ this-> set('loggedIn',$ this-> Auth-> loggedIn()); b $ b

这对我很好。



下一个问题是,thios-> auth-> user('id')将在登录用户后不返回任何内容。幸运的是,我遇到了这个职位,这使事情更清楚:


http://ask.cakephp.org/questions/view/unable_to_access_logged-in_users_data_in_2_0




<令人惊讶的是,蛋糕实验室的天才们认为,改变登录工作的方式有助于澄清一些混乱。说实话,我困惑的唯一的是谁是这样的事实,auth组件有所有的用户的详细信息可用后登录,但是不要害怕,他们已经清除了混乱和...删除该功能完全。



那么,你要做什么?以上链接建议获取所有用户详细信息,然后将其发送到auth登录部分。我不是特别喜欢这个(因为这是一个愚蠢的问题,我不能相信任何这么不起眼的需要),但它是我必须做的。欢迎提出建议!



因此,不要太混乱:

  if($ this-> Auth-> login($ this-> request-> data)){
... // argh! 1

我现在有:

  $ user = $ this-> User-> find('first',array(
'conditions'=> array ('User.email'=> $ this-> request-> data ['User'] ['email'])

);
//使用AuthComponent〜Rs登录操作
if($ this-> Auth-> login($ user ['User'])){
... // omg该条目在数据库中的额外检查只是辉煌和高效

不是这样的更整洁,更少混乱?好的工作,cakephp mavericks!



下一个错误是


授权适配器;控制器


b 啊!回答已经在堆栈溢出这里:
在cakePHP中找不到授权适配器



就是这样!可能还有其他问题 - 上帝的速度在他们 - 但我没有遇到他们,所以我不能再帮助你了。


UPDATE: the question i asked doesn't quite cover how deep i went in doing this upgrade! If you stumble on this, i hope the answer i pushed is useful to you

So, in an effort to get the "forum" plugin working, i've decided to upgrade cakephp from 1.3 to 2.1

(This was because the forum plugin uses something called CakeDC utils, and they are already up to cakephp 2.0, and surprise surprise, the 2.3 version of forum isn't clear which utils it works with...)

Ok, so I have run the cake upgrader magic thing, in accordance with the instructions found here:

http://book.cakephp.org/2.0/en/console-and-shells/upgrade-shell.html#upgrade-shell

And i ran the upgrader, and it said it did a bunch of things, and it looks like it did do a bunch of things.

Now when i visit my site, it is down - no response at all.

The error logs in apache read:

[Thu Apr 05 02:58:04 2012] [error] [client 173.45.125.112] PHP Fatal error: Can't find application core file. Please create /cake_install/app/config/core.php, and make sure it is readable by PHP. in /cake_install/cake/libs/configure.php on line 393

The reason that file doesn't exist is that it was changed to a capital "C" Config in the upgrade. What am i missing?

解决方案

The given answer by mensch isn't quite what I need - I never touched the index.php file - so i will detail what I am trying here.

I am using this site as a guide, but with my own commentary too! http://www.paulmarshall.us/blog/migrating-from-cakephp-13-to-cakephp-20

(i also found this: https://github.com/dereuromark/upgrade which i might have a shot at if the above tutorial fails. I'm not too keen on it though, I like super-exhaustive documents, not

Put `CakePlugin::loadAll();` in your app bootstrap to make sure this plugin is loaded

which to me is meaningless... can you specify the folder of the file? Any particular spot in the file to add the line? etc... i'll try and be particular about what i did!)

First up, i've noticed that the index.php that my cake was using was not the index.php that came with the cake2.1 code. Unsure why that is the case, but I copied the "new" 2.1 index.php across (yes, this is the app/webroot/index.php file) and now i have a new error:

Notice: Undefined index: Error in /cake_install/lib/Cake/Core/Configure.php on line 94 Notice: Undefined index: Exception in /cake_install/lib/Cake/Core/Configure.php on line 95 Fatal error: Class name must be a valid object or a string in /cake_install/lib/Cake/Error/ErrorHandler.php on line 126

(where cake_install is the folder where my cake app sits)

Working on this now...

AND now i see that the upgrade tool didn't upgrade the core.php file - found in app/Config (for 2.1, app/config for 1.3)... what did the upgrade tool really do? I've cut and paste the 2.1 version in (that is, from the zip file of the 2.1 code, i took that /app/Config/core.php and moved it into my /app/Config directory), and made sure the salt and security values were swapped across. That's it.

Still no luck. So now i have upgraded the database.php file (also in app/Config, or app/config) ~ I changed the

'driver' => 'mysqli',

to

'datasource' => 'Database/Mysqli',

Configuring files randomly is fun!

Ah, ok, so the upgrade to core and database changed the error message... that's good? Still unsure what their much vaunted "upgrade" script did... it just changed file names? Really?

Warning (2): file_put_contents(/cake_install/app/tmp/logs/error.log): failed to open stream: Permission denied [CORE/Cake/Log/Engine/FileLog.php, line 69]

Notice (1024): Please change the value of 'Security.cipherSeed' in app/Config/core.php to a numeric (digits only) seed value specific to your application [CORE/Cake/Utility/Debugger.php, line 810]

Fatal error: Class 'AppHelper' not found in /cake_install/lib/Cake/View/Helper/HtmlHelper.php on line 31

Ok, so i 777 the /cake_install/app/tmp/logs/ folder (chmod 777 -R folderHere) and

...guess i never upgraded the cipher seed. Ok, made up a new number! (What does the cipher seed do, you ask? Um, well, bing wasn't much help - i read the code. Seems to be used for encrypting/decrypting from cookies? Ok, i can live with that)

Bootstrap.php

I moved the bootstrap in the zip file to my version (thanks for little, upgrade script!). Haven't made any changes yet, I think i will need to to load plugins though... i'm sure that is well documented though (hah!)

So that leaves me with this errror:

Fatal error: Class 'AppHelper' not found in /cake_install/lib/Cake/View/Helper/HtmlHelper.php on line 31

And of course, the much vaunted cake upgrader has failed to do another upgrade. Check this page out: http://book.cakephp.org/2.0/en/appendices/2-1-migration-guide.html

Ok, so now I have to make the files - just as they are in that page. The only trick was that, yes, it is in the app folder, and no, my app/View folder that cakePhp made didn't have a "Helper" subfolder... so for the AppHelper.php i had to make a Helper subfolder under /app/View/.

...

HEY! Now i get a background and a logo... and these:

Notice (8): Undefined variable: loggedIn [APP/pages/top_menu.html, line 3]

Notice (8): Undefined variable: html [APP/pages/top_menu.html, line 25]

Fatal error: Call to a member function link() on a non-object in /cake_install/app/pages/top_menu.html on line 25

Great. Some sort of cool new cake 2 feature that means that i cannot use $html? That seems... oddly appropriate, really.

Unbelievable. Now I need to change how $this->data works??? WHY?? WHY?? Why can't this mob work out that apis tend to be fixed contracts, not floating ideas... argh. That's ok, the most used cake line i have is now... wrong. I'm developing in scala or django from now on, junior languages suck.

Here is what i ran: find . -type f -exec sed -i 's/$this->data/$this->request->data/g' {} \;

I went to the /app directory to do so. This 2.1... it better be seriously awesome... the amount of work everyone has to do to get it up. Is this, i assume, a normal day working with the junior languages?

Ah fantastic, the $html problem is caused because somebody didn't like lowercase? One can only wonder: Undefined var when using Html Helper in CakePHP 2.0 And the solution is: (thanks to another post in SO)

find . -type f -exec sed -i 's/$html/$this->Html/g' {} \;

And naturally the same problem with $session -

find . -type f -exec sed -i 's/$session/$this->Session/g' {} \;

...

Things are coming along! Now I have the inscrutible error:

Controller class PagesController could not be found.

Oh for the love of... so i need to move the PagesController found here:

lib/Cake/Console/Templates/skel/Controller/PagesController.php

and put it here

app/Controller/

again, the Cake installer/upgrader seems to be asleep on the job.

And now I have

Helper class JavascriptHelper could not be found.

This isn't too bad - you won't find any references to "JavascriptHelper", but you will find references to "Javascript" in your "$helpers" array. The back-end adds in the word Helper for extra obfuscation. Anyway, i searched through my php files for any $helpers arrays, and found one, in the AppController(2.1) class.

I don't like nor understand helpers - javascript ones, anyway - so I never used them. I must have followed a tutorial blindly at some point and added it in... but i don't need it, so out it goes!

And now i need to clean up all the ctp files i had, where i used a "require" to ensure that the right html was used. Once more i will use the find command from above for this (to point them to the "View" and not "views" folder) Sigh. Ok, no, it isn't that simple, is it? Where before I had :

require(app/View/Pages/man_front.html)

i now need:

require(/cake_folder/app/View/Pages/man_front.html)

(where the cake folder is where all my cake stuff is. Unsure why this is, but a simple find fixed it:

find . -type f -exec sed -i 's/app\/View\/Pages/\/cake_folder\/app\/View\/Pages/g' {} \;

(the \ will "depower" a /)

Ok, so having done all that and gotten your site to some sort of acceptable level, what next? Well, you might now find some db issues:

Warning (2): mysqli::mysqli() expects parameter 1 to be string, array given [CORE/Cake/Model/ConnectionManager.php, line 101]

Fatal error: Call to undefined method mysqli::getSchemaName() in /cake_install/lib/Cake/Model/Model.php on line 3383

Of course, no more mysqli support. Edited the database.php to use mysql instead (ie i just removed the ending "i")

(what is wrong with the peeps in cakephp??? API means "don't change everything if it will break existing code, ever." not "change! OBAMAAAAA!" ~ next upgrade, i'll push all my code to django or spring or scala. Ruddy nonsense.)

The next issue is the "Components" that i am using - i get a cake error saying:

Missing Plugin

Error: The application is trying to load a file from the Uploader plugin

Error: Make sure your plugin Uploader is in the app/Plugin directory and was loaded

<?php
CakePlugin::load('Uploader');

Loading all plugins: If you wish to load all plugins at once, use the following line in your app/Config/bootstrap.php file

CakePlugin::loadAll();

So... not only is all my code busted, but all the old plugins too? Nice.

The solution is to create an app/Plugin folder (yes, the magic upgrader doesn't do that, either) and then look at the plugins you had. Now! This is different from your components! I don't know how just yet - check out my question for a possible answer : Difference between a "component" and a "plugin" in cakephp 2.1? - but right now, we are just looking at the "PLUGIN" folder, and plugins in general. Looks like, in cake 1.3, the plugins were listed like this:

var $components = array('Uploader.Uploader',...);

that is, with a dot notation. I can live with that. In my case, I needed to get the latest version of the Uploader plugin (that, thankfully, was upgraded to be 2.x compatible!) and put it in the app/Plugin folder

so i got:

app
    Plugin
        Uploader
            Config
            Locale
            <the other files here too!>

That seems to work right now, hooray!

The next error was:

Warning (2): Invalid argument supplied for foreach() [CORE/Cake/Utility/Set.php, line 1048]

Warning (2): array_multisort() [http://php.net/function.array-multisort]: Argument #1 is expected to be an array or a sort flag [CORE/Cake/Utility/Set.php, line 1087]

Warning (2): array_unique() expects parameter 1 to be array, null given [CORE/Cake/Utility/Set.php, line 1089]

Warning (2): Invalid argument supplied for foreach() [CORE/Cake/Utility/Set.php, line 1091]

Warning (2): Cannot modify header information - headers already sent by (output started at /cake_install/lib/Cake/Utility/Debugger.php:761) [CORE/Cake/Network/CakeResponse.php, line 395]

Ah, ok then. That is clear. I am glad I know what the error is in my code. Good error messaging!

Now I see, foolish me, to think that the utility Set::Sort would continue to work if the first array was empty! Truly, the cakephp people are standing, not on the shoulders of giants, but on their very foreheads.

It would seem that the new 2.1 upgrade does away with this shabby practice, so now i need a check before any Set:Sort calls to avoid if the array in question is empty or null. Fine. Easy enough, but... geeze.

  • I just threw in a

    if (!empty($theArray)){ Set::sort($theArray,...); }

and that fixed that.

Now I am getting FormHelper errors - it looks like $form in the view now becomes $this->Form, so i have another quick script to replace this:

find . -type f -exec sed -i 's/$form/$this->Form/g' {} \;

And now the next error I get is:

Fatal error: Unsupported operand types in /cake_install/lib/Cake/View/Helper/FormHelper.php on line 1804

And now they've done gone messed up the "select" method in the FormHelper - so before, where I had this:

echo $this->Form->select('treatment_id', $treatments, null, array('empty' => '-- select treatment to rate -- '));

i now have this:

echo $this->Form->select('treatment_id',$treatments, array('empty' => '-- select treatment to rate -- '));

And now one of my components - actually, the You_tube_loader_component - was broken. I need to modify it so that the header reads:

class YouTubeLoaderComponent extends Component {
    function __construct(ComponentCollection $collection, $settings = array()) {
        parent::__construct($collection, $settings);
        ...
    }
}

Previously i had just defaulted the valeus of the uname and password - now i stick them in the "..." section instead of messing around with the mysterious "settings" array!

Next up is:

Warning (2): Illegal offset type [CORE/Cake/Model/Model.php, line 2689]

Warning (2): Illegal offset type [CORE/Cake/Model/Model.php, line 2665]

Soooo this is a problem that isn't picked up in cake 1.3, but is in 2.1

The issue is that in the controller action being referenced, there is a "find" call without a type paramter. That is, I had

$results = $this->User->find(array(...), array(...), null, false);

where i should have had:

$results = $this->User->find('first',array(
    'conditions' => array("User.id" => ($this->Auth->user("id"))),
    'fields' => array("User.confirmed") 
)
);

Another issue I had was that, for whatever reason, the check:

$this->set('loggedIn', $this->Auth->user('id'));

did not work. Apparently (although am unsure how/why), cakePHP auth in 2.x will no longer store all the user's details to the session. I don't know which details it stores to the session, or how to modify them - looking into that! - but my code wasn't saving the "id" value, so the check above always set the loggedIn value to false.

To remedy, I modified the call to read:

$this->set('loggedIn', $this->Auth->loggedIn());

which worked fine for me.

Next problem is that the thios->auth->user('id') will return me sweet nothing after logging in a user. Fortunately I came across this post, that made things clearer:

http://ask.cakephp.org/questions/view/unable_to_access_logged-in_users_data_in_2_0

Amazingly, the geniuses at cake labs thought that changing the very way that logging in worked would help clear up some confusion. To be honest, the only thing I'm confused about is who was so confused about the fact that the auth component had all the user's details available after logging in. But fear not, they've cleared the confusion up and... removed the feature entirely.

So, what are you to do? The link above suggests getting all the user details, then shipping that into the auth login section. I don't particularly like this (because it is a stupid problem and i cannot believe anything so inelegant is needed), but it is what I have to do. Suggestions welcome!

So instead of the oh-so-confusing:

if ($this->Auth->login($this->request->data)) {
    ... //argh! I am so confused by that line above!!!1

i now have:

$user = $this->User->find('first', array(
    'conditions' => array('User.email' =>   $this->request->data['User']['email'])
    )
);
// Use the AuthComponent~Rs login action
if ($this->Auth->login($user['User'])) {
    ... //omg the extra check that the entry is in the db is just brilliant and efficient

isn't that just so much neater and less confusing? Good job, cakephp mavericks!

The next error is

Authorization adapter "controller" was not found.

Which is a bit vague...

Ah! Answered already on stack overflow here: Authorization adapter was not found in cakePHP

And that was it! There might be other issues - god speed on them - but i didn't come across them, so i cannot help you any more.

这篇关于Cakephp从1.3升级到2.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆