diff --git a/installation/sql/postgresql/joomla.sql b/installation/sql/postgresql/joomla.sql index 361730d261f8a..26aecf73a3430 100644 --- a/installation/sql/postgresql/joomla.sql +++ b/installation/sql/postgresql/joomla.sql @@ -1842,7 +1842,7 @@ CREATE TABLE "#__modules" ( "module" character varying(50) DEFAULT NULL, "access" bigint DEFAULT 0 NOT NULL, "showtitle" smallint DEFAULT 1 NOT NULL, - "params" text NOT NULL, + "params" text DEFAULT '' NOT NULL, "client_id" smallint DEFAULT 0 NOT NULL, "language" character varying(7) NOT NULL, PRIMARY KEY ("id") diff --git a/libraries/joomla/database/database/postgresql.php b/libraries/joomla/database/database/postgresql.php index bb516dcd31f1c..c79f7ab04dc2e 100644 --- a/libraries/joomla/database/database/postgresql.php +++ b/libraries/joomla/database/database/postgresql.php @@ -447,6 +447,8 @@ public function insertid() public function insertObject($table, &$object, $key = null) { // Initialise variables. + $columns = $this->getTableColumns($table); + $fields = array(); $values = array(); @@ -467,7 +469,7 @@ public function insertObject($table, &$object, $key = null) // Prepare and sanitize the fields and values for the database query. $fields[] = $this->quoteName($k); - $values[] = is_numeric($v) ? $v : $this->quote($v); + $values[] = $this->sqlValue($columns, $k, $v); } // Create the base insert statement. @@ -1043,6 +1045,62 @@ public function replacePrefix($sql, $prefix = '#__') return $replacedQuery; } + /** + * This function return a field value as a prepared string to be used in a SQL statement. + * + * @param string $columns The array of field columns returned by JDatabasePostgreSQL::getTableColumns. + * @param string $field_name Name of field that will receive the converted SQL value + * @param string $field_value Php variable value to be converted to SQL. + * + * @return string The quoted string. + * + * @since 11.3 + */ + protected function sqlValue(&$columns, $field_name, $field_value) + { + switch ($columns[$field_name]) + { + case 'boolean': + if ($field_value == 't') + { + $val = 'TRUE'; + } + elseif ($field_value == 'f') + { + $val = 'FALSE'; + } + elseif (is_bool($field_value)) + { + $val = $field_value ? 'TRUE' : 'FALSE'; + } + else + { + $val = 'NULL'; + } + break; + case 'bigint': + case 'bigserial': + case 'integer': + case 'money': + case 'real': + case 'smallint': + case 'serial': + case 'numeric': + $val = strlen($field_value) == 0 ? 'NULL' : strval($field_value); + break; + case 'date': + case 'timestamp without time zone': + if (empty($field_value)) + { + $field_value = $this->getNullDate(); + } + default: + $val = $this->quote($field_value); + } + + return $val; + } + /** * Method to commit a transaction. * @@ -1154,6 +1212,8 @@ public function unlockTables() public function updateObject($table, &$object, $key, $nulls = false) { // Initialise variables. + $columns = $this->getTableColumns($table); + $fields = array(); $where = ''; @@ -1174,7 +1234,8 @@ public function updateObject($table, &$object, $key, $nulls = false) // Set the primary key to the WHERE clause instead of a field to update. if ($k == $key) { - $where = $this->quoteName($k) . '=' . (is_numeric($v) ? $v : $this->quote($v)); + $key_val = $this->sqlValue($columns, $k, $v); + $where = $this->quoteName($k) . '=' . $key_val; continue; } @@ -1192,10 +1253,9 @@ public function updateObject($table, &$object, $key, $nulls = false) continue; } } - // The field is not null so we prep it for update. else { - $val = (is_numeric($v) ? $v : $this->quote($v)); + $val = $this->sqlValue($columns, $k, $v); } // Add the field to be updated. diff --git a/libraries/joomla/database/table/menu.php b/libraries/joomla/database/table/menu.php index a0c78a77b961d..304caa909887c 100644 --- a/libraries/joomla/database/table/menu.php +++ b/libraries/joomla/database/table/menu.php @@ -145,7 +145,10 @@ public function store($updateNulls = false) $db = JFactory::getDBO(); // Verify that the alias is unique $table = JTable::getInstance('Menu', 'JTable'); - if ($table->load(array('alias' => $this->alias, 'parent_id' => $this->parent_id, 'client_id' => $this->client_id, 'language' => $this->language)) + + $clientId = strlen($this->client_id) == 0 ? 0 : $this->client_id; + + if ($table->load(array('alias' => $this->alias, 'parent_id' => $this->parent_id, 'client_id' => $clientId, 'language' => $this->language)) && ($table->id != $this->id || $this->id == 0)) { if ($this->menutype == $table->menutype) diff --git a/libraries/joomla/installer/adapters/component.php b/libraries/joomla/installer/adapters/component.php index 88c57419ee636..7d9f17121d010 100644 --- a/libraries/joomla/installer/adapters/component.php +++ b/libraries/joomla/installer/adapters/component.php @@ -541,7 +541,7 @@ public function install() return false; } - $eid = $row->$key; + $eid = $row->extension_id; // Clobber any possible pending updates $update = JTable::getInstance('update'); diff --git a/libraries/joomla/installer/adapters/language.php b/libraries/joomla/installer/adapters/language.php index adcd514c78fbf..34140ba26b786 100644 --- a/libraries/joomla/installer/adapters/language.php +++ b/libraries/joomla/installer/adapters/language.php @@ -283,7 +283,7 @@ protected function _install($cname, $basePath, $clientId, &$element) // Clobber any possible pending updates $update = JTable::getInstance('update'); - $uid = $update->find(array('element' => $this->get('tag'), 'type' => 'language', 'client_id' => '', 'folder' => '')); + $uid = $update->find(array('element' => $this->get('tag'), 'type' => 'language', 'client_id' => $clientId, 'folder' => '')); if ($uid) { $update->delete($uid);