From: Mikael Nordfeldth Date: Mon, 10 Jul 2017 11:25:04 +0000 (+0200) Subject: Update PEAR DB_DataObject to 1.11.5 X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a223273544b4056dadb6a84f8dd029d1e54c85d4;p=quix0rs-gnu-social.git Update PEAR DB_DataObject to 1.11.5 Source: https://pear.php.net/package/DB_DataObject Release date: 2015-11-10 --- diff --git a/extlib/DB/DataObject.php b/extlib/DB/DataObject.php index 1a7b34665d..e26cf8efa0 100644 --- a/extlib/DB/DataObject.php +++ b/extlib/DB/DataObject.php @@ -15,7 +15,7 @@ * @author Alan Knowles * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id: DataObject.php 320069 2011-11-28 04:34:08Z alan_k $ + * @version CVS: $Id: DataObject.php 336751 2015-05-12 04:39:50Z alan_k $ * @link http://pear.php.net/package/DB_DataObject */ @@ -410,7 +410,7 @@ class DB_DataObject extends DB_DataObject_Overload if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) { $this->debug($n, "find",1); } - if (!$this->__table) { + if (!strlen($this->tableName())) { // xdebug can backtrace this! trigger_error("NO \$__table SPECIFIED in class definition",E_USER_ERROR); } @@ -2073,6 +2073,9 @@ class DB_DataObject extends DB_DataObject_Overload if (count($args)) { $this->__table = $args[0]; } + if (empty($this->__table)) { + return ''; + } if (!empty($_DB_DATAOBJECT['CONFIG']['portability']) && $_DB_DATAOBJECT['CONFIG']['portability'] & 1) { return strtolower($this->__table); } @@ -2421,7 +2424,7 @@ class DB_DataObject extends DB_DataObject_Overload $dsn = isset($this->_database_dsn) ? $this->_database_dsn : null; if (!$dsn) { - if (!$this->_database && !empty($this->__table)) { + if (!$this->_database && !strlen($this->tableName())) { $this->_database = isset($options["table_{$this->tableName()}"]) ? $options["table_{$this->tableName()}"] : null; } if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) { @@ -3522,7 +3525,7 @@ class DB_DataObject extends DB_DataObject_Overload if ($joinCol !== false) { $this->raiseError( "joinAdd: You cannot target a join column in the " . - "'link from' table ({$obj->__table}). " . + "'link from' table ({$obj->tableName()}). " . "Either remove the fourth argument to joinAdd() ". "({$joinCol}), or alter your links.ini file.", DB_DATAOBJECT_ERROR_NODATA); @@ -3605,7 +3608,7 @@ class DB_DataObject extends DB_DataObject_Overload if (!$items) { $this->raiseError( - "joinAdd: No table definition for {$obj->__table}", + "joinAdd: No table definition for {$obj->tableName()}", DB_DATAOBJECT_ERROR_INVALIDCONFIG); return false; } @@ -3800,6 +3803,7 @@ class DB_DataObject extends DB_DataObject_Overload */ function autoJoin($cfg = array()) { + global $_DB_DATAOBJECT; //var_Dump($cfg);exit; $pre_links = $this->links(); if (!empty($cfg['links'])) { @@ -3807,7 +3811,8 @@ class DB_DataObject extends DB_DataObject_Overload } $map = $this->links( ); - + $this->databaseStructure(); + $dbstructure = $_DB_DATAOBJECT['INI'][$this->_database]; //print_r($map); $tabdef = $this->table(); @@ -3874,6 +3879,12 @@ class DB_DataObject extends DB_DataObject_Overload list($tab,$col) = explode(':', $info); // what about multiple joins on the same table!!! + + // if links point to a table that does not exist - ignore. + if (!isset($dbstructure[$tab])) { + continue; + } + $xx = DB_DataObject::factory($tab); if (!is_object($xx) || !is_a($xx, 'DB_DataObject')) { continue; diff --git a/extlib/DB/DataObject/Generator.php b/extlib/DB/DataObject/Generator.php index a712e6d9eb..c7f87161c3 100644 --- a/extlib/DB/DataObject/Generator.php +++ b/extlib/DB/DataObject/Generator.php @@ -15,7 +15,7 @@ * @author Alan Knowles * @copyright 1997-2006 The PHP Group * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id: Generator.php 315531 2011-08-26 02:21:29Z alan_k $ + * @version CVS: $Id: Generator.php 336719 2015-05-05 10:37:33Z alan_k $ * @link http://pear.php.net/package/DB_DataObject */ @@ -406,7 +406,7 @@ class DB_DataObject_Generator extends DB_DataObject * Currenly only works with mysql / mysqli / posgtreas * to use, you must set option: generate_links=true * - * @author Pascal Schöni + * @author Pascal Sch�ni */ function _createForiegnKeys() @@ -507,7 +507,7 @@ class DB_DataObject_Generator extends DB_DataObject * Currenly only works with mysql / mysqli * to use, you must set option: generate_links=true * - * @author Pascal Schöni + * @author Pascal Sch�ni */ function generateForeignKeys() { @@ -895,7 +895,7 @@ class DB_DataObject_Generator extends DB_DataObject $options = &PEAR::getStaticProperty('DB_DataObject','options'); $this->_extends = empty($options['extends']) ? $this->_extends : $options['extends']; - $this->_extendsFile = empty($options['extends_location']) ? $this->_extendsFile : $options['extends_location']; + $this->_extendsFile = !isset($options['extends_location']) ? $this->_extendsFile : $options['extends_location']; foreach($this->tables as $this->table) { @@ -976,8 +976,12 @@ class DB_DataObject_Generator extends DB_DataObject $head .= $this->derivedHookExtendsDocBlock(); - // requires - $head .= "require_once '{$this->_extendsFile}';\n\n"; + // requires - if you set extends_location = (blank) then no require line will be set + // this can be used if you have an autoloader + + if (!empty($this->_extendsFile)) { + $head .= "require_once '{$this->_extendsFile}';\n\n"; + } // add dummy class header in... // class $head .= $this->derivedHookClassDocBlock(); @@ -1039,10 +1043,11 @@ class DB_DataObject_Generator extends DB_DataObject continue; } - $p = str_repeat(' ',max(2, (30 - strlen($t->name)))); + $pad = str_repeat(' ',max(2, (30 - strlen($t->name)))); $length = empty($t->len) ? '' : '('.$t->len.')'; - $body .=" {$var} \${$t->name}; {$p}// {$t->type}$length {$t->flags}\n"; + $flags = strlen($t->flags) ? (' '. trim($t->flags)) : ''; + $body .=" {$var} \${$t->name}; {$pad}// {$t->type}{$length}{$flags}\n"; // can not do set as PEAR::DB table info doesnt support it. //if (substr($t->Type,0,3) == "set") @@ -1283,7 +1288,7 @@ class DB_DataObject_Generator extends DB_DataObject $class_prefix = empty($options['class_prefix']) ? '' : $options['class_prefix']; $this->_extends = empty($options['extends']) ? $this->_extends : $options['extends']; - $this->_extendsFile = empty($options['extends_location']) ? $this->_extendsFile : $options['extends_location']; + $this->_extendsFile = !isset($options['extends_location']) ? $this->_extendsFile : $options['extends_location']; $classname = $this->classname = $this->getClassNameFromTableName($this->table);