简体   繁体   English

禁用magic_quotes_gpc

[英]Disabling magic_quotes_gpc

I have a site, locally setup. 我有一个网站,在本地设置。 It's application development framework is Kohana. 它的应用程序开发框架是Kohana。

I have an error displaying the following: 我在显示以下错误:

Unknown Error

An error was detected which prevented the loading of this page. If this problem persists, please contact the website administrator.

system/core/Kohana.php [98]:

Function set_magic_quotes_runtime() is deprecated
Stack Trace

    * system/core/Kohana.php [98]:

      set_magic_quotes_runtime(  )

    * system/core/Bootstrap.php [39]:

      Kohana::setup(  )

    * index.php [130]:

      require( system/core/Bootstrap.php )

Loaded in {execution_time} seconds, using {memory_usage} of memory. Generated by Kohana v{kohana_version}.

I've been told by another lead developer of this project, to disable magic_quotes in my php.ini .. 该项目的另一位主要开发人员告诉我,要禁用php.ini中的magic_quotes ..
I'm using MAMP, and I've done so. 我正在使用MAMP,并且已经这样做了。

Problem is still apparent.. any clues as to what this error is caused by, how to get around? 问题仍然很明显..关于此错误是由什么引起的任何线索,如何解决?

Another quick something to note, when outputting phpinfo() , I get the following: 另一个需要注意的快速提示,当输出phpinfo() ,我得到以下信息:

local value Off
Master Value On

Do I have to disable master value? 我必须禁用主值吗? If so, how? 如果是这样,怎么办?

Your using PHP 5.3 and since magic_quotes is drepacted in PHP 5.3 and will be removed. 您使用的是PHP 5.3,由于magic_quotes在PHP 5.3中已删除,将被删除。 all functions that alter this ini setting throws an error. 更改此ini设置的所有函数都会引发错误。

Quick solution: go to file system/core/Kohana.php Line 98 and out-comment the set_magic_quotes_runtime 快速解决方案:转到文件system / core / Kohana.php第98行,并注释掉set_magic_quotes_runtime

or switch to PHP 5.2.10 或切换到PHP 5.2.10

您可以在system / core / Kohana.php的第98行注释掉set_magic_quotes_runtime()调用

You are probably running PHP 5.3.x. 您可能正在运行PHP5.3.x。
If you have have write access to your php.ini , you might want to try setting the error_reporting configuration entry to hide such E_DEPRECATED warnings. 如果您具有对php.ini写权限,则可能要尝试设置error_reporting配置条目以隐藏此类E_DEPRECATED警告。

Example (your mileage may vary...): 示例(您的里程可能有所不同...):

error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED

On development machines however, you usually want as many warnings as possible to fix bad or obsolete code. 但是,在开发机器上,您通常需要尽可能多的警告来修复错误或过时的代码。

See also 也可以看看

EDIT: 编辑:
This would fix the symptom rather than the cause (editing the Kohana file) but personally, I don't like patching third-party libraries because you will have to do that for each new release you update to, unless the new release works in the very aspect the patch is about to fix. 这将解决症状,而不是原因(编辑Kohana文件),但就个人而言,我个人不喜欢修补第三方库,因为您必须为更新到的每个新版本执行此操作,除非该新版本可以在该补丁将要修复的方面。

EDIT 2: 编辑2:
To fix the cause, you could replace set_magic_quotes_runtime([VALUE]) with ini_set('magic_quotes_runtime', [VALUE]) . 为了解决问题,您可以将set_magic_quotes_runtime([VALUE])替换为ini_set('magic_quotes_runtime', [VALUE])

This is probably safer than just removing the call because while the function is deprecated, it can still have an effect on the behavior of the software if omitted (if the PHP installation has magic_quotes_runtime enabled). 这可能比仅删除调用更为安全,因为不推荐使用该函数, 如果省略该函数, 则仍会影响软件的行为(如果PHP安装启用了magic_quotes_runtime )。

You might also want to check for a newer version of Kohana where this is fixed. 您可能还需要检查是否已修复了Kohana的较新版本。

Note, however, that upgrading a framework should be done with extreme care and extended testing to ensure that things continue to work as expected. 但是请注意,升级框架时应格外小心并进行扩展测试,以确保事情继续按预期进行。

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

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