PHP errors and warnings. PC 5 beta51. PHP 8.3

Phoca Cart - complex e-commerce extension
User avatar
sulpher
Phoca Professional
Phoca Professional
Posts: 103
Joined: 28 Feb 2017, 09:45

PHP errors and warnings. PC 5 beta51. PHP 8.3

Post by sulpher »

AH01071: Got error 'PHP message: PHP Warning: Trying to access array offset on null in /var/www/administrator/components/com_phocacart/libraries/phocacart/order/order.php on line 2968;

PHP message: PHP Warning: Trying to access array offset on null in /var/www/administrator/components/com_phocacart/libraries/phocacart/order/order.php on line 2969;

PHP message: PHP Warning: Trying to access array offset on null in /var/www/administrator/components/com_phocacart/libraries/phocacart/order/order.php on line 2970;

PHP message: PHP Warning: Trying to access array offset on null in /var/www/administrator/components/com_phocacart/libraries/phocacart/order/order.php on line 2971;

PHP message: PHP Warning: Trying to access array offset on null in /var/www/administrator/components/com_phocacart/libraries/phocacart/order/order.php on line 2972;

PHP message: PHP Warning: Attempt to read property "date" on null in /var/www/administrator/components/com_phocacart/libraries/phocacart/order/status.php on line 131;

PHP message: PHP Warning: Attempt to read property "order_number" on null in /var/www/administrator/components/com_phocacart/libraries/phocacart/order/status.php on line 131;
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48345
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: PHP errors and warnings. PC 5 beta51. PHP 8.3

Post by Jan »

Hi, are you 100% your database table structure is complete?

Do you have following columns in table "phocacart_orders"?

tracking_date_shipped
invoice_date
invoice_due_date
invoice_time_of_supply
required_delivery_time

Jan
If you find Phoca extensions useful, please support the project
User avatar
sulpher
Phoca Professional
Phoca Professional
Posts: 103
Joined: 28 Feb 2017, 09:45

Re: PHP errors and warnings. PC 5 beta51. PHP 8.3

Post by sulpher »

Yes, all these columns exist in table.
It was clean installation of PC5 beta51 on J5.1.0.
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48345
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: PHP errors and warnings. PC 5 beta51. PHP 8.3

Post by Jan »

This is hard to say because when the columns are loaded from DB, they should be included in the array/object. Where exactly do you get these errors?

Jan
If you find Phoca extensions useful, please support the project
User avatar
sulpher
Phoca Professional
Phoca Professional
Posts: 103
Joined: 28 Feb 2017, 09:45

Re: PHP errors and warnings. PC 5 beta51. PHP 8.3

Post by sulpher »

I can't remember what I did that lead to these issues. I tested payment plugins. WIll take more attention during the next testing.

Btw, is there a situation that some outdated code in the payment plugin leads to these warnings?
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48345
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: PHP errors and warnings. PC 5 beta51. PHP 8.3

Post by Jan »

These are errors inside core libraries, so yes, it is possible that some obsolete plugin can invoke it but the core should somehow protect from this. But on the mentioned lines, the code goes directly from database, so the variables should be loaded there. :idea:

Jan
If you find Phoca extensions useful, please support the project
User avatar
sulpher
Phoca Professional
Phoca Professional
Posts: 103
Joined: 28 Feb 2017, 09:45

Re: PHP errors and warnings. PC 5 beta51. PHP 8.3

Post by sulpher »

Today I logged in to the site, proceeded to My orders page and go to empty checkout page. No payment method was launched and there are entries in error.log:
PHP Warning: Trying to access array offset on null in /var/www//administrator/components/com_phocacart/libraries/phocacart/order/order.php on line 2971; PHP message: PHP Warning:
Trying to access array offset on null in /var/www//administrator/components/com_phocacart/libraries/phocacart/order/order.php on line 2972; PHP message:

PHP Warning: Trying to access array offset on null in /var/www//administrator/components/com_phocacart/libraries/phocacart/order/order.php on line 2973; PHP message: PHP Warning: Trying to access array offset on null in /var/www//administrator/components/com_phocacart/libraries/phocacart/order/order.php on line 2974;

