From: Mitra <mi...@mi...> - 2003-01-22 21:59:25
|
At 6:08 PM +0100 22/1/03, Honza Malik wrote: >Hi Mitra, > > thans for the changes, it is step forward. A few comments: > >1) I fixed small bug in zids->shortids() - check CVS Thanks - I guess none of my test views are using short ids! >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. I'll ask. If necessary, maybe there are equivalents of any PHP4 functions we are using, for example an implementation of array_map written in PHP3, that we could conditionally include? > >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. Strange - because new_id uses "md5" which has to return 128 bits. I wonder if these were ids which generated a leading ascii zero, the ratios look reasonable for this, i.e. 919007/366 =3D 251, which is close to a one in 256 chance, i.e. something that occurred when 8 bits (2^8=3D256) all were zero. This makes sense if we assume that md5 returns a number which the ereg in new_id casts as a string, and so ignores the leading zero. I've fixed zids.php3 to allow 12..16 character packed ids, and 24..32 long, but this could break my tagged ids. I've also fixed util.php3.new_id to only return a string of exactly 16 chars. > >4) You wrote: >> The main reason for doing this was to add tagged ids, i.e. being able >> to have a field in a record that includes an extra piece of >> information to type a link, for example the existing related_sel.php3 >> adds an 'x','y' or 'z' for the direction of the link (although this >> doesn't seem to be used anywhere at the moment!). > >It is good idea of tagged ids. Thanks - I'm building a site now that uses them. >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! This is what I keep asking (unanswered) questions about. In related_sel.php3 you have three buttons "Add" "Add Mutual" "Add Backward" which add "x", "y" or "z", if you add the result as an id then its is stripped, but if you add it as text it is stored, but doesn't seem to be used anywhere, and didn't work with related views! So why were the three buttons put in if the code doesn't use them, or was this some project that never got finished. I don't care too much ... except that I've been trying very hard not to break code, that I couldn't figure out how it could ever be used! > >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) Ok - I'll make this 24..32, and I guess we can't use tags that end in a hex character [0-9a-f) - Mitra >On =DAt, 2003-01-21 at 07:48, Mitra wrote: >> Some big changes on the CVS version. >> >> DO NOT DOWNLOAD ON LIVE SERVERS YET > > > > The big change is the id encapsulation discussed on here a couple of > > weeks ago. I've added a class "zids" which encapsulates an array of > > ids. > > > > Basically the way it works is to store the ids in whatever format >> they are supplied in, and then has methods to convert and return them >> in the format needed, so for example it can be initialized with >> packed ids, and then return long ids. >> >> The main reason for doing this was to add tagged ids, i.e. being able > > to have a field in a record that includes an extra piece of >> information to type a link, for example the existing related_sel.php3 >> adds an 'x','y' or 'z' for the direction of the link (although this >> doesn't seem to be used anywhere at the moment!). >> >> In case you are interested I need the tagged ids for a project where >> I want to flag businesses based on criteria (organic, community >> supporter etc) but want to have a value (good, medium, bad) on each >> link. >> >> I've changed code to use this class in places where I need it, its >> generally applicable so gradually I'll change code as I work in >> different places. Because of the way the zids class is written, the >> tagged ids won't effect any code not designed to handle them because >> they'll be converted to long or quoted etc ids in those places. >> >> The code also includes other methods for working on ids or collection >> of ids, for example there is a "sqlin()" method which returns a >> string like 'item.id IN ("12345","6778")' >> >> Because this code makes changes in lots of places, its possible I've >> broken something that I haven't been able to test. Please email me >> and I'll make rapid fixes. >> >> One other change I've made is to add a global variable that works >> like $debug, but just gives warnings on places that something strange >> is noticed , for example trying to unpack an id which is already >> unpacked. I encourage the use of this flag to help track errors, >> without generating warnings for users. >> >> It would be great if people with non-active installations could test >> this, i.e. people for whom finding a bug won't muck up a live server! >> >> Note the CVS version also includes Jakub's system-wide m_gettext >> changes, so that is another reason to download and test on a non-live >> installation. >> >> I'll be happy to take bug reports and treat them as a priority to get >> them fixed. >> >> - Mitra >> >> >> 01/21/03 - code rule changes >> - added global flag $errcheck like $debug but generates >> 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 >> cleanly ed >> it these >> *** More changes to related item window coming >> * duplicates pack_id and unpack_id to pack_id128 and >> unpack_id128 whi >> ch check type >> - commented out require of _lang.php3 files from config.php3 > > > >------------------------------------------------------- >This SF.net email is sponsored by: Scholarships for Techies! >Can't afford IT training? All 2003 ictp students receive scholarships. >Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more. >www.ictp.com/training/sourceforge.asp >_______________________________________________ >Apc-aa-coders mailing list >Apc...@li... >https://lists.sourceforge.net/lists/listinfo/apc-aa-coders -- Mitra Technology Consulting - www.mitra.biz - mi...@mi... 02-6684-8096 or 0414-648-0722 Life is a Mystery to be Lived, not a Problem to be Solved |