/** * Get a URL for submission back to the same script. * * @param $query array * @return string */ public function getUrl($query = array()) { $url = $this->request->getRequestURL(); # Remove existing query $url = preg_replace('/\\?.*$/', '', $url); if ($query) { $url .= '?' . wfArrayToCgi($query); } return $url; }
} date_default_timezone_set($wgLocaltimezone); if (is_null($wgLocalTZoffset)) { $wgLocalTZoffset = date('Z') / 60; } if (!$wgDBerrorLogTZ) { $wgDBerrorLogTZ = $wgLocaltimezone; } // Useful debug output if ($wgCommandLineMode) { $wgRequest = new FauxRequest(array()); wfDebug("\n\nStart command line script {$self}\n"); } else { // Can't stub this one, it sets up $_GET and $_REQUEST in its constructor $wgRequest = new WebRequest(); $debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n"; if ($wgDebugPrintHttpHeaders) { $debug .= "HTTP HEADERS:\n"; foreach ($wgRequest->getAllHeaders() as $name => $value) { $debug .= "{$name}: {$value}\n"; } } wfDebug($debug); } Profiler::instance()->scopedProfileOut($ps_misc); $ps_memcached = Profiler::instance()->scopedProfileIn($fname . '-memcached'); $wgMemc = wfGetMainCache(); $messageMemc = wfGetMessageCacheStorage(); $parserMemc = wfGetParserCacheStorage(); wfDebugLog('caches', 'main: ' . get_class($wgMemc) . ', message: ' . get_class($messageMemc) . ', parser: ' . get_class($parserMemc)); Profiler::instance()->scopedProfileOut($ps_memcached);
private function process(WebRequest &$request, OutputPage &$output) { global $wgLinkTitlesTimeLimit; // Start the stopwatch $startTime = microtime(true); // Connect to the database $dbr = wfGetDB(DB_SLAVE); // Fetch the start index and max number of records from the POST // request. $postValues = $request->getValues(); // Convert the start index to an integer; this helps preventing // SQL injection attacks via forged POST requests. $start = intval($postValues['s']); // If an end index was given, we don't need to query the database if (array_key_exists('e', $postValues)) { $end = intval($postValues['e']); } else { // No end index was given. Therefore, count pages now. $end = $this->countPages($dbr); } array_key_exists('r', $postValues) ? $reloads = $postValues['r'] : ($reloads = 0); // Retrieve page names from the database. $res = $dbr->select('page', 'page_title', array('page_namespace = 0'), __METHOD__, array('LIMIT' => 999999999, 'OFFSET' => $start)); // Iterate through the pages; break if a time limit is exceeded. foreach ($res as $row) { $curTitle = $row->page_title; LinkTitles::processPage($curTitle, $this->getContext()); $start += 1; // Check if the time limit is exceeded if (microtime(true) - $startTime > $wgLinkTitlesTimeLimit) { break; } } $this->addProgressInfo($output, $curTitle, $start, $end); // If we have not reached the last page yet, produce code to reload // the extension's special page. if ($start < $end) { $reloads += 1; // Build a form with hidden values and output JavaScript code that // immediately submits the form in order to continue the process. $output->addHTML($this->getReloaderForm($request->getRequestURL(), $start, $end, $reloads)); } else { $this->addCompletedInfo($output, $start, $end, $reloads); } }
wfSuppressWarnings(); $wgLocaltimezone = date_default_timezone_get(); wfRestoreWarnings(); } date_default_timezone_set($wgLocaltimezone); if (is_null($wgLocalTZoffset)) { $wgLocalTZoffset = date('Z') / 60; } # Useful debug output if ($wgCommandLineMode) { $wgRequest = new FauxRequest(array()); wfDebug("\n\nStart command line script {$self}\n"); } else { # Can't stub this one, it sets up $_GET and $_REQUEST in its constructor $wgRequest = new WebRequest(); $debug = "Start request\n\n{$_SERVER['REQUEST_METHOD']} {$wgRequest->getRequestURL()}"; if ($wgDebugPrintHttpHeaders) { $debug .= "\nHTTP HEADERS:\n"; foreach ($wgRequest->getAllHeaders() as $name => $value) { $debug .= "{$name}: {$value}\n"; } } wfDebug("{$debug}\n"); } wfProfileOut($fname . '-misc1'); wfProfileIn($fname . '-memcached'); $wgMemc = wfGetMainCache(); $messageMemc = wfGetMessageCacheStorage(); $parserMemc = wfGetParserCacheStorage(); wfDebug('CACHES: ' . get_class($wgMemc) . '[main] ' . get_class($messageMemc) . '[message] ' . get_class($parserMemc) . "[parser]\n"); wfProfileOut($fname . '-memcached');