This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Blogs » Gaetano Giunta » eZ on Cheap Hosting, episode I -...


eZ on Cheap Hosting, episode I - solving the magic_quotes_gpc problem

Saturday 02 February 2013 6:58:09 pm

  • Currently 5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

This is the first in a series of blog posts dedicated to installing eZ Publish on cheap hosting.

"Cheap hosting" in this context has no strict definition; it is a term used to denote the hosting solutions on shared servers which typically give to the user little control over the configuration of the LAMP stack: no cronjobs, no shell access, no access to php.ini, no choice of storage engine or charset for mysql databases etc...

There are many small quirks with such solutions which can make life of the eZ developer hard - often not documented well if at all in the descriptions of the offer itself. The upside is that they generally can be rented almost for free, making them attractive for the cash-strapped personal-blog type of users. And even if you find one which is really incompatible, it will not make a huge dent in your pocket.

Without further ado, this one concentrates on problems with the php.ini setting "magic_quotes_gpc".

The observable behaviour is: impossibility to add images to rich text fields, quotes in text fields which get replaced by backslash-quote.

Read on for the solution...


As per the requirements, for a correct execution of eZ, the value for the php settings magic_quotes_gpc has to be off.

Some shared-hosting solutions have it on.

Symptoms analysis

The symptoms include: impossibility to add images to rich text fields, quotes in text fields which get replaced by backslash-quote. No editor would be happy with that.

You can verify this in the Administration Interface, by going to "System Information", then clicking on the small "phpinfo" link which takes to the full phpinfo information page, then serach for the word "magic_quotes_gpc" in the list of values displayed.

Solution I

If you can put an .htaccess file in the root directory of your eZ installation, you might be able to fix the problem by adding the following line in there:

php_flag   magic_quotes_gpc      Off

I say "you might" because when I tried this, all I got was an error message for the whole website... Luckily replacing the .htaccess file with the original version is an easy operation.

The problem is that this method will only work when php is executed in mod_php mode, and most shared hosting solutions run php in cgi mode.

Solution II

Luckily for us php is a fairly flexible language, and eZ allows inclusion of an extra php file at the beginning of execution of every web page. Armed with this knowledge, you can:

  • create a config.php file at the root of your installation
  • add the following content into it
function stripslashes_deep($value)
    $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
    return $value;
$_GET = stripslashes_deep($_GET);$_POST = stripslashes_deep($_POST);

And voilà, done.

Proudly Developed with from