PHP message: PHP Warning: Trying to access array offset on null in /var/www//administrator/components/com_phocacart/libraries/phocacart/order/order.php on line 2975;

PHP message: PHP Warning: Attempt to read property "order_number" on null in /var/www//administrator/components/com_phocacart/libraries/phocacart/order/status.php on line 131; PHP message: PHP Warning: Attempt to read property "user_id" on null in /var/www//administrator/components/com_phocacart/libraries/phocacart/order/status.php on line 443'

PC 5.0.0Beta54, PHP 8.3.8, Joomla 5.1.1
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48345
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: PHP errors and warnings. PC 5 beta51. PHP 8.3

Post by Jan »

Hi, see the code, there is a database query which asks the columns, e.g. column: tracking_date_shipped

Code: Select all

$query = ' SELECT date, invoice_number_id, invoice_number, invoice_prn, invoice_date, invoice_due_date, invoice_time_of_supply, tracking_date_shipped, required_delivery_time  FROM #__phocacart_orders WHERE id = ' . (int)$id . ' ORDER BY id LIMIT 1';
and then you ask the value with:

$d['tracking_date_shipped'] = $orderData['tracking_date_shipped'];

Then it is not possible, that this value will be null, except, e.g. the database column does not exist in your database :idea:

Check the table #__phocacart_orders for tracking_date_shipped column :idea:


Can you let me know the code of: administrator/components/com_phocacart/libraries/phocacart/order/order.php

between lines: 2964 and 2976?

Jan
If you find Phoca extensions useful, please support the project
User avatar
sulpher
Phoca Professional
Phoca Professional
Posts: 103
Joined: 28 Feb 2017, 09:45

Re: PHP errors and warnings. PC 5 beta51. PHP 8.3

Post by sulpher »

Jan wrote: 11 Jun 2024, 16:12 Hi, see the code, there is a database query which asks the columns, e.g. column: tracking_date_shipped

Code: Select all

$query = ' SELECT date, invoice_number_id, invoice_number, invoice_prn, invoice_date, invoice_due_date, invoice_time_of_supply, tracking_date_shipped, required_delivery_time  FROM #__phocacart_orders WHERE id = ' . (int)$id . ' ORDER BY id LIMIT 1';
and then you ask the value with:

$d['tracking_date_shipped'] = $orderData['tracking_date_shipped'];

Then it is not possible, that this value will be null, except, e.g. the database column does not exist in your database :idea:

Check the table #__phocacart_orders for tracking_date_shipped column :idea:
this column exists:
Image

btw, I just installed several beta versions over existing ones. Is it necessary? No SQL code need to be executed?
As we see, the required column exists, but I just ask for future.
Can you let me know the code of: administrator/components/com_phocacart/libraries/phocacart/order/order.php

between lines: 2964 and 2976?

Jan
Here is code (PC 5.0 beta54 installed) :

Code: Select all

        $db->setQuery($query);
        $orderData = $db->loadAssoc();

        // SEE: administrator/components/com_phocacart/tables/phocacartorder.php
        // some date columns cannot have null values, as null values will be transformed to 0000-00-00 00:00:00 in check function
        // instead of leaving yet stored data in database (values with null standardly do not change current data in database)
        // $d['date'] - defined previously
        $d['tracking_date_shipped'] = $orderData['tracking_date_shipped'];
        $d['invoice_date']          = $orderData['invoice_date'];
        $d['invoice_due_date']      = $orderData['invoice_due_date'];
        $d['invoice_time_of_supply']= $orderData['invoice_time_of_supply'];
        $d['required_delivery_time']= $orderData['required_delivery_time'];
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48345
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: PHP errors and warnings. PC 5 beta51. PHP 8.3

Post by Jan »

The code is the same on your instance, so hard to say why it does produce such errors. I will try to do more tests.

Jan
If you find Phoca extensions useful, please support the project
Post Reply