[dev] Category_sql bug / patch
Hans Lellelid
hans at appliedsec.com
Tue Jan 14 11:51:52 PST 2003
Also, -- more on Category framework. Shouldn't the _nameMap[$id] always
map to the fullname of the category? Currently when a new category is
created only the deepest element is stored in the _nameMap[] array. (on
subsequent reloads the full cat name is stored in the array). Fixing
this means that the line I sent the patch for previously (i.e. last line
of Category_sql::addCategory()), should probably read:
return parent::_addCategory($fullname, $id, $pid, $order) ? $id : false;
(i.e. _addCategory($fullname...) and NOT _addCategory($name...) )
Does that make sense?
Hans
Hans Lellelid wrote:
> There is what [i'm assuming] is a bug in Category_sql, such that when
> I create a new Category (e.g. permission) like this:
>
> $cat->addCategory("app:section:item");
>
> The categories ('app', 'section', and 'item') are all written, _but_
> the `category_parents` column is incorrect for [only] the deepest
> category ('item'). Instead of having the category ids of the other
> two categories, it has :1:1. Apparently this is happening because
> when addCategory() runs all the way through (w/o recursing or
> returning an error object), it returns TRUE instead of the category ID
> that was created -- well, actually it's returning the value of
> parent::_addCategory() which is [always] TRUE.
>
> Attached is a patch for Category_sql::addCategory() that essentially
> just changes the return line so that it returns the category ID -- or
> false if parent::_addCategory() did not return true.
>
> This may well not be the right fix -- but it works.
>
> Cheers,
> Hans
>
>------------------------------------------------------------------------
>
>Index: sql.php
>===================================================================
>RCS file: /repository/horde/lib/Category/sql.php,v
>retrieving revision 1.53
>diff -r1.53 sql.php
>275c275
>< return parent::_addCategory($name, $id, $pid, $order);
>---
>
>
>> return parent::_addCategory($name, $id, $pid, $order) ? $id : false;
>>
>>
>>------------------------------------------------------------------------
>>
>>
>>
>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4461 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.horde.org/archives/dev/attachments/20030114/3368729c/smime.bin
More information about the dev
mailing list