diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2013-04-30 14:45:22 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2013-04-30 14:45:22 +0200 |
commit | 202484ebb48d5c8b2514af2ab519b37179ba3c12 (patch) | |
tree | ad42bdfe1d2a77c2959d97e133432e450d572ef3 /phpBB/includes | |
parent | 863d0c7687cc926dfda0ddd20b34e7942748fb2e (diff) | |
download | forums-202484ebb48d5c8b2514af2ab519b37179ba3c12.tar forums-202484ebb48d5c8b2514af2ab519b37179ba3c12.tar.gz forums-202484ebb48d5c8b2514af2ab519b37179ba3c12.tar.bz2 forums-202484ebb48d5c8b2514af2ab519b37179ba3c12.tar.xz forums-202484ebb48d5c8b2514af2ab519b37179ba3c12.zip |
[ticket/11495] Fix docs of add_item_to_nestedset() and take id as argument
PHPBB3-11495
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/tree/nestedset.php | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php index ae9805aa45..934eb933e0 100644 --- a/phpBB/includes/tree/nestedset.php +++ b/phpBB/includes/tree/nestedset.php @@ -111,16 +111,17 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface $item_data[$this->column_item_id] = (int) $this->db->sql_nextid(); - return array_merge($item_data, $this->add_item_to_nestedset($item_data)); + return array_merge($item_data, $this->add_item_to_nestedset($item_data[$this->column_item_id])); } /** * Add an item which already has a database row at the end of the tree * - * @param array $item The item to be added - * @return bool True if the item was added + * @param int $item_id The item to be added + * @return array Array with updated data, if the item was added successfully + * Empty array otherwise */ - protected function add_item_to_nestedset(array $item) + protected function add_item_to_nestedset($item_id) { $sql = 'SELECT MAX(' . $this->column_right_id . ') AS ' . $this->column_right_id . ' FROM ' . $this->table_name . ' @@ -138,10 +139,13 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface $sql = 'UPDATE ' . $this->table_name . ' SET ' . $this->db->sql_build_array('UPDATE', $update_item_data) . ' - WHERE ' . $this->column_item_id . ' = ' . (int) $item[$this->column_item_id]; + WHERE ' . $this->column_item_id . ' = ' . (int) $item_id . ' + AND ' . $this->column_parent_id . ' = 0 + AND ' . $this->column_left_id . ' = 0 + AND ' . $this->column_right_id . ' = 0'; $this->db->sql_query($sql); - return $update_item_data; + return ($this->db->sql_affectedrows() == 1) ? $update_item_data : array(); } /** |