Jump to content

PHP Warning:  Declaration of Product::addAttribute in Apache2 error logs


Mold

Recommended Posts

Greets

I could use a bit of help in following issue. I get a warning like this in Apache error logs repeating constantly.

[Wed Mar 21 16:32:34.201653 2018] [:error] [pid 27135] [client XXX.XXX.XXX.XXX:XXXX] PHP Warning:  Declaration of Product::addAttribute($price, $weight, $unit_impact, $ecotax, $id_images, $reference, $ean13, $default, $flagnew = false, $location = NULL, $upc = NULL, $minimal_quantity = 1, array $id_shop_list = Array, $available_date = NULL) should be compatible with ProductCore::addAttribute($price, $weight, $unit_impact, $ecotax, $id_images, $reference, $ean13, $default, $location = NULL, $upc = NULL, $minimal_quantity = 1, array $id_shop_list = Array, $available_date = NULL) in /var/www/XXXXXXX/public_html/override/classes/Product.php on line 0, referer: http://XXXXXXX/

I didn't mentioned this to affect normal site working capacity. But I would like to know what is the problem and how get rid of this error if it's possible. 

Installed software versions:

Prestashop - 1.6.11

PHP - 7.0

Apache Server - 2.4.18

(my PHP skills can be estimated at a junior level - if this matter)

Thanks in advance.

Link to comment
Share on other sites

According to the last line of the error message this comes from an override. That means some module that you have installed. It looks like that module has some incompatibilities with your Prestashop version. Given that you don't see a problem this most likely isn't a serious problem. You should ask the provider of that module for an update.

Finding out which module it is can be a bit of a job. Some options:

 - you can open the indicated override file and see whether its contents reveal something

 - you can search among your module files for a file with the same name as the override

 - Prestools has a function for this.

Link to comment
Share on other sites

Oh! Prestools Suite looks like a must have useful tool. I'll take a closer look at it later.

 

The file Product.php exist only in ..classes/ and ..override/classes/  folders. So I have no Idea which module put it there in override folder.

I compared this 2 files and found out than in core class the function addAttribute() is missing one argument $flagnew.

Now I could go the dirty way and delete this argument from addAttribute function in the overriding class. And from addCombinationEntity function that calls addAttribute. Not sure if this is a good idea.

But the problem seems to be in that core class is older than the overriding one, that added a functionality to set a product attribute as new. In this case a Prestashop update to latest version could solve this and maybe some other issues. I've tried it on a test server some time ago and was getting a 500 error message.

Maybe it's time for another try... that would you advice me.  

Link to comment
Share on other sites

I've successfully upgraded PrestaShop 1.6.1.11 to 1.6.1.18.

After upgrade Back Office become much slower :(

[UPDATE] Fixed speed issue thanx to this post. I've been too restrictive on permissions.

But the warning error I described above is still cluttering apache error log file.

Edited by Mold (see edit history)
Link to comment
Share on other sites

If the content of the override file says nothing about its origin you can go further:

 - you can study its code and compare it to the original to see what the extra functionality is

 - you can try renaming it (you can also try deleting but renaming makes it easier to set it back). and see whether something stops working.

Link to comment
Share on other sites

8 hours ago, Mold said:

But the warning error I described above is still cluttering apache error log file.

You have an existing Product override, which needs to be refactored (aka updated) to conform to the new version of Prestashop that you are using.  Once you do that, the error will go away.

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