Question

My crappy web host did some upgrades the other day and some settings have gone awry, because looking at our company's wiki (MediaWiki), every quote is being escaped with a backslashes. It's not even just data which is being posted (ie: the articles) which are affected, but also the standard MediaWiki text. eg:

You\'ve followed a link to a page that doesn\'t exist yet. To create the page, start typing in the box below (see the help page for more info). If you are here by mistake, just click your browser\'s \'\'\'back\'\'\' button.

The first thing I did was disable magic_quotes_gpc AND magic_quotes_runtime using a .htaccess file, but this is still occurring. My php_info() reports this:

Setting             Local Value   Master Value  
magic_quotes_gpc        Off            On  
magic_quotes_runtime    Off            On  
magic_quotes_sybase     Off            Off  

Any ideas?

Was it helpful?

Solution

If PHP flags are set with php_admin_flag/php_admin_value, you can't change it from a .htaccess file. This has caused me some headache before. Either disable it in php.ini or undo magic quotes in runtime: http://talks.php.net/show/php-best-practices/26

OTHER TIPS

You may want to confirm that the data in your DB hasn't been corrupted. If you were addslash()ing your data when, unbeknownst to you, magic_quotes had been turned on, then you'd be double-slashifying data going into your DB.

You'll need to get them to change the master value, or handle it yourself. I don't believe you can set magic_quotes_gpc() at runtime for super globals. (setting it at runtime will strip things like database/files, but not the globals)

if (ini_get('magic_quotes_gpc') ) {
  foreach($_GET as $key=>$value) {
    $_GET[$key] = stripslashes($value);
  } 
} // etc...

Perhaps something else is calling set_magic_quotes_runtime().

I use stripslases() to remove slashes when displaying.

http://www.php.net/manual/en/function.stripslashes.php

Have you tried contacting your crappy host and logging a fault? You're probably not the only one affected if you are on shared hosting.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top