Undefined Index Error when updating products in admin

Open to all! Ask other shopowners for help.
Post Reply
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Undefined Index Error when updating products in admin

Post by lecarlb »

Hello,

I'm using version 1.0.8.4 and I get the following errors:

Code: Select all

Notice: Undefined index: products_quantity in /usr/local/apache/subdomains/BTFraGranc3SbutL3r/www.xxxxxx.com/htdocs/adminBTblR/categories.php on line 197

Code: Select all

Fatal error: Uncaught TypeError: Argument 1 passed to Text::input() must be of the type string, null given, called in /usr/local/apache/subdomains/BTFraGranc3SbutL3r/www.xxxxxxxxx.com/htdocs/adminBTblR/categories.php on line 197 and defined in /usr/local/apache/subdomains/BTFraGranc3SbutL3r/www.xxxxxxxxx.com/htdocs/includes/system/versioned/1.0.8.2/text.php:34 Stack trace: #0 /usr/local/apache/subdomains/BTFraGranc3SbutL3r/www.xxxxxxxxxx.com/htdocs/adminBTblR/categories.php(197): Text::input() #1 {main} thrown in /usr/local/apache/subdomains/BTFraGranc3SbutL3r/www.xxxxxxxxxxx.com/htdocs/includes/system/versioned/1.0.8.2/text.php on line 34
Thank you.


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4561
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 413 times

Re: Undefined Index Error when updating products in admin

Post by burt »

Post 10 lines either way of L197 categories.php
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Undefined Index Error when updating products in admin

Post by ecartz »

It would be on the previous page actually, as that line in 1.0.8.4 is processing a form submission. So the question is why your form is missing the quantity field. Perhaps explain more about what you were doing immediately prior?
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: Undefined Index Error when updating products in admin

Post by lecarlb »

burt wrote: Wed Nov 01, 2023 10:11 am Post 10 lines either way of L197 categories.php

Code: Select all

        $OSCOM_Hooks->call('categories', 'moveProductConfirmAction');

        tep_redirect(tep_href_link('categories.php', 'cPath=' . $new_parent_id . '&pID=' . $products_id));
        break;
      case 'insert_product':
      case 'update_product':
        if (isset($_GET['pID'])) {
          $products_id = Text::input($_GET['pID']);
        }
        $products_date_available = Text::input($_POST['products_date_available']);

        $sql_data = [
          'products_quantity' => (int)Text::input($_POST['products_quantity']),
          'products_model' => Text::prepare($_POST['products_model']),
          'products_price' => Text::input($_POST['products_price']),
          'products_date_available' => (date('Y-m-d') < $products_date_available) ? $products_date_available : 'NULL',
          'products_weight' => (float)Text::input($_POST['products_weight']),
          'products_handling_shipping' => tep_db_prepare_input($_POST['products_handling_shipping']),
          'products_extra_shipping' => tep_db_prepare_input($_POST['products_extra_shipping']),
          'products_surcharge_shipping' => tep_db_prepare_input($_POST['products_surcharge_shipping']),
          'products_status' => Text::input($_POST['products_status']),
          'products_tax_class_id' => Text::input($_POST['products_tax_class_id']),
          'manufacturers_id' => (int)Text::input($_POST['manufacturers_id']),
          'products_gtin' => (Text::is_empty($_POST['products_gtin'])) ? 'NULL' : str_pad(Text::prepare($_POST['products_gtin']), 14, '0', STR_PAD_LEFT),
        ];
User avatar
burt
Core Team
Posts: 4561
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 413 times

Re: Undefined Index Error when updating products in admin

Post by burt »

You have some custom code in there, so I wonder if you have accidentally broken the "weight" input box?
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: Undefined Index Error when updating products in admin

Post by lecarlb »

burt wrote: Wed Nov 01, 2023 2:42 pm You have some custom code in there, so I wonder if you have accidentally broken the "weight" input box?
I'm beginning to think it's QTPro. I checked products without attributes and they seem to be fine.
raiwa
Certified Developer
Posts: 1641
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: Undefined Index Error when updating products in admin

Post by raiwa »

I just checked with QtPro last version and Phoenix 1.0.8.20. The error doesn't appear there. I have no old versions test installation and can't therefore debug for your version.
But looking at the qtPro admin hook it could be caused in line 94 or 98 depending on the version:

