Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2012
    Posts
    209
    Plugin Contributions
    1

    Idea or Suggestion data not showing after php version change

    [Note: remember to include site URL, ZC version, list of plugins, PHP version, etc ... read the Posting Tips shown above for information to include in your post here. And, remove this comment before actually posting!]

    Have some problem . Please help to sort it out .Thanks in advance.

    zencart 1.5.6a

    if php version is to 7.0

    this line $attr_value = $products[$i]['attributes_values'][$option]; say for example echoes to "diptimoy"

    if I chnage php to 7.2

    the same line echoes "d" only not "diptimoy "

    Where I am wrong

  2. #2
    Join Date
    Jul 2012
    Posts
    16,719
    Plugin Contributions
    17

    Default Re: data not showing after php version change

    Can we have more context?

    Line is in what file, doing what operation?
    Please consider the other aspects of the posting tips including plugins that are installed, how the upgrade/install was performed, etc...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Apr 2012
    Posts
    209
    Plugin Contributions
    1

    Default Re: data not showing after php version change

    Code looks like this


    foreach ($products[$i]['attributes'] as $option => $value) {

    $tmp_option = $option;
    $pos = strpos($option, '___');
    $measure_name = '';
    if ($pos !== false) {
    $measure_name = substr($option, 0, $pos) . ' - ';
    $option = substr($option, $pos+1);
    }

    $attributes_query = "select popt.products_options_name, poval.products_options_values_name,
    pa.options_values_price, pa.price_prefix
    from " . TABLE_PRODUCTS_OPTIONS . " popt,
    " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval,
    " . TABLE_PRODUCTS_ATTRIBUTES . " pa
    where pa.products_id = '" . (int)$products[$i]['id'] . "'
    and pa.options_id = '" . (int)$option . "'
    and pa.options_id = popt.products_options_id
    and pa.options_values_id = '" . (int)$value . "'
    and pa.options_values_id = poval.products_options_values_id
    and popt.language_id = '" . (int)$_SESSION['languages_id'] . "'
    and poval.language_id = '" . (int)$_SESSION['languages_id'] . "'";

    $attributes = $db->Execute($attributes_query);

    if($attributes->recordCount() == 0) {
    $attributes_query = "select products_options_name, products_options_type
    from " . TABLE_PRODUCTS_OPTIONS . "
    where products_options_id = '" . (int)$option . "'
    and language_id = '" . (int)$_SESSION['languages_id'] . "'";
    $attributes = $db->Execute($attributes_query);
    }

    //clr 030714 Determine if attribute is a text attribute and change products array if it is.
    if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID){
    $attr_value = $products[$i]['attributes_values'][$option]; // creating the php issue
    } else {
    $attr_value = $attributes->fields['products_options_values_name'];
    if($attr_value==''&& $tmp_option!='attributes_updated') {
    $attr_value_query = $db->Execute("select * from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id=" . $value);
    $attr_value = $attr_value_query->fields['products_options_values_name'];
    }
    }

    if(!empty($products[$i]['measurement_profile_id'])) {
    $custom_profile_relate = $db->Execute("select product_measurement_options_name, products_options_append from " . TABLE_PRODUCTS_MEASUREMENT_OPTIONS_RELATE . " pmor join " . TABLE_CUSTOMERS_MEASUREMENTS_OPTIONS_RELATE . " cmor on pmor.options_relate_id = cmor.options_relate_id where cmor.measurements_info_id = " . $products[$i]['measurement_profile_id'] . " and cmor.products_options_id = " . (int)$option);
    $relate_name = '';
    if($custom_profile_relate->fields['products_options_append'] == 1) {
    $relate_name = $custom_profile_relate->fields['product_measurement_options_name'];
    if($relate_name != '') $relate_name = '-' . $relate_name;
    }
    }

    $this->products[$index]['attributes'][$subindex] = array('option' => $attributes->fields['products_options_name'],
    'value' => $attr_value,
    'option_id' => $option,
    'value_id' => $value,
    'prefix' => $attributes->fields['price_prefix'],
    'price' => $attributes->fields['options_values_price']);

    $this->notify('NOTIFY_ORDER_CART_ADD_ATTRIBUTE_LIST', array('index'=>$index, 'subindex'=>$subindex, 'products'=>$products[$i], 'attributes'=>$attributes));
    $subindex++;
    }

  4. #4
    Join Date
    Jul 2012
    Posts
    16,719
    Plugin Contributions
    17

    Default Re: data not showing after php version change

    Couple of things.

    In future, recommend enclosing code in code tags: [CODE][/CODE]
    To make it easier to read and as necessary for testing to copy and paste the code.

    Second, would be to capture the condition of $products before the foreach loop. This should dump them to a debug file:
    Code:
    trigger_error('$products array before loop: ' . print_r($products, true), E_USER_WARNING);
    One thing that looks "unusual" is the adjustment of $option if your search string is found, because the remaining string returned will start with 2 underscores that then when cast to integer will result in 0 instead of the integer that is at the end of that triple underscore string. But without seeing the data of this home brew code, there's little way to identify why a single character is presented instead of the expected string. The issue likely is related back to the assignment that was made to create the data being parsed.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Apr 2012
    Posts
    209
    Plugin Contributions
    1

    Idea or Suggestion Re: data not showing after php version change

    Quote Originally Posted by mc12345678 View Post
    Couple of things.

    In future, recommend enclosing code in code tags: [CODE][/CODE]
    To make it easier to read and as necessary for testing to copy and paste the code.

    Second, would be to capture the condition of $products before the foreach loop. This should dump them to a debug file:
    Code:
    trigger_error('$products array before loop: ' . print_r($products, true), E_USER_WARNING);
    One thing that looks "unusual" is the adjustment of $option if your search string is found, because the remaining string returned will start with 2 underscores that then when cast to integer will result in 0 instead of the integer that is at the end of that triple underscore string. But without seeing the data of this home brew code, there's little way to identify why a single character is presented instead of the expected string. The issue likely is related back to the assignment that was made to create the data being parsed.

    Sorry . here is the code

    Code:
            trigger_error('$products array before loop: ' . print_r($products, true), E_USER_WARNING);
            foreach ($products[$i]['attributes'] as $option => $value) {
              /*
              //clr 030714 Determine if attribute is a text attribute and change products array if it is.
              if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID){
              $attr_value = $products[$i]['attributes_values'][$option];
              } else {
              $attr_value = $attributes->fields['products_options_values_name'];
              }
              */
    
    		  $tmp_option = $option;
    		  $pos = strpos($option, '___');
    		  $measure_name = '';
    		  if ($pos !== false) {
    			$measure_name = substr($option, 0, $pos) . ' - ';
    			$option = substr($option, $pos+1);
    		  }
              $attributes_query = "select popt.products_options_name, poval.products_options_values_name,
                                              pa.options_values_price, pa.price_prefix, popt.products_options_type
                                       from " . TABLE_PRODUCTS_OPTIONS . " popt,
                                            " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval,
                                            " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                       where pa.products_id = '" . (int)$products[$i]['id'] . "'
                                       and pa.options_id = '" . (int)$option . "'
                                       and pa.options_id = popt.products_options_id
                                       and pa.options_values_id = '" . (int)$value . "'
                                       and pa.options_values_id = poval.products_options_values_id
                                       and popt.language_id = '" . (int)$_SESSION['languages_id'] . "'
                                       and poval.language_id = '" . (int)$_SESSION['languages_id'] . "'";
    
      
              $attributes = $db->Execute($attributes_query);
    
    		  if($attributes->recordCount() == 0) {
    			$attributes_query = "select products_options_name, products_options_type
                                       from " . TABLE_PRODUCTS_OPTIONS . "
                                       where products_options_id = '" . (int)$option . "'
                                       and language_id = '" . (int)$_SESSION['languages_id'] . "'";
    			$attributes = $db->Execute($attributes_query);
    		  }
              //clr 030714 Determine if attribute is a text attribute and change products array if it is.
              if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID){
                  $attr_value = $products[$i]['attributes_values'][$tmp_option];
              } else {
                $attr_value = $attributes->fields['products_options_values_name'];
    			if($attr_value==''&& $tmp_option!='attributes_updated') {
    				$attr_value_query = $db->Execute("select * from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id=" . $value);
    				$attr_value = $attr_value_query->fields['products_options_values_name'];
    			}
              }
    
    		  if(!empty($products[$i]['measurement_profile_id'])) {
    				$custom_profile_relate = $db->Execute("select product_measurement_options_name, products_options_append from " . TABLE_PRODUCTS_MEASUREMENT_OPTIONS_RELATE . " pmor join " . TABLE_CUSTOMERS_MEASUREMENTS_OPTIONS_RELATE . " cmor on pmor.options_relate_id = cmor.options_relate_id where cmor.measurements_info_id = " . $products[$i]['measurement_profile_id'] . " and cmor.products_options_id = " . (int)$option);
    				$relate_name = '';
    				if($custom_profile_relate->fields['products_options_append'] == 1) {
    					$relate_name = $custom_profile_relate->fields['product_measurement_options_name'];
    					if($relate_name != '') $relate_name = '-' . $relate_name;
    				}
    		  }
    		  
              $this->products[$index]['attributes'][$subindex] = array('option' => $measure_name . $attributes->fields['products_options_name'] . $relate_name,
                                                                       'value' => $attr_value,
                                                                       'option_id' => $tmp_option,
                                                                       'value_id' => $value,
                                                                       'prefix' => $attributes->fields['price_prefix'],
                                                                       'price' => $attributes->fields['options_values_price']);
    
              $this->notify('NOTIFY_ORDER_CART_ADD_ATTRIBUTE_LIST', array('index'=>$index, 'subindex'=>$subindex, 'products'=>$products[$i], 'attributes'=>$attributes));
              $subindex++;
            }
          }

    IF the version of php is 7.0 and below no dump file and value shows fine.

    if php version 7.1 and 7.2 then a log file is generated which is as follows

    [21-Jan-2019 03:40:26 UTC] Request URI: /index.php?main_page=checkout_confirmation, IP address: 45.249.82.116
    #1 trigger_error() called at [/includes/classes/order.php:553]
    #2 order->cart() called at [/includes/classes/order.php:34]
    #3 order->order() called at [/includes/modules/pages/checkout_confirmation/header_php.php:63]
    #4 require(/includes/modules/pages/checkout_confirmation/header_php.php) called at [/index.php:36]
    --> PHP Warning: $products array before loop: Array
    (
    [0] => Array
    (
    [id] => 3718:cd24a9cd3ff7e2cd43358b5c014ec7ee
    [category] => 1
    [name] => Archer Blue Light Wash Jeans
    [model] => R Naps - Hb
    [image] => jeans/archerblueltwashjeans.jpg
    [price] => 59
    [quantity] => 1
    [weight] => 2
    [final_price] => 59
    [onetime_charges] => 0
    [tax_class_id] => 0
    [measurement_price] => 0
    [measurement_arributes] => Array
    (
    )

    [attributes] => Array
    (
    [attributes_updated] => 1
    [20] => 20
    [290] => 7220
    [84] => 362
    [283] => 6530
    [1] => 0
    [2] => 7
    [3] => 3236
    [8] => 0
    [5] => 0
    [6] => 0
    [23] => 0
    [42] => 0
    [7] => 0
    [87] => 0
    [24] => 0
    )

    [attributes_values] => d 4424 91 1 1
    [products_priced_by_attribute] => 0
    [product_is_free] => 0
    [products_discount_type] => 0
    [products_discount_type_from] => 0
    [products_measurement_type] => 1
    [measurement_profile_id] => 79367
    [products_options_values_measurement] => 1
    [products_is_remake] => 0
    [is_valid_remake] => 1
    )

    )
    in /includes/classes/order.php on line 553.

    The attributes which shows like
    [attributes_values] => d 4424 91 1 1

    when in 7.0 the value is
    [attributes_values] => Array
    (
    [1] => diptimoy
    [8] => 46
    [5] => 40
    [6] => 43
    [23] => 9.5
    [42] => 15.5
    [7] => 27.5
    [87] => 17.5
    [24] => 16
    )

    Thanks in advance.

  6. #6
    Join Date
    Jul 2012
    Posts
    16,719
    Plugin Contributions
    17

    Default Re: data not showing after php version change

    A little confused still. My confusion stems from what I understand of the statement that if php 7.0 or below is chosen that there is no log generated when the code gets to the newly added trigger_error statement... but in php 7.1 and 7.2 (as available) the newly added trigger_error statement actually works.

    From what it looks like, the attributes_values key looks like it was assigned a value as a string and then as each "key" was assigned to the string, only the first character of that value was put into the position.

    Can see for example that the values of 9 and 1 are next to each other. Likely at positions 23 and 24 of a long string of text...

    Before the first use/assignment to $products[$i]['attributes_values'] it should be identified as an array so that addition of the next value to it is captured as an arrayed item.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Jul 2012
    Posts
    16,719
    Plugin Contributions
    17

    Default Re: data not showing after php version change

    Where again is this code? I mean, sure there's the error log that seems to point at a few places, but trying to figure out if there is a need to go testing several product and settings to see if default code in that area works as expected or not.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  8. #8
    Join Date
    Apr 2012
    Posts
    209
    Plugin Contributions
    1

    Idea or Suggestion Re: data not showing after php version change

    Quote Originally Posted by mc12345678 View Post
    Where again is this code? I mean, sure there's the error log that seems to point at a few places, but trying to figure out if there is a need to go testing several product and settings to see if default code in that area works as expected or not.

    You mean this should solve the problem

    $products[$i]['attributes_values'] =array();


    Right?

  9. #9
    Join Date
    Apr 2012
    Posts
    209
    Plugin Contributions
    1

    Idea or Suggestion Re: data not showing after php version change

    Quote Originally Posted by diptimoy View Post
    You mean this should solve the problem

    $products[$i]['attributes_values'] =array();


    Right?
    Thanks , the solution worked.

  10. #10
    Join Date
    Jul 2012
    Posts
    16,719
    Plugin Contributions
    17

    Default Re: data not showing after php version change

    Quote Originally Posted by diptimoy View Post
    Thanks , the solution worked.
    Good. Again though is this an issue with a vanilla Zen Cart installation (problem/issue affects everyone) or is the code from above something that was self written (problem affects only those that have incorporated some extra code)?

    Yes, I could go searching for the presence/absence of all of those things and could independently run tests, but it's a lot more helpful for those that find the issue to identify the bounds of what they've found.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. v138a Orders Not Showing after PHP upgrade
    By denise006 in forum Managing Customers and Orders
    Replies: 8
    Last Post: 3 Apr 2018, 08:31 PM
  2. Replies: 1
    Last Post: 24 Mar 2015, 11:31 PM
  3. Replies: 5
    Last Post: 3 Jun 2014, 05:42 PM
  4. v1371 prices are not showing after php update
    By kory007 in forum General Questions
    Replies: 3
    Last Post: 10 Sep 2012, 09:31 PM
  5. Paypal IPN not working after upgrading PHP version
    By mattf in forum Managing Customers and Orders
    Replies: 2
    Last Post: 4 Nov 2010, 01:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR