Index: trunk/phase3/maintenance/cleanupUploadStash.php |
— | — | @@ -36,12 +36,12 @@ |
37 | 37 | |
38 | 38 | public function execute() { |
39 | 39 | $repo = RepoGroup::singleton()->getLocalRepo(); |
40 | | - |
| 40 | + |
41 | 41 | $dbr = $repo->getSlaveDb(); |
42 | 42 | |
43 | 43 | // how far back should this look for files to delete? |
44 | 44 | global $wgUploadStashMaxAge; |
45 | | - |
| 45 | + |
46 | 46 | $this->output( "Getting list of files to clean up...\n" ); |
47 | 47 | $res = $dbr->select( |
48 | 48 | 'uploadstash', |
— | — | @@ -49,10 +49,11 @@ |
50 | 50 | 'us_timestamp < ' . $dbr->timestamp( time() - $wgUploadStashMaxAge ), |
51 | 51 | __METHOD__ |
52 | 52 | ); |
53 | | - |
| 53 | + |
54 | 54 | if( !is_object( $res ) || $res->numRows() == 0 ) { |
| 55 | + $this->output( 'No files to cleanup!' ); |
55 | 56 | // nothing to do. |
56 | | - return false; |
| 57 | + return; |
57 | 58 | } |
58 | 59 | |
59 | 60 | // finish the read before starting writes. |
— | — | @@ -60,13 +61,13 @@ |
61 | 62 | foreach($res as $row) { |
62 | 63 | array_push( $keys, $row->us_key ); |
63 | 64 | } |
64 | | - |
| 65 | + |
65 | 66 | $this->output( 'Removing ' . count($keys) . " file(s)...\n" ); |
66 | 67 | // this could be done some other, more direct/efficient way, but using |
67 | 68 | // UploadStash's own methods means it's less likely to fall accidentally |
68 | 69 | // out-of-date someday |
69 | 70 | $stash = new UploadStash( $repo ); |
70 | | - |
| 71 | + |
71 | 72 | foreach( $keys as $key ) { |
72 | 73 | $stash->getFile( $key, true ); |
73 | 74 | $stash->removeFileNoAuth( $key ); |
— | — | @@ -75,4 +76,4 @@ |
76 | 77 | } |
77 | 78 | |
78 | 79 | $maintClass = "UploadStashCleanup"; |
79 | | -require_once( RUN_MAINTENANCE_IF_MAIN ); |
\ No newline at end of file |
| 80 | +require_once( RUN_MAINTENANCE_IF_MAIN ); |
Index: trunk/phase3/maintenance/checkSyntax.php |
— | — | @@ -165,6 +165,8 @@ |
166 | 166 | |
167 | 167 | /** |
168 | 168 | * Returns true if $file is of a type we can check |
| 169 | + * @param $file string |
| 170 | + * @return bool |
169 | 171 | */ |
170 | 172 | private function isSuitableFile( $file ) { |
171 | 173 | $file = str_replace( '\\', '/', $file ); |
— | — | @@ -181,6 +183,8 @@ |
182 | 184 | |
183 | 185 | /** |
184 | 186 | * Add given path to file list, searching it in include path if needed |
| 187 | + * @param $path string |
| 188 | + * @return bool |
185 | 189 | */ |
186 | 190 | private function addPath( $path ) { |
187 | 191 | global $IP; |
— | — | @@ -188,8 +192,10 @@ |
189 | 193 | } |
190 | 194 | |
191 | 195 | /** |
192 | | - * Add given file to file list, or, if it's a directory, add its content |
193 | | - */ |
| 196 | + * Add given file to file list, or, if it's a directory, add its content |
| 197 | + * @param $path string |
| 198 | + * @return bool |
| 199 | + */ |
194 | 200 | private function addFileOrDir( $path ) { |
195 | 201 | if ( is_dir( $path ) ) { |
196 | 202 | $this->addDirectoryContent( $path ); |
Index: trunk/phase3/maintenance/fuzz-tester.php |
— | — | @@ -759,14 +759,18 @@ |
760 | 760 | static private $maxparams = 10; |
761 | 761 | |
762 | 762 | /** |
763 | | - ** Returns random number between finish and start. |
| 763 | + * Returns random number between finish and start. |
| 764 | + * @param $finish |
| 765 | + * @param $start int |
| 766 | + * @return int |
764 | 767 | */ |
765 | 768 | static public function randnum( $finish, $start = 0 ) { |
766 | 769 | return mt_rand( $start, $finish ); |
767 | 770 | } |
768 | 771 | |
769 | 772 | /** |
770 | | - ** Returns a mix of random text and random wiki syntax. |
| 773 | + * Returns a mix of random text and random wiki syntax. |
| 774 | + * @return string |
771 | 775 | */ |
772 | 776 | static private function randstring() { |
773 | 777 | $thestring = ""; |
— | — | @@ -796,18 +800,17 @@ |
797 | 801 | } |
798 | 802 | |
799 | 803 | /** |
800 | | - ** Returns either random text, or random wiki syntax, or random data from "ints", |
801 | | - ** or random data from "other". |
| 804 | + * Returns either random text, or random wiki syntax, or random data from "ints", |
| 805 | + * or random data from "other". |
| 806 | + * @return string |
802 | 807 | */ |
803 | 808 | static private function makestring() { |
804 | 809 | $what = wikiFuzz::randnum( 2 ); |
805 | 810 | if ( $what == 0 ) { |
806 | 811 | return wikiFuzz::randstring(); |
807 | | - } |
808 | | - elseif ( $what == 1 ) { |
| 812 | + } elseif ( $what == 1 ) { |
809 | 813 | return wikiFuzz::$ints[wikiFuzz::randnum( count( wikiFuzz::$ints ) - 1 )]; |
810 | | - } |
811 | | - else { |
| 814 | + } else { |
812 | 815 | return wikiFuzz::$other[wikiFuzz::randnum( count( wikiFuzz::$other ) - 1 )]; |
813 | 816 | } |
814 | 817 | } |
— | — | @@ -815,6 +818,8 @@ |
816 | 819 | /** |
817 | 820 | * Returns the matched character slash-escaped as in a C string |
818 | 821 | * Helper for makeTitleSafe callback |
| 822 | + * @param $matches |
| 823 | + * @return atring |
819 | 824 | */ |
820 | 825 | static private function stringEscape( $matches ) { |
821 | 826 | return sprintf( "\\x%02x", ord( $matches[1] ) ); |
— | — | @@ -823,6 +828,8 @@ |
824 | 829 | /** |
825 | 830 | ** Strips out the stuff that Mediawiki balks at in a page's title. |
826 | 831 | ** Implementation copied/pasted from cleanupTable.inc & cleanupImages.php |
| 832 | + * @param $str string |
| 833 | + * @return string |
827 | 834 | */ |
828 | 835 | static public function makeTitleSafe( $str ) { |
829 | 836 | $legalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF"; |
— | — | @@ -833,6 +840,7 @@ |
834 | 841 | |
835 | 842 | /** |
836 | 843 | ** Returns a string of fuzz text. |
| 844 | + * @return string |
837 | 845 | */ |
838 | 846 | static private function loop() { |
839 | 847 | switch ( wikiFuzz::randnum( 3 ) ) { |
— | — | @@ -860,7 +868,8 @@ |
861 | 869 | } |
862 | 870 | |
863 | 871 | /** |
864 | | - ** Returns one of the three styles of random quote: ', ", and nothing. |
| 872 | + * Returns one of the three styles of random quote: ', ", and nothing. |
| 873 | + * @return string |
865 | 874 | */ |
866 | 875 | static private function getRandQuote() { |
867 | 876 | switch ( wikiFuzz::randnum( 3 ) ) { |
— | — | @@ -872,6 +881,8 @@ |
873 | 882 | |
874 | 883 | /** |
875 | 884 | ** Returns fuzz text, with the parameter indicating approximately how many lines of text you want. |
| 885 | + * @param $maxtypes int |
| 886 | + * @return string |
876 | 887 | */ |
877 | 888 | static public function makeFuzz( $maxtypes = 2 ) { |
878 | 889 | $page = ""; |
— | — | @@ -2174,9 +2185,10 @@ |
2175 | 2186 | } |
2176 | 2187 | } |
2177 | 2188 | |
2178 | | - |
2179 | 2189 | /** |
2180 | 2190 | ** selects a page test to run. |
| 2191 | + * @param $count |
| 2192 | + * @return \api|\confirmEmail|\contributionsTest|\editPageTest|\imagelistTest|\imagepageTest|\ipblocklistTest|\listusersTest|\mimeSearchTest|\newImagesTest|\pageDeletion|\pageHistoryTest|\pageProtectionForm|\prefixindexTest|\profileInfo|\recentchangesTest|\redirectTest|\searchTest|\specialAllmessagesTest|\specialAllpagesTest|\specialBlockip|\specialBlockmeTest|\specialBooksourcesTest|\specialCategoryTree|\specialChemicalsourcesTest|\specialCitePageTest|\specialExportTest|\specialFilepathPageTest|\specialImportPageTest|\specialLinksearch|\specialLockdbPageTest|\specialLogTest|\specialMovePage|\specialNewpagesPageTest|\specialRenameuserPageTest|\specialRevisionDeletePageTest|\specialUndeletePageTest|\specialUnlockdbPageTest|\specialUserrights|\successfulUserLoginTest|\thumbTest|\trackbackTest|\userLoginTest|\viewPageTest|\watchlistTest |
2181 | 2193 | */ |
2182 | 2194 | function selectPageTest( $count ) { |
2183 | 2195 | |
— | — | @@ -2248,11 +2260,12 @@ |
2249 | 2261 | file_put_contents( $name, $data ); |
2250 | 2262 | } |
2251 | 2263 | |
2252 | | - |
2253 | 2264 | /** |
2254 | 2265 | ** Returns a test as an experimental GET-to-POST URL. |
2255 | 2266 | ** This doesn't seem to always work though, and sometimes the output is too long |
2256 | 2267 | ** to be a valid GET URL, so we also save in other formats. |
| 2268 | + * @param $test pageTest |
| 2269 | + * @return string |
2257 | 2270 | */ |
2258 | 2271 | function getAsURL( pageTest $test ) { |
2259 | 2272 | $used_question_mark = ( strpos( $test->getPagePath(), "?" ) !== false ); |
— | — | @@ -2304,11 +2317,12 @@ |
2305 | 2318 | saveFile( $str, $filename ); |
2306 | 2319 | } |
2307 | 2320 | |
2308 | | - |
2309 | 2321 | /** |
2310 | | - ** Escapes a value so that it can be used on the command line by Curl. |
2311 | | - ** Specifically, "<" and "@" need to be escaped if they are the first character, |
2312 | | - ** otherwise curl interprets these as meaning that we want to insert a file. |
| 2322 | + * Escapes a value so that it can be used on the command line by Curl. |
| 2323 | + * Specifically, "<" and "@" need to be escaped if they are the first character, |
| 2324 | + * otherwise curl interprets these as meaning that we want to insert a file. |
| 2325 | + * @param $input_params array |
| 2326 | + * @return array |
2313 | 2327 | */ |
2314 | 2328 | function escapeForCurl( array $input_params ) { |
2315 | 2329 | $output_params = array(); |
— | — | @@ -2359,18 +2373,21 @@ |
2360 | 2374 | saveTestData ( $test, $base_name . DATA_FILE ); |
2361 | 2375 | } |
2362 | 2376 | |
2363 | | - |
2364 | 2377 | // ////////////////// MEDIAWIKI OUTPUT ///////////////////////// |
2365 | 2378 | |
2366 | 2379 | /** |
2367 | | - ** Asks MediaWiki for the HTML output of a test. |
| 2380 | + * Asks MediaWiki for the HTML output of a test. |
| 2381 | + * @param $test pageTest |
| 2382 | + * @return string |
2368 | 2383 | */ |
2369 | 2384 | function wikiTestOutput( pageTest $test ) { |
2370 | 2385 | |
2371 | 2386 | $ch = curl_init(); |
2372 | 2387 | |
2373 | 2388 | // specify the cookie, if required. |
2374 | | - if ( $test->getCookie() ) curl_setopt( $ch, CURLOPT_COOKIE, $test->getCookie() ); |
| 2389 | + if ( $test->getCookie() ) { |
| 2390 | + curl_setopt( $ch, CURLOPT_COOKIE, $test->getCookie() ); |
| 2391 | + } |
2375 | 2392 | curl_setopt( $ch, CURLOPT_POST, 1 ); // save form using a POST |
2376 | 2393 | |
2377 | 2394 | $params = escapeForCurl( $test->getParams() ); |
— | — | @@ -2397,6 +2414,8 @@ |
2398 | 2415 | |
2399 | 2416 | /** |
2400 | 2417 | * Asks the validator whether this is valid HTML, or not. |
| 2418 | + * @param $text string |
| 2419 | + * @return array |
2401 | 2420 | */ |
2402 | 2421 | function validateHTML( $text ) { |
2403 | 2422 | |
— | — | @@ -2425,9 +2444,10 @@ |
2426 | 2445 | return array( $valid, $result ); |
2427 | 2446 | } |
2428 | 2447 | |
2429 | | - |
2430 | 2448 | /** |
2431 | | - ** Get tidy to check for no HTML errors in the output file (e.g. unescaped strings). |
| 2449 | + * Get tidy to check for no HTML errors in the output file (e.g. unescaped strings). |
| 2450 | + * @param $name |
| 2451 | + * @return bool |
2432 | 2452 | */ |
2433 | 2453 | function tidyCheckFile( $name ) { |
2434 | 2454 | $file = DIRECTORY . "/" . $name; |
— | — | @@ -2446,10 +2466,10 @@ |
2447 | 2467 | } |
2448 | 2468 | } |
2449 | 2469 | |
2450 | | - |
2451 | 2470 | /** |
2452 | 2471 | ** Returns whether or not an database error log file has changed in size since |
2453 | 2472 | ** the last time this was run. This is used to tell if a test caused a DB error. |
| 2473 | + * @return bool |
2454 | 2474 | */ |
2455 | 2475 | function dbErrorLogged() { |
2456 | 2476 | static $filesize; |
— | — | @@ -2477,8 +2497,12 @@ |
2478 | 2498 | // //////////////// TOP-LEVEL PROBLEM-FINDING FUNCTION //////////////////////// |
2479 | 2499 | |
2480 | 2500 | /** |
2481 | | - ** takes a page test, and runs it and tests it for problems in the output. |
2482 | | - ** Returns: False on finding a problem, or True on no problems being found. |
| 2501 | + * takes a page test, and runs it and tests it for problems in the output. |
| 2502 | + * Returns: False on finding a problem, or True on no problems being found. |
| 2503 | + * @param $test pageTest |
| 2504 | + * @param $testname |
| 2505 | + * @param $can_overwrite bool |
| 2506 | + * @return bool |
2483 | 2507 | */ |
2484 | 2508 | function runWikiTest( pageTest $test, &$testname, $can_overwrite = false ) { |
2485 | 2509 | |
Index: trunk/phase3/maintenance/mwdocgen.php |
— | — | @@ -89,6 +89,7 @@ |
90 | 90 | /** |
91 | 91 | * Read a line from the shell |
92 | 92 | * @param $prompt String |
| 93 | + * @return string |
93 | 94 | */ |
94 | 95 | function readaline( $prompt = '' ) { |
95 | 96 | print $prompt; |
— | — | @@ -151,6 +152,7 @@ |
152 | 153 | * @param $exclude String: Additionals path regex to exclude |
153 | 154 | * @param $exclude_patterns String: Additionals path regex to exclude |
154 | 155 | * (LocalSettings.php, AdminSettings.php, .svn and .git directories are always excluded) |
| 156 | + * @return string |
155 | 157 | */ |
156 | 158 | function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath, $currentVersion, $svnstat, $input, $exclude, $exclude_patterns ) { |
157 | 159 | |
Index: trunk/phase3/maintenance/generateSitemap.php |
— | — | @@ -188,6 +188,9 @@ |
189 | 189 | |
190 | 190 | // Custom priorities |
191 | 191 | if ( $wgSitemapNamespacesPriorities !== false ) { |
| 192 | + /** |
| 193 | + * @var $wgSitemapNamespacesPriorities array |
| 194 | + */ |
192 | 195 | foreach ( $wgSitemapNamespacesPriorities as $namespace => $priority ) { |
193 | 196 | $float = floatval( $priority ); |
194 | 197 | if ( $float > 1.0 ) { |
— | — | @@ -202,6 +205,8 @@ |
203 | 206 | |
204 | 207 | /** |
205 | 208 | * Create directory if it does not exist and return pathname with a trailing slash |
| 209 | + * @param $fspath string |
| 210 | + * @return null|string |
206 | 211 | */ |
207 | 212 | private static function init_path( $fspath ) { |
208 | 213 | if ( !isset( $fspath ) ) { |
Index: trunk/phase3/maintenance/jsparse.php |
— | — | @@ -32,7 +32,6 @@ |
33 | 33 | } |
34 | 34 | |
35 | 35 | public function execute() { |
36 | | - $iterations = $this->getOption( 'i', 100 ); |
37 | 36 | if ( $this->hasArg() ) { |
38 | 37 | $files = $this->mArgs; |
39 | 38 | } else { |
Index: trunk/phase3/maintenance/backup.inc |
— | — | @@ -252,6 +252,7 @@ |
253 | 253 | * @todo Fixme: the --server parameter is currently not respected, as it |
254 | 254 | * doesn't seem terribly easy to ask the load balancer for a particular |
255 | 255 | * connection by name. |
| 256 | + * @return DatabaseBase |
256 | 257 | */ |
257 | 258 | function backupDb() { |
258 | 259 | $this->lb = wfGetLBFactory()->newMainLB(); |
Index: trunk/phase3/maintenance/importDump.php |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | $this->stderr = fopen( "php://stderr", "wt" ); |
59 | 59 | $this->addOption( 'report', |
60 | 60 | 'Report position and speed after every n pages processed', false, true ); |
61 | | - $this->addOption( 'namespaces', |
| 61 | + $this->addOption( 'namespaces', |
62 | 62 | 'Import only the pages from namespaces belonging to the list of ' . |
63 | 63 | 'pipe-separated namespace names or namespace indexes', false, true ); |
64 | 64 | $this->addOption( 'dry-run', 'Parse dump without actually importing pages' ); |
— | — | @@ -154,10 +154,14 @@ |
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
| 158 | + /** |
| 159 | + * @param $revision Revision |
| 160 | + * @return bool |
| 161 | + */ |
158 | 162 | function handleUpload( $revision ) { |
159 | 163 | if ( $this->uploads ) { |
160 | 164 | if ( $this->skippedNamespace( $revision ) ) { |
161 | | - return; |
| 165 | + return ; |
162 | 166 | } |
163 | 167 | $this->uploadCount++; |
164 | 168 | // $this->report(); |
Index: trunk/phase3/maintenance/cleanupImages.php |
— | — | @@ -73,8 +73,9 @@ |
74 | 74 | if ( is_null( $title ) ) { |
75 | 75 | $this->output( "page $source ($cleaned) is illegal.\n" ); |
76 | 76 | $safe = $this->buildSafeTitle( $cleaned ); |
77 | | - if ( $safe === false ) |
| 77 | + if ( $safe === false ) { |
78 | 78 | return $this->progress( 0 ); |
| 79 | + } |
79 | 80 | $this->pokeFile( $source, $safe ); |
80 | 81 | return $this->progress( 1 ); |
81 | 82 | } |
— | — | @@ -86,7 +87,7 @@ |
87 | 88 | return $this->progress( 1 ); |
88 | 89 | } |
89 | 90 | |
90 | | - $this->progress( 0 ); |
| 91 | + return $this->progress( 0 ); |
91 | 92 | } |
92 | 93 | |
93 | 94 | /** |
— | — | @@ -123,7 +124,8 @@ |
124 | 125 | $path = $this->filePath( $orig ); |
125 | 126 | if ( !file_exists( $path ) ) { |
126 | 127 | $this->output( "missing file: $path\n" ); |
127 | | - return $this->killRow( $orig ); |
| 128 | + $this->killRow( $orig ); |
| 129 | + return; |
128 | 130 | } |
129 | 131 | |
130 | 132 | $db = wfGetDB( DB_MASTER ); |
— | — | @@ -138,7 +140,7 @@ |
139 | 141 | $version = 0; |
140 | 142 | $final = $new; |
141 | 143 | $conflict = ( $this->imageExists( $final, $db ) || |
142 | | - ( $this->pageExists( $orig, $db ) && $this->pageExists( $final, $db ) ) ); |
| 144 | + ( $this->pageExists( $orig, $db ) && $this->pageExists( $final, $db ) ) ); |
143 | 145 | |
144 | 146 | while ( $conflict ) { |
145 | 147 | $this->output( "Rename conflicts with '$final'...\n" ); |
— | — | @@ -170,7 +172,7 @@ |
171 | 173 | $dir = dirname( $finalPath ); |
172 | 174 | if ( !file_exists( $dir ) ) { |
173 | 175 | if ( !wfMkdirParents( $dir, null, __METHOD__ ) ) { |
174 | | - $this->log( "RENAME FAILED, COULD NOT CREATE $dir" ); |
| 176 | + $this->output( "RENAME FAILED, COULD NOT CREATE $dir" ); |
175 | 177 | $db->rollback(); |
176 | 178 | return; |
177 | 179 | } |
Index: trunk/phase3/maintenance/Maintenance.php |
— | — | @@ -526,6 +526,7 @@ |
527 | 527 | * to allow sysadmins to explicitly set one if they'd prefer to override |
528 | 528 | * defaults (or for people using Suhosin which yells at you for trying |
529 | 529 | * to disable the limits) |
| 530 | + * @return string |
530 | 531 | */ |
531 | 532 | public function memoryLimit() { |
532 | 533 | $limit = $this->getOption( 'memory-limit', 'max' ); |
— | — | @@ -852,6 +853,9 @@ |
853 | 854 | $wgDBpassword = $wgDBadminpassword; |
854 | 855 | |
855 | 856 | if ( $wgDBservers ) { |
| 857 | + /** |
| 858 | + * @var $wgDBservers array |
| 859 | + */ |
856 | 860 | foreach ( $wgDBservers as $i => $server ) { |
857 | 861 | $wgDBservers[$i]['user'] = $wgDBuser; |
858 | 862 | $wgDBservers[$i]['password'] = $wgDBpassword; |
— | — | @@ -980,6 +984,7 @@ |
981 | 985 | |
982 | 986 | /** |
983 | 987 | * Get the maintenance directory. |
| 988 | + * @return string |
984 | 989 | */ |
985 | 990 | protected function getDir() { |
986 | 991 | return dirname( __FILE__ ); |
— | — | @@ -1127,6 +1132,7 @@ |
1128 | 1133 | * Update the searchindex table for a given pageid |
1129 | 1134 | * @param $dbw Database: a database write handle |
1130 | 1135 | * @param $pageId Integer: the page ID to update. |
| 1136 | + * @return null|string |
1131 | 1137 | */ |
1132 | 1138 | public function updateSearchIndexForPage( $dbw, $pageId ) { |
1133 | 1139 | // Get current revision |
Index: trunk/phase3/maintenance/benchmarks/benchmarkPurge.php |
— | — | @@ -54,6 +54,7 @@ |
55 | 55 | * to benchmark Squid response times. |
56 | 56 | * @param $urls array A bunch of URLs to purge |
57 | 57 | * @param $trials int How many times to run the test? |
| 58 | + * @return string |
58 | 59 | */ |
59 | 60 | private function benchSquid( $urls, $trials = 1 ) { |
60 | 61 | $start = wfTime(); |
— | — | @@ -70,6 +71,7 @@ |
71 | 72 | /** |
72 | 73 | * Get an array of randomUrl()'s. |
73 | 74 | * @param $length int How many urls to add to the array |
| 75 | + * @return array |
74 | 76 | */ |
75 | 77 | private function randomUrlList( $length ) { |
76 | 78 | $list = array(); |
— | — | @@ -82,6 +84,7 @@ |
83 | 85 | /** |
84 | 86 | * Return a random URL of the wiki. Not necessarily an actual title in the |
85 | 87 | * database, but at least a URL that looks like one. |
| 88 | + * @return string |
86 | 89 | */ |
87 | 90 | private function randomUrl() { |
88 | 91 | global $wgServer, $wgArticlePath; |
— | — | @@ -91,6 +94,7 @@ |
92 | 95 | /** |
93 | 96 | * Create a random title string (not necessarily a Title object). |
94 | 97 | * For use with randomUrl(). |
| 98 | + * @return string |
95 | 99 | */ |
96 | 100 | private function randomTitle() { |
97 | 101 | $str = ''; |
Index: trunk/phase3/maintenance/cleanupCaps.php |
— | — | @@ -88,9 +88,8 @@ |
89 | 89 | return $this->processRow( $row ); |
90 | 90 | } |
91 | 91 | } |
92 | | - } else { |
93 | | - $this->progress( 0 ); |
94 | 92 | } |
| 93 | + return $this->progress( 0 ); |
95 | 94 | } |
96 | 95 | } |
97 | 96 | |
Index: trunk/phase3/maintenance/dumpTextPass.php |
— | — | @@ -66,6 +66,11 @@ |
67 | 67 | var $checkpointJustWritten = false; |
68 | 68 | var $checkpointFiles = array(); |
69 | 69 | |
| 70 | + /** |
| 71 | + * @var DatabaseBase |
| 72 | + */ |
| 73 | + protected $db; |
| 74 | + |
70 | 75 | function initProgress( $history ) { |
71 | 76 | parent::initProgress(); |
72 | 77 | $this->timeOfCheckpoint = $this->startTime; |
— | — | @@ -169,7 +174,8 @@ |
170 | 175 | */ |
171 | 176 | function showReport() { |
172 | 177 | if ( !$this->prefetch ) { |
173 | | - return parent::showReport(); |
| 178 | + parent::showReport(); |
| 179 | + return; |
174 | 180 | } |
175 | 181 | |
176 | 182 | if ( $this->reporting ) { |
— | — | @@ -186,8 +192,7 @@ |
187 | 193 | $etats = wfTimestamp( TS_DB, intval( $eta ) ); |
188 | 194 | if ( $this->fetchCount ) { |
189 | 195 | $fetchRate = 100.0 * $this->prefetchCount / $this->fetchCount; |
190 | | - } |
191 | | - else { |
| 196 | + } else { |
192 | 197 | $fetchRate = '-'; |
193 | 198 | } |
194 | 199 | $pageRate = $this->pageCount / $deltaAll; |
— | — | @@ -201,8 +206,7 @@ |
202 | 207 | if ( $deltaPart ) { |
203 | 208 | if ( $this->fetchCountLast ) { |
204 | 209 | $fetchRatePart = 100.0 * $this->prefetchCountLast / $this->fetchCountLast; |
205 | | - } |
206 | | - else { |
| 210 | + } else { |
207 | 211 | $fetchRatePart = '-'; |
208 | 212 | } |
209 | 213 | $pageRatePart = $this->pageCountPart / $deltaPart; |
— | — | @@ -228,9 +232,9 @@ |
229 | 233 | |
230 | 234 | function checkIfTimeExceeded() { |
231 | 235 | if ( $this->maxTimeAllowed && ( $this->lastTime - $this->timeOfCheckpoint > $this->maxTimeAllowed ) ) { |
232 | | - return True; |
| 236 | + return true; |
233 | 237 | } |
234 | | - return False; |
| 238 | + return false; |
235 | 239 | } |
236 | 240 | |
237 | 241 | function finalOptionCheck() { |
— | — | @@ -286,7 +290,7 @@ |
287 | 291 | // we wrote some stuff after last checkpoint that needs renamed |
288 | 292 | if (file_exists($filenameList[0])) { |
289 | 293 | $newFilenames = array(); |
290 | | - # we might have just written the header and footer and had no |
| 294 | + # we might have just written the header and footer and had no |
291 | 295 | # pages or revisions written... perhaps they were all deleted |
292 | 296 | # there's no pageID 0 so we use that. the caller is responsible |
293 | 297 | # for deciding what to do with a file containing only the |
— | — | @@ -332,7 +336,6 @@ |
333 | 337 | } |
334 | 338 | |
335 | 339 | private function doGetText( $id ) { |
336 | | - |
337 | 340 | $id = intval( $id ); |
338 | 341 | $this->failures = 0; |
339 | 342 | $ex = new MWException( "Graceful storage failure" ); |
— | — | @@ -345,9 +348,9 @@ |
346 | 349 | $this->closeSpawn(); |
347 | 350 | $this->openSpawn(); |
348 | 351 | } |
349 | | - $text = $this->getTextSpawned( $id ); |
| 352 | + $text = $this->getTextSpawned( $id ); |
350 | 353 | } else { |
351 | | - $text = $this->getTextDbSafe( $id ); |
| 354 | + $text = $this->getTextDbSafe( $id ); |
352 | 355 | } |
353 | 356 | if ( $text === false ) { |
354 | 357 | $this->failures++; |
— | — | @@ -359,11 +362,10 @@ |
360 | 363 | $this->failedTextRetrievals++; |
361 | 364 | if ($this->failedTextRetrievals > $this->maxConsecutiveFailedTextRetrievals) { |
362 | 365 | throw $ex; |
363 | | - } |
364 | | - else { |
| 366 | + } else { |
365 | 367 | // would be nice to return something better to the caller someday, |
366 | 368 | // log what we know about the failure and about the revision |
367 | | - return(""); |
| 369 | + return ""; |
368 | 370 | } |
369 | 371 | } else { |
370 | 372 | $this->progress( "Error $this->failures " . |
— | — | @@ -373,16 +375,18 @@ |
374 | 376 | } |
375 | 377 | } else { |
376 | 378 | $this->failedTextRetrievals= 0; |
377 | | - return( $text ); |
| 379 | + return $text; |
378 | 380 | } |
379 | 381 | } |
380 | | - |
| 382 | + return ''; |
381 | 383 | } |
382 | 384 | |
383 | 385 | /** |
384 | 386 | * Fetch a text revision from the database, retrying in case of failure. |
385 | 387 | * This may survive some transitory errors by reconnecting, but |
386 | 388 | * may not survive a long-term server outage. |
| 389 | + * |
| 390 | + * FIXME: WTF? Why is it using a loop and then returning unconditionally? |
387 | 391 | */ |
388 | 392 | private function getTextDbSafe( $id ) { |
389 | 393 | while ( true ) { |
— | — | @@ -397,6 +401,8 @@ |
398 | 402 | |
399 | 403 | /** |
400 | 404 | * May throw a database error if, say, the server dies during query. |
| 405 | + * @param $id |
| 406 | + * @return bool|string |
401 | 407 | */ |
402 | 408 | private function getTextDb( $id ) { |
403 | 409 | global $wgContLang; |
— | — | @@ -584,15 +590,15 @@ |
585 | 591 | $this->egress->writeClosePage( $this->buffer ); |
586 | 592 | // nasty hack, we can't just write the chardata after the |
587 | 593 | // page tag, it will include leading blanks from the next line |
588 | | - $this->egress->sink->write("\n"); |
589 | | - |
| 594 | + $this->egress->sink->write("\n"); |
| 595 | + |
590 | 596 | $this->buffer = $this->xmlwriterobj->closeStream(); |
591 | 597 | $this->egress->writeCloseStream( $this->buffer ); |
592 | 598 | |
593 | 599 | $this->buffer = ""; |
594 | 600 | $this->thisPage = ""; |
595 | 601 | // this could be more than one file if we had more than one output arg |
596 | | - $checkpointFilenames = array(); |
| 602 | + |
597 | 603 | $filenameList = (array)$this->egress->getFilenames(); |
598 | 604 | $newFilenames = array(); |
599 | 605 | $firstPageID = str_pad($this->firstPageWritten,9,"0",STR_PAD_LEFT); |
— | — | @@ -669,10 +675,10 @@ |
670 | 676 | pressure on the database. |
671 | 677 | (Requires the XMLReader extension) |
672 | 678 | --maxtime=<minutes> Write out checkpoint file after this many minutes (writing |
673 | | - out complete page, closing xml file properly, and opening new one |
| 679 | + out complete page, closing xml file properly, and opening new one |
674 | 680 | with header). This option requires the checkpointfile option. |
675 | 681 | --checkpointfile=<filenamepattern> Use this string for checkpoint filenames, |
676 | | - substituting first pageid written for the first %s (required) and the |
| 682 | + substituting first pageid written for the first %s (required) and the |
677 | 683 | last pageid written for the second %s if it exists. |
678 | 684 | --quiet Don't dump status reports to stderr. |
679 | 685 | --report=n Report position and speed after every n pages processed. |
Index: trunk/phase3/maintenance/backupPrefetch.inc |
— | — | @@ -133,6 +133,7 @@ |
134 | 134 | |
135 | 135 | /** |
136 | 136 | * @access private |
| 137 | + * @return string |
137 | 138 | */ |
138 | 139 | function nextText() { |
139 | 140 | $this->skipTo( 'text' ); |
— | — | @@ -141,6 +142,9 @@ |
142 | 143 | |
143 | 144 | /** |
144 | 145 | * @access private |
| 146 | + * @param $name string |
| 147 | + * @param $parent string |
| 148 | + * @return bool|null |
145 | 149 | */ |
146 | 150 | function skipTo( $name, $parent = 'page' ) { |
147 | 151 | if ( $this->atEnd ) { |
— | — | @@ -192,6 +196,7 @@ |
193 | 197 | |
194 | 198 | /** |
195 | 199 | * @access private |
| 200 | + * @return null |
196 | 201 | */ |
197 | 202 | function close() { |
198 | 203 | $this->reader->close(); |