Code: Select all

        $summa = (int)(empty($list['summa'])) ? 0 : $list['summa'];
try to put the 0 (zero) in quotes:

Code: Select all

        $summa = (int)(empty($list['summa'])) ? '0' : $list['summa'];
But I think the error can only appear if you do not have any attribute stock quantity entered yet.
EDIT: Just checked and even there is no attribute stock entered, I do not get the error in my version. Maybe it's something else or you have something strange in your shop.

Meanwhile there is no QtPro version for Phoenix 1.0.8.4 available.
Qtpro 7.3.2 is flagged for Phoenix 1.0.7.15-1.0.8.0
QtPro 7.4.10 is flagged for Phoenix 1.0.8.6-1.0.8.20
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
lecarlb
Contributor
Posts: 316
Joined: Mon Oct 26, 2020 5:26 pm
Phoenix Version:
Has thanked: 48 times
Been thanked: 9 times

Re: Undefined Index Error when updating products in admin

Post by lecarlb »

raiwa wrote: Wed Nov 01, 2023 4:29 pm I just checked with QtPro last version and Phoenix 1.0.8.20. The error doesn't appear there. I have no old versions test installation and can't therefore debug for your version.
But looking at the qtPro admin hook it could be caused in line 94 or 98 depending on the version:

Code: Select all

        $summa = (int)(empty($list['summa'])) ? 0 : $list['summa'];
try to put the 0 (zero) in quotes:

Code: Select all

        $summa = (int)(empty($list['summa'])) ? '0' : $list['summa'];
But I think the error can only appear if you do not have any attribute stock quantity entered yet.
EDIT: Just checked and even there is no attribute stock entered, I do not get the error in my version. Maybe it's something else or you have something strange in your shop.

Meanwhile there is no QtPro version for Phoenix 1.0.8.4 available.
Qtpro 7.3.2 is flagged for Phoenix 1.0.7.15-1.0.8.0
QtPro 7.4.10 is flagged for Phoenix 1.0.8.6-1.0.8.20
Thanks for shedding some light on this @raiwa I didn't realize my version of Phoenix wasn't included. But here's error msgs from error log that occurs when stock levels aren't correct

Code: Select all

[Tue Oct 31 23:56:07.157447 2023] [php7:notice] [pid 15965] [client 71.28.224.173:57681] PHP Notice:  Trying to access array offset on value of type null in /usr/local/apache/subdomains/BTFraGranc3SbutL3r/www.xxxxxxx.com/htdocs/adminBTblR/includes/functions/general.php on line 152, referer: https://xxxxxxxxxx.com/adminBTblR/categories.php?pID=119935&action=new_product&stock_updated=true
[Tue Oct 31 23:56:07.157717 2023] [php7:notice] [pid 15965] [client 71.28.224.173:57681] PHP Notice:  Trying to access array offset on value of type null in /usr/local/apache/subdomains/BTFraGranc3SbutL3r/www.xxxxxxxxxxx.com/htdocs/adminBTblR/includes/functions/general.php on line 152, referer: https://xxxxxxxxxxxxx.com/adminBTblR/categories.php?pID=119935&action=new_product&stock_updated=true
[Tue Oct 31 23:56:34.315228 2023] [php7:warn] [pid 15214] [client 71.28.224.173:57696] PHP Warning:  Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini. in Unknown on line 0, referer: https://xxxxxxxxxxx.com/adminBTblR/categories.php?pID=119935&action=new_product&stock_updated=true
[Tue Oct 31 23:56:34.315489 2023] [php7:warn] [pid 15214] [client 71.28.224.173:57696] PHP Warning:  Unknown: Multipart body parts limit exceeded 1020. To increase the limit change max_multipart_body_parts in php.ini. in Unknown on line 0, referer: https://xxxxxxxxxxxxxx.com/adminBTblR/categories.php?pID=119935&action=new_product&stock_updated=true
[Tue Oct 31 23:56:34.500855 2023] [php7:notice] [pid 15214] [client 71.28.224.173:57696] PHP Notice:  Undefined index: products_quantity in /usr/local/apache/subdomains/BTFraGranc3SbutL3r/www.xxxxxxxxxxxx.com/htdocs/adminBTblR/categories.php on line 197, referer: https://xxxxxxxxxxxxx.com/adminBTblR/categories.php?pID=119935&action=new_product&stock_updated=true[\code]

Hopefully this could help someone in the future.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply