(bug 9575) Accept upload description from GET parameters
[lhc/web/wiklou.git] / includes / HTMLCacheUpdate.php
index f76bcd6..260439b 100644 (file)
@@ -38,7 +38,7 @@ class HTMLCacheUpdate
        function doUpdate() {
                # Fetch the IDs
                $cond = $this->getToCondition();
-               $dbr =& wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_SLAVE );
                $res = $dbr->select( $this->mTable, $this->getFromField(), $cond, __METHOD__ );
                $resWrap = new ResultWrapper( $dbr, $res );
                if ( $dbr->numRows( $res ) != 0 ) {
@@ -55,7 +55,6 @@ class HTMLCacheUpdate
                $numRows = $res->numRows();
                $numBatches = ceil( $numRows / $this->mRowsPerJob );
                $realBatchSize = $numRows / $numBatches;
-               $boundaries = array();
                $start = false;
                $jobs = array();
                do {
@@ -68,13 +67,13 @@ class HTMLCacheUpdate
                                        break;
                                }
                        }
-                       if ( $id !== false ) {
-                               // One less on the end to avoid duplicating the boundary
-                               $job = new HTMLCacheUpdateJob( $this->mTitle, $this->mTable, $start, $id - 1 );
-                       } else {
-                               $job = new HTMLCacheUpdateJob( $this->mTitle, $this->mTable, $start, false );
-                       }
-                       $jobs[] = $job;
+                       
+                       $params = array(
+                               'table' => $this->mTable,
+                               'start' => $start,
+                               'end' => ( $id !== false ? $id - 1 : false ),
+                       );
+                       $jobs[] = new HTMLCacheUpdateJob( $this->mTitle, $params );
 
                        $start = $id;
                } while ( $start );
@@ -137,7 +136,7 @@ class HTMLCacheUpdate
                        return;
                }
 
-               $dbw =& wfGetDB( DB_MASTER );
+               $dbw = wfGetDB( DB_MASTER );
                $timestamp = $dbw->timestamp();
                $done = false;
                
@@ -185,26 +184,23 @@ class HTMLCacheUpdate
        }
 }
 
+/**
+ * @todo document (e.g. one-sentence top-level class description).
+ */
 class HTMLCacheUpdateJob extends Job {
        var $table, $start, $end;
 
        /**
         * Construct a job
         * @param Title $title The title linked to
-        * @param string $table The name of the link table.
-        * @param integer $start Beginning page_id or false for open interval
-        * @param integer $end End page_id or false for open interval
+        * @param array $params Job parameters (table, start and end page_ids)
         * @param integer $id job_id
         */
-       function __construct( $title, $table, $start, $end, $id = 0 ) {
-               $params = array(
-                       'table' => $table, 
-                       'start' => $start, 
-                       'end' => $end );
+       function __construct( $title, $params, $id = 0 ) {
                parent::__construct( 'htmlCacheUpdate', $title, $params, $id );
-               $this->table = $table;
-               $this->start = intval( $start );
-               $this->end = intval( $end );
+               $this->table = $params['table'];
+               $this->start = $params['start'];
+               $this->end = $params['end'];
        }
 
        function run() {
@@ -219,7 +215,7 @@ class HTMLCacheUpdateJob extends Job {
                        $conds[] = "$fromField <= {$this->end}";
                }
 
-               $dbr =& wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_SLAVE );
                $res = $dbr->select( $this->table, $fromField, $conds, __METHOD__ );
                $update->invalidateIDs( new ResultWrapper( $dbr, $res ) );
                $dbr->freeResult( $res );
@@ -227,4 +223,4 @@ class HTMLCacheUpdateJob extends Job {
                return true;
        }
 }
-?>
+