From ccc7e8139c827356b9c2f3beb71d8d69e499f647 Mon Sep 17 00:00:00 2001 From: real_nowhereman Date: Wed, 24 Sep 2008 10:08:12 +0000 Subject: [PATCH] indices correctly updated when *removing* categories --- fp-includes/core/core.entry.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/fp-includes/core/core.entry.php b/fp-includes/core/core.entry.php index 7dc5ff7..bc05b0f 100755 --- a/fp-includes/core/core.entry.php +++ b/fp-includes/core/core.entry.php @@ -100,7 +100,7 @@ return $this->indices[$cat]; } - function add($id, $entry) { + function add($id, $entry, $del = array()) { $key =& entry_idtokey($id); $val = $entry['SUBJECT']; @@ -115,6 +115,13 @@ } } + if ($del) { + foreach($del as $cat) { + $this_index =& $this->get_index($cat); + $this_index->delitem($key); + } + } + return true; } @@ -620,8 +627,14 @@ $entry['CONTENT'] = apply_filters('content_save_pre', $entry['CONTENT']); $entry['SUBJECT'] = apply_filters('title_save_pre', $entry['SUBJECT']); + + $del = array(); + if ($arr = entry_parse($id)) { + if (isset($entry['CATEGORIES']) && is_array($entry['CATEGORIES'])) + $del = array_diff($arr['categories'], $entry['CATEGORIES']); + } - $ok = ($update_index) ? $obj->add($id, $entry) : true; + $ok = ($update_index) ? $obj->add($id, $entry, $del) : true; if ($ok) {