Jump to content

Error When Saving Products after Upgrade to Mysql 5.7


gurdipsk

Recommended Posts

I encountered several errors in Prestashop after the server was upgraded, it now uses Mysql 5.7. Mysql5.7  is strict and is causing issues on Prestashop sites. I managed to solve some of them.

The issue now is that saving  edits to a products show a white admin screen and the word ERROR. But I can see that the product is saved and shows properly on the frontend.

The following is a bit of background in my journey in solving issues (may be useful). I hope someone can provide some pointers on how to save products without the error warning.

 

First Error (solved)

<blockquote>Bad SQL query
Expression #11 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'lenbrook_eshopdb.sav.quantity' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
</blockquote>

This was solved by changing sql_mode in /etc/my.cnf by removing "ONLY_FULL_GROUP_BY".

 

Next, Error in backend when updating products (solved):
"An error occurred while updating object. product ()"

"Warning: preg_match() expects at least 2 parameters, 1 given in /home/lenbrook/public_html/classes/Validate.php on line 405"
"Incorrect date value: '0000-00-00' for column 'available_date' at row 1"

Also, errors when trying to create an account. Apparently Mysql 5.7 does not accept 0 dates.

How solved: sql_mode was again changed, to remove: STRICT_TRANS_TABLES, NO_ZERO_IN_DATE,NO_ZERO_DATE,
I can also create new accounts now.

 

Current error:

When a product is edited and saved, a white admin screen shows with the words ERROR. have to hit the back key to return to the product edit screen. Then use Back to List to return to the list of products. But the product edits are saved. The errors I see in dev mode are:

"Warning: preg_match() expects at least 2 parameters, 1 given in /home/xxx/public_html/classes/Validate.php on line 405
ERROR"

Line 405 relates to isCleanHtml validator. Seemed to be having an issue with <iframe> in product descriptions so I set Preference > General > Allow iframes to Yes. This got rid of the warning, but the word"ERROR" remains. I have also tried to override Product.php class and remove the validation on product descriptions (/override/classes/Product.php):

<?php

class Product extends ProductCore
{
    public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
    {
        // Here we remove script validation on description_short field
        unset(static::$definition['fields']['description_short']['validate']);

        parent::__construct($id_product, $full, $id_lang, $id_shop, $context);
    }
}

... and deleted /cache/class_index.php so that Prestashop takes this override into account.

No effect whatsoever :(

 

Any ideas?

 

 

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