We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49756
    • 7 Posts
    I am using WordPress integration and after upgrading to Evo 1.0.15 I was getting the 'could not load DBAPI class' error.

    I tracked it down to a change in document.parser.class.inc.php here:

    /**
         * Loads an extension from the extenders folder.
         * You can load any extension creating a boot file:
         * MODX_MANAGER_PATH."includes/extenders/{$extname}.extenders.inc.php"
         * $extname - extension name in lowercase
         *
         * @return boolean
         */
    	function loadExtension($extname) {
    
            $extname = trim(str_replace(array('..','/','\\'),'',strtolower($extname)));
    
            $filename = MODX_MANAGER_PATH."includes/extenders/{$extname}.extenders.inc.php";
    
            return is_file($filename) ? include $filename : false;
        }	
    


    Note that $extname is followed by '.extenders.inc.php'

    I replaced this section of code with this code from an older version of ModX (1.0.10):

    // loads an extension from the extenders folder
        function loadExtension($extname) {
            global $database_type;
    
            switch ($extname) {
                // Database API
                case 'DBAPI' :
                    if (!include_once MODX_BASE_PATH . 'manager/includes/extenders/dbapi.' . $database_type . '.class.inc.php')
                        return false;
                    $this->db= new DBAPI;
                    return true;
                    break;
    
                    // Manager API
                case 'ManagerAPI' :
                    if (!include_once MODX_BASE_PATH . 'manager/includes/extenders/manager.api.class.inc.php')
                        return false;
                    $this->manager= new ManagerAPI;
                    return true;
                    break;
    
                default :
                    return false;
            }
        }
    


    Note the correct reference to '.class.inc.php' as the dbapi file is named dbapi.mysql.class.inc.php.

    After replacing this code, I'm no longer getting the error. I'm not sure if this is going to cause issues anywhere else in ModX yet (it appears its already breaking things in the manager).

    So my question is, why does the DBAPI load fine when called directly, but not through the .extenders config file? [ed. note: lt_dan last edited this post 9 years, 3 months ago.]
      • 49756
      • 7 Posts
      Update:

      I created a hybrid of the two versions and ended up with this:

      	function loadExtension($extname) {
      		
      		global $database_type;
      		
              switch ($extname) {
                  // Database API
                  case 'DBAPI' :
                      if (!include_once MODX_BASE_PATH . 'manager/includes/extenders/dbapi.' . $database_type . '.class.inc.php')
                          return false;
                      $this->db= new DBAPI;
                      return true;
                      break;
      		}
      			
      		$extname = trim(str_replace(array('..','/','\\'),'',strtolower($extname)));
      
              $filename = MODX_MANAGER_PATH."includes/extenders/{$extname}.extenders.inc.php";
      
              return is_file($filename) ? include $filename : false;
      		
      		
      		}


      It seems to be that only the dbapi class file is the only one having this issue.
        • 36416
        • 589 Posts
        Quote from: lt_dan at Jan 28, 2015, 11:48 PM
        It seems to be that only the dbapi class file is the only one having this issue.

        Changing the core instead of your add-ons means creating maintenance nightmare...
          • 49756
          • 7 Posts
          Quote from: danilocuculic at Jan 29, 2015, 07:24 AM
          Quote from: lt_dan at Jan 28, 2015, 11:48 PM
          It seems to be that only the dbapi class file is the only one having this issue.
          Changing the core instead of your add-ons means creating maintenance nightmare...

          Agreed, but I'm not running an add-on. I'm making a call to the document parser for database access. This appears to be a bug with 1.0.15.
            • 36416
            • 589 Posts
            Quote from: lt_dan at Jan 30, 2015, 07:25 AM
            Agreed, but I'm not running an add-on. I'm making a call to the document parser for database access. This appears to be a bug with 1.0.15.

            I was trying to (gently) say its you - not MODX... wink

            OK, found where your real problem is described - let's continue there.
              • 49756
              • 7 Posts
              Quote from: danilocuculic at Jan 30, 2015, 08:38 AM
              Quote from: lt_dan at Jan 30, 2015, 07:25 AM
              Agreed, but I'm not running an add-on. I'm making a call to the document parser for database access. This appears to be a bug with 1.0.15.

              I was trying to (gently) say its you - not MODX... wink

              OK, found where your real problem is described - let's continue there.

              I was hopig it wasn't modx and that the solution would be as you described in the other thread. Thanks!
                • 49756
                • 7 Posts
                Quote from: danilocuculic at Jan 30, 2015, 08:38 AM
                Quote from: lt_dan at Jan 30, 2015, 07:25 AM
                Agreed, but I'm not running an add-on. I'm making a call to the document parser for database access. This appears to be a bug with 1.0.15.

                I was trying to (gently) say its you - not MODX... wink

                OK, found where your real problem is described - let's continue there.

                I was hopig it wasn't modx and that the solution would be as you described in the other thread. Thanks!