Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2009
    Location
    Longs, SC
    Posts
    626
    Plugin Contributions
    2

    Default Cannot redeclare class queryFactory in /includes/classes/db/mysql/query_factory.php

    I'm working on a problem and could use some guidance, Receiving the following error: Cannot redeclare class queryFactory in /includes/classes/db/mysql/query_factory.php on line 424. I've searched the forum and have been unable to find a resolution. This is a 1.3.9d install with numerous mods installed (I'm not aware of all of them as numerous people have/do support this site). Some of the more notable are Wordpress on Zencart, Simple SEO URL, Back in stock notifications, advanced shipper, CAPTCHA, sitemap xml, and others. At first this seemed to be related to the CAPTCHA mod which I turned off in the admin. That slowed the number of errors down but didn't stop them. I've used the developers toolkit to make sure the class wasn't defined multiple times. It wasn't . Here's the output from that:
    Code:
         Searching 1158 files ... for: queryFactory
     
    .../includes/classes/class.phpbb.php
    
    Line #30 : $this->db_phpbb = new queryFactory();
     
    .../includes/classes/db/mysql/query_factory.php
    
    Line #15 : * Queryfactory - A simple database abstraction layer
    
    Line #18 : class queryFactory extends base {
    
    Line #21 : function queryFactory() {
    
    Line #118 : $obj = new queryFactoryResult;
    
    Line #136 : $obj = new queryFactoryResult;
    
    Line #186 : $obj = new queryFactoryResult;
    
    Line #228 : $obj = new queryFactoryResult;
    
    Line #298 : $obj[strtoupper(@mysql_field_name($res, $i))] = new queryFactoryMeta($i, $res);
    
    Line #425 : class queryFactoryResult {
    
    Line #427 : function queryFactoryResult() {
    
    Line #491 : class queryFactoryMeta {
    
    Line #493 : function queryFactoryMeta($zp_field, $zp_res) {
     
    .../includes/classes/yclass.php
    
    Line #32 : if($this->is_obj($db_result,'queryFactoryResult')){
    
    Line #52 : if($this->is_obj($db_result,'queryFactoryResult')){
     
    .../includes/functions/functions_general.php
    
    Line #662 : } elseif( is_a( $value, 'queryFactoryResult' ) ) {
     
    .../includes/functions/sessions.php
    
    Line #58 : $db = new queryFactory();
     
    .../includes/init_includes/init_database.php
    
    Line #18 : $db = new queryFactory();
     
    .../admin/includes/functions/general.php
    
    Line #385 : } elseif( is_a( $value, 'queryFactoryResult' ) ) {
     
    .../admin/includes/init_includes/init_database.php
    
    Line #16 : // Load queryFactory db classes
    
    Line #18 : $db = new queryFactory();
     
    .../admin/thubservice.php
    
    Line #64 : $db = new queryFactory();
     
    Match Lines found: 22
    I replaced includes/classes/db/mysql/query_factory.php with the original file from 1.3.9d to make sure it wasn't corrupted. That had no effect. The interesting thing is that the error always refers to line 424 as containing the error. In both the original file and the one that existed on the server line 424 does not contain a class definition.
    PHP Code:
    class queryFactoryResult {

      function 
    queryFactoryResult() {
        
    $this->is_cached false;
      }

      function 
    MoveNext() {
        global 
    $zc_cache;
        
    $this->cursor++;
        if (
    $this->is_cached) {
    //THE FOLLOWING LINE IS 424 
         
    if ($this->cursor >= sizeof($this->result)) {
            
    $this->EOF true;
          } else {
            while(list(
    $key$value) = each($this->result[$this->cursor])) {
              
    $this->fields[$key] = $value;
            }
          }
        } else {
          
    $zp_result_array = @mysql_fetch_array($this->resource);
          if (!
    $zp_result_array) {
            
    $this->EOF true;
          } else {
            while (list(
    $key$value) = each($zp_result_array)) {
              if (!
    preg_match('/^[0-9]/'$key)) {
                
    $this->fields[$key] = $value;
              }
            }
          }
        }
      } 
    Any suggestions on how to proceed with debugging this?

  2. #2
    Join Date
    Aug 2009
    Location
    Longs, SC
    Posts
    626
    Plugin Contributions
    2

    Default Re: Cannot redeclare class queryFactory in /includes/classes/db/mysql/query_factory.p

    Just to give an update. My clients hosting company upgraded her server to php 5.3.16. This is apparently what broke zencart. They fixed the problem by adding a line of code to includes/classes/db/mysql/queryFactory.php:
    PHP Code:
    /**
     * Queryfactory - A simple database abstraction layer
     *
     */
    //Line added here 

    if (!class_exists('queryFactory')) { 

    class 
    queryFactory extends base {
      var 
    $link$count_queries$total_query_time;

      function 
    queryFactory() {
        
    $this->count_queries 0;
        
    $this->total_query_time 0;
      } 
    This corrected the problem but I'm concerned that this won't be the only problem that is about to surface as a result of the php version change. Any idea why going to 5.3.16 would break this class in 1.3.9d and if you are aware of any other things that might fail as a result of this upgrade?

  3. #3
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Cannot redeclare class queryFactory in /includes/classes/db/mysql/query_factory.p

    Makes no sense. That's a weak bandage. Sure, it will work, but it doesn't address the root problem.

    There shouldn't be any "cannot redeclare" problem using v1.3.9 on PHP 5.3.16.

    It's far more likely that there's some configuration or customization on the site that is causing the code to re-process the scripts that load that file. So, while you were correct in searching for duplicates of that specific file, you need to carry that logic further by looking for ALL "backup copies" of ANY file, including the auto_loaders folder and init_system, and, well, everything.
    This is where I'd start: http://www.zen-cart.com/wiki/index.p...Obscure_Issues

    If you don't dig further and find the ACTUAL root problem, then you are likely going to encounter further problems at the least convenient time. Or future customizations may not work because they're triggered in the wrong place because of duplicate bootstraps that are running. And that's not to mention the wasted CPU cycles that will slow down the site needlessly if there's actually duplicate code running on every click.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Aug 2009
    Location
    Longs, SC
    Posts
    626
    Plugin Contributions
    2

    Default Re: Cannot redeclare class queryFactory in /includes/classes/db/mysql/query_factory.p

    Thanks as always Dr B. I located a backup file in includes/functions. There was a function_general.php.bak there. I deleted that and I'll back out the hosting companies band-aid fix to test iit.

 

 

Similar Threads

  1. Replies: 2
    Last Post: 17 Oct 2014, 04:46 AM
  2. Replies: 3
    Last Post: 3 Aug 2009, 06:13 AM
  3. Replies: 0
    Last Post: 7 Jul 2009, 12:11 PM
  4. Fatal error: Cannot redeclare class table in ...store/includes/
    By Kansai_mike in forum Built-in Shipping and Payment Modules
    Replies: 4
    Last Post: 15 Dec 2006, 06:35 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