Jump to content

Errors Related to Tools.php


Recommended Posts

Been working on a site on and off for the past year and recently noticed that when I click Categories in BO, I get a blank page.  So I enabled debugging and the error that shows is this:

 

Fatal error: Call to undefined method Tools::getDescriptionClean() in /home/username/public_html/shop/controllers/admin/AdminCategoriesController.php on line 789

 

I also noticed now, with debugging on, for every page of the FO, I have the following error at the top about 40 times:

 

Warning: trim() expects parameter 1 to be string, array given in /home/username/public_html/shop/classes/Tools.php on line 1140

 

Any ideas on how to troubleshoot this?  Both errors seem to have something to do with Tools.  I have not modified anything in Tools.php.  Running Prestashop 1.6.0.9. 

 

Please let me know if you have any ideas.

 

Thanks!

 

Alex

 

Link to comment
Share on other sites

Not modified at all? It can't be dying all of a sudden if you didn't upgrade any file.

Add this to the tools class
 

public static function getDescriptionClean($description)
{
return strip_tags(stripslashes($description));
}
Link to comment
Share on other sites

 

Not modified at all? It can't be dying all of a sudden if you didn't upgrade any file.

 

Add this to the tools class

 

public static function getDescriptionClean($description)
{
return strip_tags(stripslashes($description));
}

 

 

Thanks, Nemo1!

 

I promise I didn't modify the tools.php file myself directly.  Would a module being installed and/or enabled cause changes in the file?  Where would I need to add that code?  

 

I went back and re-downloaded PS 1.6.0.9 and used Diffmerge to compare a clean Tools.php with what I had.  I found that a lot of code (24 instances) in my version had been deleted. Very specific things, like "Tools::" was deleted from the line 

return Tools::strtolower(trim(preg_replace('/([A-Z][a-z])/', '_$1', $string), '_'));

And many other instances of "Tools::" being removed.  Also, just large chunks of code were missing.  Very strange.  I hope modules wouldn't make those kinds of changes.  

 

As a test, I went ahead and swapped the fresh Tools.php for my old one, but that didn't seem to solve the problem exactly.  I cleared cache using the button in BO and turned on force recompile, but I'm still getting the following on every page in FO:

 Warning: trim() expects parameter 1 to be string, array given in /home/hilus3/public_html/shop/classes/Tools.php on line 1141

And now in BO, I can get into the Categories menu option with no issue, but when I click on a Product, the Short Description and Description fields are not there.  The label for them is, but there is just white where there used to be a field.  

 

Any help or advise is much appreciated. 

 

Thanks!

 

Alex

 
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...