[Fusionforge-commits] r9207 - in branches/Branch_5_0/gforge: common/tracker www/my www/soap/tracker www/tracker

Roland Mas lolando at libremir.placard.fr.eu.org
Mon Mar 22 22:08:07 CET 2010


Author: lolando
Date: 2010-03-22 22:08:06 +0100 (Mon, 22 Mar 2010)
New Revision: 9207

Modified:
   branches/Branch_5_0/gforge/common/tracker/ArtifactFactory.class.php
   branches/Branch_5_0/gforge/www/my/dashboard.php
   branches/Branch_5_0/gforge/www/soap/tracker/tracker.php
   branches/Branch_5_0/gforge/www/tracker/browse.php
Log:
Fixed potential memory exhaustion when querying a tracker with lots of big artifacts (details + followups)

Modified: branches/Branch_5_0/gforge/common/tracker/ArtifactFactory.class.php
===================================================================
--- branches/Branch_5_0/gforge/common/tracker/ArtifactFactory.class.php	2010-03-22 17:56:08 UTC (rev 9206)
+++ branches/Branch_5_0/gforge/common/tracker/ArtifactFactory.class.php	2010-03-22 21:08:06 UTC (rev 9207)
@@ -98,7 +98,6 @@
 	 *	@param	array	Array of extra fields & elements to limit the query to.
 	 */
 	function setup($offset,$order_col,$sort,$max_rows,$set,$_assigned_to,$_status,$_extra_fields=array()) {
-//echo "<br />offset: $offset| order: $order|max_rows: $max_rows|_assigned_to: $_assigned_to|_status: $_status";
 
 		if ((!$offset) || ($offset < 0)) {
 			$this->offset=0;
@@ -106,6 +105,13 @@
 			$this->offset=$offset;
 		}
 
+		// $max_rows == 0 means we want all the rows
+		if (is_null($max_rows) || $max_rows < 0) {
+			$this->max_rows = 50 ;
+		} else {
+			$this->max_rows = $max_rows ;
+		}
+
 		if (session_loggedin()) {
 			$u =& session_get_user();
 		}
@@ -249,16 +255,6 @@
 		}
 		$this->extra_fields=$_extra_fields;
 		$this->setChangedFrom($_changed);
-
-		// if $max_rows == 0 it means we want all the rows
-		if (is_null($max_rows) || $max_rows < 0) {
-			$max_rows=50;
-		}
-		if ($this->query_type == 'query') {
-			$this->max_rows=0;
-		} else {
-			$this->max_rows=$max_rows;
-		}
 	}
 
 	

Modified: branches/Branch_5_0/gforge/www/my/dashboard.php
===================================================================
--- branches/Branch_5_0/gforge/www/my/dashboard.php	2010-03-22 17:56:08 UTC (rev 9206)
+++ branches/Branch_5_0/gforge/www/my/dashboard.php	2010-03-22 21:08:06 UTC (rev 9207)
@@ -134,7 +134,7 @@
                         	        $ath = new ArtifactTypeHtml($group,$at->getID());
 	                                // create artifact object, setup object
         	                        $af = new ArtifactFactory($ath);
-                	                $af->setup(0,"priority","DESC",null,"",0,1,null);
+                	                $af->setup(0,"priority","DESC",0,"",0,1,null);
                         	        // get artifacts from object
                                 	$art_arr =& $af->getArtifacts();
 	                                if (count($art_arr) > 0) {

Modified: branches/Branch_5_0/gforge/www/soap/tracker/tracker.php
===================================================================
--- branches/Branch_5_0/gforge/www/soap/tracker/tracker.php	2010-03-22 17:56:08 UTC (rev 9206)
+++ branches/Branch_5_0/gforge/www/soap/tracker/tracker.php	2010-03-22 21:08:06 UTC (rev 9207)
@@ -719,10 +719,6 @@
 		return new soap_fault ('','getArtifacts',$af->getErrorMessage(),$af->getErrorMessage());
 	}
 
