Jump to content

Tools::nl2br() error after upgraded from 1.4.9 to 1.5.3


Recommended Posts

Hello i have tried to upgrade my prestashop from 1.4.9 to 1.5.3. i have uploaded the site on a different folder to check if is working first. when i upgraded the website i had this error

 

<action result="fail" error="28" />

I've change the settings in order to see the errors and i had this error.

Fatal error: Call to undefined method Tools::nl2br() in testfolder/classes/db/Db.php on line 626

 

how i can fix it?

Link to comment
Share on other sites

  • 5 weeks later...

Ok, you can fix this by doing the following:

 

In the file:

/modules/autoupgrade/classes/Tools14.php

 

Put the following code in somewhere with the file that does not break or disturb any other function.

 

 

* Convert \n and \r\n and \r to <br />
 *
 * @param string $string String to transform
 * @return string New string
 */
public static function nl2br($str)
{
 return str_replace(array("\r\n", "\r", "\n"), '<br />', $str);
}

 

This is because this little function was missed out of the file.

  • Like 1
Link to comment
Share on other sites

I slotted this in on line 1933 just after the displayAsDeprecated function...which is also called during the autoupgrade process.

 

It also didn't stop multiple errors from occurring in the database upgrade, which I will look at in a different thread.

/**
 * Display a warning  message indicating that the method is deprecated
 */
public static function displayAsDeprecated()
{
 if (_PS_DISPLAY_COMPATIBILITY_WARNING_)
 {
  $backtrace = debug_backtrace();
  $callee = next($backtrace);
  trigger_error('Function <strong>'.$callee['function'].'()</strong> is deprecated in <strong>'.$callee['file'].'</strong> on line <strong>'.$callee['line'].'</strong><br />', E_USER_WARNING);
  $message = self::displayError('The function').' '.$callee['function'].' ('.self::displayError('Line').' '.$callee['line'].') '.self::displayError('is deprecated and will be removed in the next major version.');
  Logger::addLog($message, 3, $callee['class']);
 }
}
/**
 * Convert \n and \r\n and \r to <br />
 *
 * @param string $string String to transform
 * @return string New string
 */
public static function nl2br($str)
{
 return str_replace(array("\r\n", "\r", "\n"), '<br />', $str);
}

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...