From 3e63e05907456be92914450a8e9a85d5eb264b55 Mon Sep 17 00:00:00 2001 From: Johan Janssens Date: Tue, 7 Jul 2015 20:58:55 +0200 Subject: [PATCH] #203 - Check if 'alias' and 'path' fields exist. If not do not try to query for them or set them. --- lib/libraries/joomla/table/nested.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/libraries/joomla/table/nested.php b/lib/libraries/joomla/table/nested.php index 6d178fd248..d27a92db8e 100644 --- a/lib/libraries/joomla/table/nested.php +++ b/lib/libraries/joomla/table/nested.php @@ -1308,8 +1308,14 @@ public function rebuild($parentId = null, $leftId = 0, $level = 0, $path = '') // Build the structure of the recursive query. if (!isset($this->_cache['rebuild.sql'])) { - $query->clear() - ->select($this->_tbl_key . ', alias') + $select = $this->_tbl_key; + if (array_key_exists('alias', $this->getFields())) + { + $select .= ', alias'; + } + + $query->clear() + ->select($select) ->from($this->_tbl) ->where('parent_id = %d'); @@ -1358,9 +1364,14 @@ public function rebuild($parentId = null, $leftId = 0, $level = 0, $path = '') ->update($this->_tbl) ->set('lft = ' . (int) $leftId) ->set('rgt = ' . (int) $rightId) - ->set('level = ' . (int) $level) - ->set('path = ' . $this->_db->quote($path)) - ->where($this->_tbl_key . ' = ' . (int) $parentId); + ->set('level = ' . (int) $level); + + if (array_key_exists('path', $this->getFields())) + { + $query->set('path = ' . $this->_db->quote($path)); + } + + $query->where($this->_tbl_key . ' = ' . (int) $parentId); $this->_db->setQuery($query)->execute(); // Return the right value of this node + 1.