-//MAY HAVE TO CHANGE PARAMS TO FORCE RETRIEVAL OF RIGHT RECORDS - FOR INSTANCE $set='Custom'
-//NEEDS TO BE TESTED
-//	$af->setup(0,'','',0,false,$assigned_to,$status);
-
 	// this is a bit hacky...
 	if ($assigned_to || $status) {
 		$set = "custom";

Modified: branches/Branch_5_0/gforge/www/tracker/browse.php
===================================================================
--- branches/Branch_5_0/gforge/www/tracker/browse.php	2010-03-22 17:56:08 UTC (rev 9206)
+++ branches/Branch_5_0/gforge/www/tracker/browse.php	2010-03-22 21:08:06 UTC (rev 9207)
@@ -1,10 +1,9 @@
 <?php
 /**
- * SourceForge Generic Tracker facility
+ * FusionForge Tracker
  *
- * SourceForge: Breaking Down the Barriers to Open Source Development
  * Copyright 1999-2001 (c) VA Linux Systems
- * http://sourceforge.net
+ * Copyright 2010 Roland Mas
  *
  */
 require_once $gfcommon.'tracker/ArtifactFactory.class.php';
@@ -17,7 +16,10 @@
 }
 
 $query_id = getIntFromRequest('query_id');
+$start = getIntFromRequest('start');
 
+$pagelength = 25 ;
+
 //
 //	The browse page can be powered by a pre-saved query
 //	or by select boxes chosen by the user
@@ -107,7 +109,7 @@
 	}
 }
 
-$af->setup($offset,$_sort_col,$_sort_ord,null,$set,$_assigned_to,$_status,$aux_extra_fields);
+$af->setup($offset,$_sort_col,$_sort_ord,$pagelength,$set,$_assigned_to,$_status,$aux_extra_fields);
 //
 //	These vals are sanitized and/or retrieved from ArtifactFactory stored settings
 //
@@ -382,12 +384,7 @@
 
 	$then=(time()-$ath->getDuePeriod());
 
-	if (!isset($_GET['start'])) {
-		$start=0;
-	} else {
-		$start=$_GET['start'];
-	}
-	$max = ((count($art_arr) > ($start + 25)) ? ($start+25) : count($art_arr) );
+	$max = ((count($art_arr) > ($start + $pagelength)) ? ($start+$pagelength) : count($art_arr) );
 //echo "max: $max";
 	for ($i=$start; $i<$max; $i++) {
  		$extra_data = $art_arr[$i]->getExtraFieldDataText();
@@ -467,8 +464,8 @@
 	}
 	*/
 	echo $GLOBALS['HTML']->listTableBottom();
-	$pages = count($art_arr) / 25;
-	$currentpage = intval($start / 25);
+	$pages = count($art_arr) / $pagelength;
+	$currentpage = intval($start / $pagelength);
 //echo "Item Count: ".count($arr)."Pages: $pages";
 	if ($pages >= 1) {
 		$skipped_pages=false;
@@ -487,7 +484,7 @@
 			if ($j == $currentpage) {
 				echo '<strong>'.($j+1).'</strong>&nbsp;&nbsp;';
 			} else {
-				echo '<a href="'.getStringFromServer('PHP_SELF')."?func=browse&amp;group_id=".$group_id.'&amp;atid='.$ath->getID().'&amp;set='. $set.'&amp;start='.($j*25).'"><strong>'.($j+1).'</strong></a>&nbsp;&nbsp;';
+				echo '<a href="'.getStringFromServer('PHP_SELF')."?func=browse&amp;group_id=".$group_id.'&amp;atid='.$ath->getID().'&amp;set='. $set.'&amp;start='.($j*$pagelength).'"><strong>'.($j+1).'</strong></a>&nbsp;&nbsp;';
 			}
 		}
 	}




More information about the Fusionforge-commits mailing list