Jump to content

Undefined property: stdClass::$date


Maison Bally

Recommended Posts

Hi,

I'm new with prestashop and not a professionnal developper. I'm trying to set after-sale service parameters, both my webmail server and prestashop files are hosted by ovh. I access my mails through Thunderbird.

I found all informations (imap server name etc) but when I save the parameters in PS back-office and refresh the page, I get this message error :

 

Notice at line 1049 in file /home/(database_name)/www/controllers/admin/AdminCustomerThreadsController.php
[8] Undefined property: stdClass::$date

 

I tried to search on the web but my skills aren't that good to understand what to do... If you have any ideas.

As an secondary question, can my password in Thunderbird (and prestashop imap parameters) include special characters such as & ? I wonder if the problem can come from this.

 

Thanks !

Link to comment
Share on other sites

Hello Maison Bally,

That seems to be an issue with the email object that came through the IMAP server or your host's PHP Version is outdated, this is happening because the PHP method "imap_fetch_overview()" does not have the date element (which should based on PHP's documentation: http://php.net/manual/en/function.imap-fetch-overview.php ).

This is what is happening: image.png.82705b001e086d5b36dc39d014c7ed93.png

PrestaShop checks to make sure that the message have a subject, but it never checks for date.

Looking at the code of the controller, PrestaShop only requires the date to generate this md5_header to check if the message was previously processed. You can easily workaround that by doing the following code changes:

Replace:

            //check if message exist in database
            if (isset($overview->subject)) {
                $subject = $overview->subject;
            } else {
                $subject = '';
            }
            //Creating an md5 to check if message has been allready processed
            $md5 = md5($overview->date.$overview->from.$subject.$overview->msgno);

With:

            //check if message exist in database
            if (isset($overview->subject)) {
                $subject = $overview->subject;
            } else {
                $subject = '';
            }            
            if (isset($overview->date)) {
                $message_date = $overview->date;
            } else {
                $message_date = 'No date';
            }
            //Creating an md5 to check if message has been allready processed
            $md5 = md5($message_date.$overview->from.$subject.$overview->msgno);

This will solve your issue, however, you must verify why the date object is not there, as this can become problematic in the future (we recommend this solution if some objects do not have the element, if all of them do not have it, do not change the code... find out with your hosting company why it is missing).

A suggestion to debug it is to add the lines:

			print '<pre>';
			print_r($result);
			die;
			

Before:

            //check if message exist in database
            if (isset($overview->subject)) {
                $subject = $overview->subject;
            } else {
                $subject = '';
            }

 

Please update the post with the result of the changes and investigation.

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