简体   繁体   English

想让CakePHP 1.1在PHP 5.3上运行

[英]Want to get CakePHP 1.1 working on PHP 5.3

I manage a CakePHP 1.1 CMS website, and our hosts just upgraded PHP to 5.3, causing a number of errors, such as: 我管理一个CakePHP 1.1 CMS网站,我们的主机刚刚将PHP升级到5.3,导致了一些错误,例如:

Notice: Undefined variable: banner_image in /home2/intiwara/cake/app/views/layouts/public_site.thtml on line 49
Notice: Undefined variable: news_menu in /home2/intiwara/cake/app/views/articles/volunteer_animal_refuge.thtml on line 73

I can hide the errors by altering cake/cake/libs/configure.php line 133 to be: 我可以通过改变cake / cake / libs / configure.php第133行来隐藏错误:

error_reporting(E_ERROR);

However the variables and models are still not found so the page does not render. 但是仍然找不到变量和模型,因此页面不会呈现。

I realize I need to upgrade to CakePHP 2.1, and every post I find dwells on this. 我意识到我需要升级到CakePHP 2.1,我发现每篇帖子都有关于此的内容。 However I'm the only technical volunteer here, I have only a few hours tomorrow afternoon to get the site working, then I am offline for two weeks' work in rural Ethiopia, so I'm hoping there's a 'workaround' solution I can put in place in the meantime. 然而,我是这里唯一的技术志愿者,我明天下午只有几个小时让网站正常工作,然后我在埃塞俄比亚农村工作了两个星期的工作,所以我希望有一个'解决方案'解决方案我可以在此期间到位。 (The hosts didn't tell us this was about to happen..) (主持人没告诉我们这件事即将发生..)

I don't need the admin functionality, I don't mind hiding errors - I just need the site to render. 我不需要管理员功能,我不介意隐藏错误 - 我只需要网站进行渲染。 Is there any way I can trick PHP 5.3 to 'see' these variables? 有什么方法可以欺骗PHP 5.3来“看到”这些变量吗?

Thank you hugely Chris 非常感谢克里斯

Here are the SVN comments from my conversion from 1.1 to 1.2. 以下是我从1.1到1.2的转换中的SVN注释。 I haven't bothered tidying them up, (except for the odd "ED:"), as I'm probably the last person to upgrade from CakePHP 1.1 and I should turn the light out when I leave.. These are the steps after I'd done the standard 'replaced cake directory' and 'config' updates detailed in the appendices on the CakePHP site: http://book.cakephp.org/view/3/The-Manual#!/1.2/en/view/411/Migrating-from-CakePHP-1-1-to-1-2 . 我没有打扰他们整理,(除了奇怪的“ED:”),因为我可能是最后一个从CakePHP 1.1升级的人,我应该在我离开时把灯关掉..这些是继之后的步骤我在CakePHP网站的附录中完成了标准的'替换蛋糕目录'和'配置'更新: http//book.cakephp.org/view/3/The-Manual#!/ 1/2 / en / view / 411 /从CakePHP-1-1-to-1-2迁移

It took me two solid days to upgrade a reasonably simple CMS with my rusty PHP, and the effort dissuaded me from using CakePHP again due to the awful documentation and the intricacies the use of a framework introduced. 我花了两天时间用我生锈的PHP升级一个相当简单的CMS,由于糟糕的文档和使用框架的复杂性,我努力阻止我再次使用CakePHP。 (Although I wasted half a day hours when my host thought one of my template files was a virus so blocked every IP address I could get on.) (虽然我浪费了半天的时间,当我的主人认为我的一个模板文件是病毒时,所以阻止我可以使用的每个IP地址。)

The biggest timesaver would have been if I'd have spotted form->error as a replacement for html->tagErrorMsg. 如果我发现form-> error作为html-> tagErrorMsg的替代,那么最大的节省时间。 Instead I removed them all, put the errors in the models following the standard practice in 1.2, then re-added them all. 相反,我将它们全部删除,按照1.2中的标准做法将错误放入模型中,然后重新添加它们。 form->input displays errors automatically, but it was easier for me to use form->select than form->input('type'=>'select'.. due to the complexity of converting the options and parameters from html->select to form->input using regular expressions. form-> input自动显示错误,但是我更容易使用form-> select而不是form-> input('type'=>'select'..由于从html转换选项和参数的复杂性 - >选择form->使用正则表达式输入。

  1. Html helper migrated to Form helper Html帮助程序迁移到Form帮助程序

  2. ->renderElement() needs to change to ->element() - > renderElement()需要更改为 - > element()

  3. ->del() needs to change to ->delete() - > del()需要更改为 - > delete()

  4. generateList() needs to be migrated to find('list', array()) 需要将generateList()迁移到find('list',array())

  5. VALID_EMAIL, VALID_NOT_EMPTY (and VALID_NUMBER) replaced with array('rule' => array('email')) and array('rule' => array('minLength', 1)) -- ED: these were later updated to include default error messages, although I think I needn't have if I'd known about form->error( VALID_EMAIL,VALID_NOT_EMPTY(和VALID_NUMBER)替换为数组('rule'=> array('email'))和数组('rule'=> array('minLength',1)) - ED:这些后来更新为包括默认错误消息,虽然我认为如果我知道form-> error我不需要

  6. changed form->input to form->text form->submit form->password Look at the code here https://github.com/zeroasterisk/CakePHP-cake_up-shell/blob/master/cake_up.php for some handy detailed info. 改变形式 - >输入到表格 - >文本表格 - >提交表格 - >密码在这里查看代码https://github.com/zeroasterisk/CakePHP-cake_up-shell/blob/master/cake_up.php获取一些方便的详细信息信息。

  7. controller this->redirects are now relative in 1.2, so I put an initial "/" where I hadn't in the 1.1 version 控制器this-> redirects现在相对于1.2,所以我把一个初始的“/”放在我没有的1.1版本中

  8. form->input(Model/property => form->text(Model.property html->tagValue(Model/property => html->value(Model.property html->selectTag(Model/property => form->select(Model.property $form->textarea('Article.intro $form->labelTag('Article.body form-> input(Model / property => form-> text(Model.property html-> tagValue(Model / property => html-> value(Model.property html-> selectTag(Model / property => form-> select) (Model.property $ form-> textarea('Article.intro $ form-> labelTag('Article.body)

  9. error messages now specified in model rather than template files with exception of controller-generated errors such as duplicate username when adding a user - these are set in the same way as before, but displayed using simply echo $username_error - ED: this was also a mistake - later changed to form->error('model.field', $custom_error, options eg css class) html->labelTag=>form->label tagValue=>value selectTag=>select in helper-generated HTML, use full stop as model.field separator rather than forward-slash, eg, html->value(model.field) instead of html->tagValue(model/field) 现在在模型而不是模板文件中指定的错误消息,除了控制器生成的错误,例如添加用户时重复的用户名 - 这些都是以与以前相同的方式设置,但只显示echo $ username_error - ED:这也是一个错误 - 后来改为form->错误('model.field',$ custom_error,选项例如css类)html-> labelTag => form-> label tagValue => value selectTag =>选择帮助生成的HTML,使用完整停止为model.field分隔符而不是正斜杠,例如,html-> value(model.field)而不是html-> tagValue(model / field)

  10. Remove san->sql and cleanUpFields Remove default error messages tagErrorMsg - ED: this and much of my validation updating was a mistake - I should have replaced html->tagErrorMsg with form->error Remove accent from Espanol option in form->selects due to new bug in 1.2 that can't display accents in option 删除san-> sql和cleanUpFields删除默认错误消息tagErrorMsg - ED:这和我的大部分验证更新是一个错误 - 我应该用form-> error替换html-> tagErrorMsg从表单中删除Espanol选项中的重音 - >选择到期1.2中的新错误,无法在选项中显示重音

  11. creating model.saveString to generate sql insert statement seems to be working (ED: I'd put a method in the core of CakePHP that generated an INSERT stmnt for a model, allowing me to do automatic email backups) 创建model.saveString以生成sql insert语句似乎正在工作(ED:我将一个方法放在CakePHP的核心中,为模型生成INSERT stmnt,允许我进行自动电子邮件备份)

  12. Alternative way of displaying errors using integrated form->input method - more elegant, displays errors and all types of HTML input control, but regular expression to replace specific calls with complex customization parameter arrays would have been too complex/unreliable. 使用集成表单 - >输入法显示错误的替代方法 - 更优雅,显示错误和所有类型的HTML输入控件,但使用复杂的自定义参数数组替换特定调用的正则表达式将过于复杂/不可靠。

  13. In controller, replaced model->validates(model) with this->set(this->data) then model->validates() 在控制器中,用this-> set(this-> data)替换model-> validates(model)然后model-> validates()

  14. Validation: Added form->error calls to every input. 验证:为每个输入添加了表单 - >错误调用。 (ED: should have used regular expression search and replace html->tagErrorMsg with form->error..this would have saved a lot of conversion effort) (ED:应该使用正则表达式搜索并用form-> error错误替换html-> tagErrorMsg。这样可以节省大量的转换工作量)

  15. Custom controller generated error messages must invalidate a fieldname and in the template, the field in form->error must match that fieldname, even if it isn't a model fieldname, eg, password1 and password2. 自定义控制器生成的错误消息必须使字段名无效,并且在模板中,form-> error中的字段必须与该字段名匹配,即使它不是模型字段名,例如password1和password2。

If you followed the conventions you might have some luck and be able to upgrade to 1.3 withing a reasonable amount of time if you have a higher level of experience with CakePHP. 如果您遵循惯例,您可能会有一些运气,并且如果您对CakePHP有更高的使用经验,则可以在合理的时间内升级到1.3。 From 1.1 to 2.1... this won't go that smooth. 从1.1到2.1 ......这不会那么顺利。

Without knowing the whole code and all the issues it's hard to tell anything, it's not even really possible to say if it would be better to try to work around with fugly fixes or to do a proper upgrade to 1.3. 在不知道整个代码和所有问题的情况下,很难说出任何问题,甚至不能说是否更好地尝试解决这些问题或者适当升级到1.3。

If this is really something mission critical contact me in private and I'll get you the contact to a company who can get it done. 如果这确实是关键任务,请私下与我联系,我会告诉您与能够完成任务的公司联系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM