From: Honza M. <hon...@ec...> - 2003-01-22 16:50:44
|
Hi Mitra, thans for the changes, it is step forward. A few comments: 1) I fixed small bug in zids->shortids() - check CVS 2) You are using array_slice, array_map functions which are implemented only in PHP4 (array_map PHP 4 >=3D 4.0.6). So far we use only PHP3 functions in AA. Maybe is the time to change, but we have at least ask apc-aa-general. 3) Your assumption that packed ids are EXACTLY 16 characters long (and unpacked are EXACTLY 32 characters long) is unfortunately wrong. I can't say you why - we generate the ids by new_id() function, but in our database are packed ids for item 16 (in 91907 items), 15 (366) and 14 (4) characters long. 4) You wrote: > The main reason for doing this was to add tagged ids, i.e. being able=20 > to have a field in a record that includes an extra piece of=20 > information to type a link, for example the existing related_sel.php3=20 > adds an 'x','y' or 'z' for the direction of the link (although this=20 > doesn't seem to be used anywhere at the moment!). It is good idea of tagged ids. On the other hand the 'x', 'y' and 'z' in related_sel.php3 is not exactly the same as tagged ids - it is never writen to the database. We add 'x', ... just as information to StoreItem() function (see insert_fnc_ids() in include/itemfunc.php3 - there ut is used). In this function we remove 'x', ... and to the database we store untagged item ids! 5) In zids.php3 you wrote: function id_t2l(&$str) { #TODO: Look online for quicker way to substr last 32 chars - mitra if (ereg("(.*)([0-9a-f]{32})",$str,$parts)) return $parts[2]; The quicker way is: substr($str, -32), but see 3) Honza On =DAt, 2003-01-21 at 07:48, Mitra wrote: > Some big changes on the CVS version. >=20 > DO NOT DOWNLOAD ON LIVE SERVERS YET >=20 > The big change is the id encapsulation discussed on here a couple of=20 > weeks ago. I've added a class "zids" which encapsulates an array of=20 > ids. >=20 > Basically the way it works is to store the ids in whatever format=20 > they are supplied in, and then has methods to convert and return them=20 > in the format needed, so for example it can be initialized with=20 > packed ids, and then return long ids. >=20 > The main reason for doing this was to add tagged ids, i.e. being able=20 > to have a field in a record that includes an extra piece of=20 > information to type a link, for example the existing related_sel.php3=20 > adds an 'x','y' or 'z' for the direction of the link (although this=20 > doesn't seem to be used anywhere at the moment!). >=20 > In case you are interested I need the tagged ids for a project where=20 > I want to flag businesses based on criteria (organic, community=20 > supporter etc) but want to have a value (good, medium, bad) on each=20 > link. >=20 > I've changed code to use this class in places where I need it, its=20 > generally applicable so gradually I'll change code as I work in=20 > different places. Because of the way the zids class is written, the=20 > tagged ids won't effect any code not designed to handle them because=20 > they'll be converted to long or quoted etc ids in those places. >=20 > The code also includes other methods for working on ids or collection=20 > of ids, for example there is a "sqlin()" method which returns a=20 > string like 'item.id IN ("12345","6778")' >=20 > Because this code makes changes in lots of places, its possible I've=20 > broken something that I haven't been able to test. Please email me=20 > and I'll make rapid fixes. >=20 > One other change I've made is to add a global variable that works=20 > like $debug, but just gives warnings on places that something strange=20 > is noticed , for example trying to unpack an id which is already=20 > unpacked. I encourage the use of this flag to help track errors,=20 > without generating warnings for users. >=20 > It would be great if people with non-active installations could test=20 > this, i.e. people for whom finding a bug won't muck up a live server! >=20 > Note the CVS version also includes Jakub's system-wide m_gettext=20 > changes, so that is another reason to download and test on a non-live=20 > installation. >=20 > I'll be happy to take bug reports and treat them as a priority to get=20 > them fixed. >=20 > - Mitra >=20 >=20 > 01/21/03 - code rule changes > - added global flag $errcheck like $debug but generates=20 > warnings on str > angeness > - added zids.php3 to encapsulate id management including: > * adds support for tagged ids in many places (not all yet) > ** If related item window field set to store text, it will=20 > cleanly ed > it these > *** More changes to related item window coming > * duplicates pack_id and unpack_id to pack_id128 and=20 > unpack_id128 whi > ch check type > - commented out require of _lang.php3 files from config.php3 |