Skip to content

Commit

Permalink
Fix some methods in JTableNested when alias field does not exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
elinw committed Nov 4, 2012
1 parent 269f260 commit 50c3e3d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions libraries/joomla/table/nested.php
Expand Up @@ -430,6 +430,7 @@ public function moveByReference($referenceId, $position = 'after', $pk = null)
/*
* Create space in the nested sets at the new location for the moved sub-tree.
*/

// Shift left values.
$query = $this->_db->getQuery(true);
$query->update($this->_tbl)
Expand Down Expand Up @@ -473,11 +474,14 @@ public function moveByReference($referenceId, $position = 'after', $pk = null)
$query->update($this->_tbl);

// Update the title and alias fields if they exist for the table.
$fields = $this->getFields();

if (property_exists($this, 'title') && $this->title !== null)
{
$query->set('title = ' . $this->_db->Quote($this->title));
}
if (property_exists($this, 'alias') && $this->alias !== null)

if (array_key_exists('alias', $fields) && $this->alias !== null)
{
$query->set('alias = ' . $this->_db->Quote($this->alias));
}
Expand Down Expand Up @@ -1186,7 +1190,9 @@ public function getRootId()
return $result[0];
}

if (property_exists($this, 'alias'))
$fields = $this->getFields();

if (array_key_exists('alias', $fields))
{
// Test for a unique record alias = root
$query = $this->_db->getQuery(true);
Expand Down Expand Up @@ -1311,8 +1317,10 @@ public function rebuild($parentId = null, $leftId = 0, $level = 0, $path = '')
*/
public function rebuildPath($pk = null)
{
$fields = $this->getFields();

// If there is no alias or path field, just return true.
if (!property_exists($this, 'alias') || !property_exists($this, 'path'))
if (!array_key_exists('alias', $fields) || !array_key_exists('path', $fields))
{
return true;
}
Expand Down

0 comments on commit 50c3e3d

Please sign in to comment.