From: Jonny B. <jo...@ti...> - 2011-06-04 15:42:31
|
Hi all - Sylvie mainly i guess. Can you check this over sometime please? (or the equivalent in 7.x) - it seems to work better for me in most cases, especially on large sets of categorised objects, but i don't think it's quite 100% right still and i'm concerned because i didn't really understand how the $join var worked before (as it was unused). Hope there are no surprise regressions due to this, particularly when using the category plugin - let me know quicky-quick if you find anything. Thanks jonny On 4 Jun 2011, at 16:31, jon...@us... wrote: > Revision: 34761 > http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=34761&view=rev > Author: jonnybradley > Date: 2011-06-04 15:31:52 +0000 (Sat, 04 Jun 2011) > > Log Message: > ----------- > [bp/r34759+60][FIX] categories: Fix getting multiple categories in "and" mode and stop ignoring maxRecords in get_categoryobjects (previous workaround) > Also partial bp/r32018 to handle an array of types > > Modified Paths: > -------------- > branches/proposals/6.x/lib/categories/categlib.php > > Modified: branches/proposals/6.x/lib/categories/categlib.php > =================================================================== > --- branches/proposals/6.x/lib/categories/categlib.php 2011-06-04 15:20:46 UTC (rev 34760) > +++ branches/proposals/6.x/lib/categories/categlib.php 2011-06-04 15:31:52 UTC (rev 34761) > @@ -459,14 +459,15 @@ > $join = ''; > if (is_array($categId) && $and) { > $categId = $this->get_jailed( $categId ); > - $i = count($categId); > - $bindWhere = $categId; > + $i = count($categId)+1; > + $bindWhere = array(); > foreach ($categId as $c) { > - if (--$i) > - $join .= " INNER JOIN tiki_category_objects tco$i on (tco$i.`catObjectId`=o.`catObjectId` and tco$i.`categId`=?) "; > + if (--$i) { > + $join .= " INNER JOIN tiki_category_objects tco$i on tco$i.`catObjectId`=o.`objectId` and tco$i.`categId`=? "; > + $bindWhere[] = $c; > + } > } > - $where = ' AND c.`categId`=? '; > - } elseif (is_array($categId)) { > + } elseif (is_array($categId)) { > $bindWhere = $categId; > if ($deep) { > foreach ($categId as $c) { > @@ -499,8 +500,13 @@ > $where .= " AND (`name` LIKE ? OR `description` LIKE ?)"; > } > if (!empty($type)) { > - $where .= ' AND `type` =? '; > - $bindWhere[] = $type; > + if (is_array($type)) { > + $where .= ' AND `type` in ('.implode(',',array_fill(0,count($type),'?')).')'; > + $bindWhere = array_merge($bindWhere, $type); > + } else { > + $where .= ' AND `type` =? '; > + $bindWhere[] = $type; > + } > } > > global $user; > @@ -517,7 +523,7 @@ > } > > // Fetch all results as was done before, but only do it once > - $query_cant = "SELECT DISTINCT c.*, o.* FROM `tiki_category_objects` c, `tiki_categorized_objects` co, `tiki_objects` o WHERE c.`catObjectId`=o.`objectId` AND o.`objectId`=co.`catObjectId` $where"; > + $query_cant = "SELECT DISTINCT c.*, o.* FROM `tiki_category_objects` c, `tiki_categorized_objects` co, `tiki_objects` o $join WHERE c.`catObjectId`=o.`objectId` AND o.`objectId`=co.`catObjectId` $where"; > $query = $query_cant . $orderBy; > $result = $this->fetchAll($query,$bindVars); > $cant = count($result); > @@ -1220,7 +1226,7 @@ > foreach ($catids as $id) { > $titles["$id"] = $this->get_category_name($id); > $objectcat = array(); > - $objectcat = $this->list_category_objects($id, $offset, $maxRecords, $sort, '', $find, $sub); > + $objectcat = $this->list_category_objects($id, $offset, $maxRecords, $sort, $types == '*'? '': $typesallowed, $find, $sub, $and); > > $acats = $andcat = array(); > foreach ($objectcat["data"] as $obj) { > > > This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. > > ------------------------------------------------------------------------------ > Simplify data backup and recovery for your virtual environment with vRanger. > Installation's a snap, and flexible recovery options mean your data is safe, > secure and there when you need it. Discover what all the cheering's about. > Get your free trial download today. > http://p.sf.net/sfu/quest-dev2dev2 > _______________________________________________ > Tikiwiki-cvs mailing list > Tik...@li... > https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs > |