Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2007
    Posts
    241
    Plugin Contributions
    6

    Default query_factory.php

    Hi, stumbled across this from a warning in the logs file, just seems the logic is incorrect as code will throw the warning before the if statement has acted?

    Line 623 in includes/classes/db/query_factory.php


    Code:
    } else {
          $zp_result_array = @mysqli_fetch_assoc($this->resource);
          $this->fields = array_replace($this->fields, $zp_result_array);
          if (!$zp_result_array) {
            $this->EOF = true;
            unset($this->fields);
          }
    should it not be

    Code:
    } else {
          $zp_result_array = @mysqli_fetch_assoc($this->resource);
          if (!$zp_result_array) {
            $this->EOF = true;
            unset($this->fields);
          }else{
        $this->fields = array_replace($this->fields, $zp_result_array);
    }

  2. #2
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,622
    Plugin Contributions
    123

    Default Re: query_factory.php

    What caused this log to be created?
    What is your PHP version?
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  3. #3
    Join Date
    Mar 2007
    Posts
    241
    Plugin Contributions
    6

    Default Re: query_factory.php

    php 7.4

    query from the tpl_specials sidebox
    $random_specials_product->MoveNext();

    --> PHP Warning: array_replace(): Expected parameter 2 to be an array, null given


    Changing to the suggest logic above removed warning.

  4. #4
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,668
    Plugin Contributions
    11

    Default Re: query_factory.php

    Quote Originally Posted by Calljj View Post
    Hi, stumbled across this from a warning in the logs file, just seems the logic is incorrect as code will throw the warning before the if statement has acted?

    Line 623 in includes/classes/db/query_factory.php


    Code:
    } else {
          $zp_result_array = @mysqli_fetch_assoc($this->resource);
          $this->fields = array_replace($this->fields, $zp_result_array);
          if (!$zp_result_array) {
            $this->EOF = true;
            unset($this->fields);
          }
    should it not be

    Code:
    } else {
          $zp_result_array = @mysqli_fetch_assoc($this->resource);
          if (!$zp_result_array) {
            $this->EOF = true;
            unset($this->fields);
          }else{
        $this->fields = array_replace($this->fields, $zp_result_array);
    }
    i am not able to reproduce said error, despite spending some time trying....

    that said, this code change makes sense to me. the function, mysqli_fetch_assoc, https://www.php.net/manual/en/mysqli...etch-assoc.php, can return false or null. so doing that check prior to the array_replace seems reasonable and in fact correct.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

 

 

Similar Threads

  1. Replies: 12
    Last Post: 17 Mar 2014, 11:10 PM
  2. [duplicate] query_factory.php
    By Kodam in forum Bug Reports
    Replies: 8
    Last Post: 22 May 2007, 06:42 AM

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