Magic quotes in joomla 3.0.2 Print

  • 51

I've been seeing quite a few questions relating to Magic Quotes needing to be turned off in order to install Joomla 3.0 Many of the responses ask you to alter the php.ini or edit other high level server config.

All of this unnecessary server tinkering is just madness!
You can't even install Joomla 3.0 without turning off Magic Quotes.
And its these kind of UX blocks that put Joomla so far backwards it's not even funny.

In many cases altering php.ini is just not possible (shared hosting etc).
Magic Quotes Enable sites have existed no problem alongside Anti Magic Quotes sites, so what changed in Joomla 3.0? Why should you alter your server config?

With some careful editing, you can turn the clock back to the way things used to be and use Joomla 3.0 with Magic Quotes turned ON!

Here's how to do it:
Step 1 Download the latest Joomla 3.0
Step 2 Extract the files on your server
Step 3 Open your favourite PHP editor
Step 4 Navigate and open installation/models/setup.php
Step 5 Scroll down to find line 234
// Check for magic quotes gpc.
$option = new stdClass;
$option->label = JText::_('INSTL_MAGIC_QUOTES_GPC');
$option->state = (ini_get('magic_quotes_gpc') == false);
$option->notice = null;
$options[] = $option;

Step 6 Comment out the code above and save the file

Now you can install Joomla 3.0 no problem.
However, Magic Quotes and Joomla's new special character escaping will cause duplicate escaping when editing/creating content. This renders anything that's not plain text incorrectly. So, we need to add one small condition to the core (this used to exist pre Joomla 3.0)
Step 1 Navigate and open libraries/joomla/filter/input.php
Step 2 Scroll down to find line 261
public function clean($source, $type = 'string')
// Handle the type constraint
switch (strtoupper($type))
// Handle magic quotes compatibility
if(get_magic_quotes_gpc()) $result = self::_stripSlashesRecursive($result);
Step 3 Add the code marked above to the clean function
Step 4 You may have noticed we're only running this when Magic Quotes is set to ON and referring to a new function called _stripSlashesRecursive. Now, we need to add that function to the class.
Scroll to line 755 and add the following function:
* Strips slashes recursively on an array.
* @param array $value Array or (nested arrays) of strings.
* @return array The input array with stripslashes applied to it.
* @deprecated 12.1 - Sanctioned on 2012-10-09 thanks to Anton Wintergerst
* @since 11.1
protected static function _stripSlashesRecursive($value)
$value = is_array($value) ? array_map(array('JFilterInput', '_stripSlashesRecursive'), $value) : stripslashes($value);
return $value;

If you want to learn about why Joomla is trying to force us to disable Magic Quotes then check out this link:

Was this answer helpful?

« Back

Powered by WHMCompleteSolution