Index: branches/REL1_19/extensions/WikimediaMaintenance/cleanupTitles64966.php |
— | — | @@ -1,160 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Script to clean up broken, unparseable titles. |
5 | | - * |
6 | | - * Usage: php cleanupTitles.php [--fix] |
7 | | - * Options: |
8 | | - * --fix Actually clean up titles; otherwise just checks for them |
9 | | - * |
10 | | - * Copyright (C) 2005 Brion Vibber <brion@pobox.com> |
11 | | - * http://www.mediawiki.org/ |
12 | | - * |
13 | | - * This program is free software; you can redistribute it and/or modify |
14 | | - * it under the terms of the GNU General Public License as published by |
15 | | - * the Free Software Foundation; either version 2 of the License, or |
16 | | - * (at your option) any later version. |
17 | | - * |
18 | | - * This program is distributed in the hope that it will be useful, |
19 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 | | - * GNU General Public License for more details. |
22 | | - * |
23 | | - * You should have received a copy of the GNU General Public License along |
24 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
25 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
26 | | - * http://www.gnu.org/copyleft/gpl.html |
27 | | - * |
28 | | - * @author Brion Vibber <brion at pobox.com> |
29 | | - * @ingroup Maintenance |
30 | | - */ |
31 | | - |
32 | | -// Detect $IP |
33 | | -$IP = getenv( 'MW_INSTALL_PATH' ); |
34 | | -if ( $IP === false ) { |
35 | | - $IP = dirname( __FILE__ ) . '/../..'; |
36 | | -} |
37 | | - |
38 | | -require_once( "$IP/maintenance/cleanupTable.inc" ); |
39 | | - |
40 | | -class TitleCleanup extends TableCleanup { |
41 | | - public function __construct() { |
42 | | - parent::__construct(); |
43 | | - $this->mDescription = "Script to clean up broken, unparseable titles"; |
44 | | - } |
45 | | - |
46 | | - protected function processRow( $row ) { |
47 | | - global $wgContLang; |
48 | | - $display = Title::makeName( $row->page_namespace, $row->page_title ); |
49 | | - $verified = $wgContLang->normalize( $display ); |
50 | | - $title = Title::newFromText( $verified ); |
51 | | - |
52 | | - if( !is_null( $title ) |
53 | | - && $title->canExist() |
54 | | - && $title->getNamespace() == $row->page_namespace |
55 | | - && $title->getDBkey() === $row->page_title ) |
56 | | - { |
57 | | - return $this->progress( 0 ); // all is fine |
58 | | - } |
59 | | - |
60 | | - if( $row->page_namespace == NS_FILE && $this->fileExists( $row->page_title ) ) { |
61 | | - $this->output( "file $row->page_title needs cleanup, please run cleanupImages.php.\n" ); |
62 | | - return $this->progress( 0 ); |
63 | | - } elseif( is_null( $title ) ) { |
64 | | - $this->output( "page $row->page_id ($display) is illegal.\n" ); |
65 | | - $this->moveIllegalPage( $row ); |
66 | | - return $this->progress( 1 ); |
67 | | - } else { |
68 | | - $this->output( "page $row->page_id ($display) doesn't match self.\n" ); |
69 | | - $this->moveInconsistentPage( $row, $title ); |
70 | | - return $this->progress( 1 ); |
71 | | - } |
72 | | - } |
73 | | - |
74 | | - protected function fileExists( $name ) { |
75 | | - // XXX: Doesn't actually check for file existence, just presence of image record. |
76 | | - // This is reasonable, since cleanupImages.php only iterates over the image table. |
77 | | - $dbr = wfGetDB( DB_SLAVE ); |
78 | | - $row = $dbr->selectRow( 'image', array( 'img_name' ), array( 'img_name' => $name ), __METHOD__ ); |
79 | | - return $row !== false; |
80 | | - } |
81 | | - |
82 | | - protected function moveIllegalPage( $row ) { |
83 | | - $legal = 'A-Za-z0-9_/\\\\-'; |
84 | | - $legalized = preg_replace_callback( "!([^$legal])!", |
85 | | - array( &$this, 'hexChar' ), |
86 | | - $row->page_title ); |
87 | | - if( $legalized == '.' ) $legalized = '(dot)'; |
88 | | - if( $legalized == '_' ) $legalized = '(space)'; |
89 | | - $legalized = 'Broken/' . $legalized; |
90 | | - |
91 | | - $title = Title::newFromText( $legalized ); |
92 | | - if( is_null( $title ) ) { |
93 | | - $clean = 'Broken/id:' . $row->page_id; |
94 | | - $this->output( "Couldn't legalize; form '$legalized' still invalid; using '$clean'\n" ); |
95 | | - $title = Title::newFromText( $clean ); |
96 | | - } elseif( $title->exists() ) { |
97 | | - $clean = 'Broken/id:' . $row->page_id; |
98 | | - $this->output( "Legalized for '$legalized' exists; using '$clean'\n" ); |
99 | | - $title = Title::newFromText( $clean ); |
100 | | - } |
101 | | - |
102 | | - $dest = $title->getDBkey(); |
103 | | - if( $this->dryrun ) { |
104 | | - $this->output( "DRY RUN: would rename $row->page_id ($row->page_namespace,'$row->page_title') to ($row->page_namespace,'$dest')\n" ); |
105 | | - } else { |
106 | | - $this->output( "renaming $row->page_id ($row->page_namespace,'$row->page_title') to ($row->page_namespace,'$dest')\n" ); |
107 | | - $dbw = wfGetDB( DB_MASTER ); |
108 | | - $dbw->update( 'page', |
109 | | - array( 'page_title' => $dest ), |
110 | | - array( 'page_id' => $row->page_id ), |
111 | | - __METHOD__ ); |
112 | | - } |
113 | | - } |
114 | | - |
115 | | - protected function moveInconsistentPage( $row, $title ) { |
116 | | - if( $title->exists() || $title->getInterwiki() || !$title->canExist() ) { |
117 | | - if( $title->getInterwiki() || !$title->canExist() ) { |
118 | | - $prior = $title->getPrefixedDbKey(); |
119 | | - } else { |
120 | | - $prior = $title->getDBkey(); |
121 | | - } |
122 | | - |
123 | | - # Old cleanupTitles could move articles there. See bug 23147. |
124 | | - $ns = $row->page_namespace; |
125 | | - if ( $ns < 0) $ns = 0; |
126 | | - |
127 | | - $clean = 'Broken/' . $prior; |
128 | | - $verified = Title::makeTitleSafe( $ns, $clean ); |
129 | | - if( $verified->exists() ) { |
130 | | - $blah = "Broken/id:" . $row->page_id; |
131 | | - $this->output( "Couldn't legalize; form '$clean' exists; using '$blah'\n" ); |
132 | | - $verified = Title::makeTitleSafe( $ns, $blah ); |
133 | | - } |
134 | | - $title = $verified; |
135 | | - } |
136 | | - if( is_null( $title ) ) { |
137 | | - $this->error( "Something awry; empty title.", true ); |
138 | | - } |
139 | | - $ns = $title->getNamespace(); |
140 | | - $dest = $title->getDBkey(); |
141 | | - |
142 | | - if( $this->dryrun ) { |
143 | | - $this->output( "DRY RUN: would rename $row->page_id ($row->page_namespace,'$row->page_title') to ($ns,'$dest')\n" ); |
144 | | - } else { |
145 | | - $this->output( "renaming $row->page_id ($row->page_namespace,'$row->page_title') to ($ns,'$dest')\n" ); |
146 | | - $dbw = wfGetDB( DB_MASTER ); |
147 | | - $dbw->update( 'page', |
148 | | - array( |
149 | | - 'page_namespace' => $ns, |
150 | | - 'page_title' => $dest |
151 | | - ), |
152 | | - array( 'page_id' => $row->page_id ), |
153 | | - __METHOD__ ); |
154 | | - $linkCache = LinkCache::singleton(); |
155 | | - $linkCache->clear(); |
156 | | - } |
157 | | - } |
158 | | -} |
159 | | - |
160 | | -$maintClass = "TitleCleanup"; |
161 | | -require_once( DO_MAINTENANCE ); |
Index: branches/REL1_19/extensions/WikimediaMaintenance/x-mctest.php |
— | — | @@ -1,84 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * This script makes several 'set', 'incr' and 'get' requests on every |
5 | | - * memcached server and shows a report. |
6 | | - * |
7 | | - * This program is free software; you can redistribute it and/or modify |
8 | | - * it under the terms of the GNU General Public License as published by |
9 | | - * the Free Software Foundation; either version 2 of the License, or |
10 | | - * (at your option) any later version. |
11 | | - * |
12 | | - * This program is distributed in the hope that it will be useful, |
13 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | | - * GNU General Public License for more details. |
16 | | - * |
17 | | - * You should have received a copy of the GNU General Public License along |
18 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
19 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
20 | | - * http://www.gnu.org/copyleft/gpl.html |
21 | | - * |
22 | | - * @ingroup Maintenance |
23 | | - */ |
24 | | - |
25 | | -require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' ); |
26 | | - |
27 | | -class mcTest extends WikimediaMaintenance { |
28 | | - public function __construct() { |
29 | | - parent::__construct(); |
30 | | - $this->mDescription = "Makes several 'set', 'incr' and 'get' requests on every" |
31 | | - . " memcached server and shows a report"; |
32 | | - $this->addOption( 'i', 'Number of iterations', false, true ); |
33 | | - $this->addArg( 'server', 'Memcached server to test', false ); |
34 | | - } |
35 | | - |
36 | | - public function execute() { |
37 | | - global $wgMemCachedServers; |
38 | | - |
39 | | - $iterations = $this->getOption( 'i', 100 ); |
40 | | - if( $this->hasArg() ) |
41 | | - $wgMemCachedServers = array( $this->getArg() ); |
42 | | - |
43 | | - foreach ( $wgMemCachedServers as $server ) { |
44 | | - $this->output( $server . " " ); |
45 | | - $mcc = new MemCachedClientforWiki( array('persistant' => true) ); |
46 | | - $mcc->set_debug(true); |
47 | | - $mcc->set_servers( array( $server ) ); |
48 | | - $set = 0; |
49 | | - $incr = 0; |
50 | | - $get = 0; |
51 | | - $time_start = $this->microtime_float(); |
52 | | - for ( $i=1; $i<=$iterations; $i++ ) { |
53 | | - if ( !is_null( $mcc->set( "test$i", $i ) ) ) { |
54 | | - $set++; |
55 | | - } |
56 | | - } |
57 | | - for ( $i=1; $i<=$iterations; $i++ ) { |
58 | | - if ( !is_null( $mcc->incr( "test$i", $i ) ) ) { |
59 | | - $incr++; |
60 | | - } |
61 | | - } |
62 | | - for ( $i=1; $i<=$iterations; $i++ ) { |
63 | | - $value = $mcc->get( "test$i" ); |
64 | | - if ( $value == $i*2 ) { |
65 | | - $get++; |
66 | | - } |
67 | | - } |
68 | | - $exectime = $this->microtime_float() - $time_start; |
69 | | - |
70 | | - $this->output( "set: $set incr: $incr get: $get time: $exectime\n" ); |
71 | | - } |
72 | | - } |
73 | | - |
74 | | - /** |
75 | | - * Return microtime() as a float |
76 | | - * @return float |
77 | | - */ |
78 | | - private function microtime_float() { |
79 | | - list($usec, $sec) = explode(" ", microtime()); |
80 | | - return ((float)$usec + (float)$sec); |
81 | | - } |
82 | | -} |
83 | | - |
84 | | -$maintClass = "mcTest"; |
85 | | -require_once( DO_MAINTENANCE ); |
Index: branches/REL1_19/extensions/WikimediaMaintenance/namespaceDupesWT.php |
— | — | @@ -1,314 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Check for articles to fix after adding/deleting namespaces |
5 | | - * |
6 | | - * Copyright (C) 2005-2007 Brion Vibber <brion@pobox.com> |
7 | | - * http://www.mediawiki.org/ |
8 | | - * |
9 | | - * This program is free software; you can redistribute it and/or modify |
10 | | - * it under the terms of the GNU General Public License as published by |
11 | | - * the Free Software Foundation; either version 2 of the License, or |
12 | | - * (at your option) any later version. |
13 | | - * |
14 | | - * This program is distributed in the hope that it will be useful, |
15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | | - * GNU General Public License for more details. |
18 | | - * |
19 | | - * You should have received a copy of the GNU General Public License along |
20 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
21 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
22 | | - * http://www.gnu.org/copyleft/gpl.html |
23 | | - * |
24 | | - * @ingroup Maintenance |
25 | | - */ |
26 | | - |
27 | | -require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' ); |
28 | | - |
29 | | -class NamespaceConflictChecker extends WikimediaMaintenance { |
30 | | - |
31 | | - /** |
32 | | - * @var DatabaseBase |
33 | | - */ |
34 | | - protected $db; |
35 | | - |
36 | | - public function __construct() { |
37 | | - parent::__construct(); |
38 | | - $this->mDescription = ""; |
39 | | - $this->addOption( 'fix', 'Attempt to automatically fix errors' ); |
40 | | - $this->addOption( 'suffix', "Dupes will be renamed with correct namespace with\n" . |
41 | | - "\t\t<text> Appended after the article name", false, true ); |
42 | | - $this->addOption( 'prefix', "Do an explicit check for the given title prefix\n" . |
43 | | - "\t\tappended after the article name", false, true ); |
44 | | - } |
45 | | - |
46 | | - public function execute() { |
47 | | - global $wgTitle; |
48 | | - |
49 | | - $this->db = wfGetDB( DB_MASTER ); |
50 | | - $wgTitle = Title::newFromText( 'Namespace title conflict cleanup script' ); |
51 | | - |
52 | | - $fix = $this->hasOption( 'fix' ); |
53 | | - $suffix = $this->getOption( 'suffix', '' ); |
54 | | - $prefix = $this->getOption( 'prefix', '' ); |
55 | | - $key = intval( $this->getOption( 'key', 0 ) ); |
56 | | - |
57 | | - if( $prefix ) { |
58 | | - $retval = $this->checkPrefix( $key, $prefix, $fix, $suffix ); |
59 | | - } else { |
60 | | - $retval = $this->checkAll( $fix, $suffix ); |
61 | | - } |
62 | | - |
63 | | - if( $retval ) { |
64 | | - $this->output( "\nLooks good!\n" ); |
65 | | - } else { |
66 | | - $this->output( "\nOh noeees\n" ); |
67 | | - } |
68 | | - } |
69 | | - |
70 | | - /** |
71 | | - * @todo Document |
72 | | - * @param $fix bool Whether or not to fix broken entries |
73 | | - * @param $suffix String Suffix to append to renamed articles |
74 | | - */ |
75 | | - private function checkAll( $fix, $suffix = '' ) { |
76 | | - global $wgContLang, $wgNamespaceAliases, $wgCanonicalNamespaceNames; |
77 | | - global $wgCapitalLinks; |
78 | | - |
79 | | - $spaces = array(); |
80 | | - |
81 | | - // List interwikis first, so they'll be overridden |
82 | | - // by any conflicting local namespaces. |
83 | | - foreach( $this->getInterwikiList() as $prefix ) { |
84 | | - $name = $wgContLang->ucfirst( $prefix ); |
85 | | - $spaces[$name] = 0; |
86 | | - } |
87 | | - |
88 | | - // Now pull in all canonical and alias namespaces... |
89 | | - foreach( $wgCanonicalNamespaceNames as $ns => $name ) { |
90 | | - // This includes $wgExtraNamespaces |
91 | | - if( $name !== '' ) { |
92 | | - $spaces[$name] = $ns; |
93 | | - } |
94 | | - } |
95 | | - foreach( $wgContLang->getNamespaces() as $ns => $name ) { |
96 | | - if( $name !== '' ) { |
97 | | - $spaces[$name] = $ns; |
98 | | - } |
99 | | - } |
100 | | - foreach( $wgNamespaceAliases as $name => $ns ) { |
101 | | - $spaces[$name] = $ns; |
102 | | - } |
103 | | - foreach( $wgContLang->getNamespaceAliases() as $name => $ns ) { |
104 | | - $spaces[$name] = $ns; |
105 | | - } |
106 | | - |
107 | | - // We'll need to check for lowercase keys as well, |
108 | | - // since we're doing case-sensitive searches in the db. |
109 | | - foreach( $spaces as $name => $ns ) { |
110 | | - $moreNames = array(); |
111 | | - $moreNames[] = $wgContLang->uc( $name ); |
112 | | - $moreNames[] = $wgContLang->ucfirst( $wgContLang->lc( $name ) ); |
113 | | - $moreNames[] = $wgContLang->ucwords( $name ); |
114 | | - $moreNames[] = $wgContLang->ucwords( $wgContLang->lc( $name ) ); |
115 | | - $moreNames[] = $wgContLang->ucwordbreaks( $name ); |
116 | | - $moreNames[] = $wgContLang->ucwordbreaks( $wgContLang->lc( $name ) ); |
117 | | - if( !$wgCapitalLinks ) { |
118 | | - foreach( $moreNames as $altName ) { |
119 | | - $moreNames[] = $wgContLang->lcfirst( $altName ); |
120 | | - } |
121 | | - $moreNames[] = $wgContLang->lcfirst( $name ); |
122 | | - } |
123 | | - foreach( array_unique( $moreNames ) as $altName ) { |
124 | | - if( $altName !== $name ) { |
125 | | - $spaces[$altName] = $ns; |
126 | | - } |
127 | | - } |
128 | | - } |
129 | | - |
130 | | - ksort( $spaces ); |
131 | | - asort( $spaces ); |
132 | | - |
133 | | - $ok = true; |
134 | | - foreach( $spaces as $name => $ns ) { |
135 | | - $ok = $this->checkNamespace( $ns, $name, $fix, $suffix ) && $ok; |
136 | | - } |
137 | | - return $ok; |
138 | | - } |
139 | | - |
140 | | - /** |
141 | | - * Get the interwiki list |
142 | | - * @todo Needs to respect interwiki cache! |
143 | | - * @return array |
144 | | - */ |
145 | | - private function getInterwikiList() { |
146 | | - $result = $this->db->select( 'interwiki', array( 'iw_prefix' ) ); |
147 | | - $prefixes = array(); |
148 | | - foreach( $result as $row ) { |
149 | | - $prefixes[] = $row->iw_prefix; |
150 | | - } |
151 | | - $this->db->freeResult( $result ); |
152 | | - return $prefixes; |
153 | | - } |
154 | | - |
155 | | - /** |
156 | | - * @todo Document |
157 | | - * @param $ns int A namespace id |
158 | | - * @param $name String |
159 | | - * @param $fix bool Whether to fix broken entries |
160 | | - * @param $suffix String Suffix to append to renamed articles |
161 | | - */ |
162 | | - private function checkNamespace( $ns, $name, $fix, $suffix = '' ) { |
163 | | - $conflicts = $this->getConflicts( $ns, $name ); |
164 | | - $count = count( $conflicts ); |
165 | | - if( $count == 0 ) { |
166 | | - return true; |
167 | | - } |
168 | | - |
169 | | - $ok = true; |
170 | | - foreach( $conflicts as $row ) { |
171 | | - $resolvable = $this->reportConflict( $row, $suffix ); |
172 | | - $ok = $ok && $resolvable; |
173 | | - if( $fix && ( $resolvable || $suffix != '' ) ) { |
174 | | - $ok = $this->resolveConflict( $row, $resolvable, $suffix ) && $ok; |
175 | | - } |
176 | | - } |
177 | | - return $ok; |
178 | | - } |
179 | | - |
180 | | - /** |
181 | | - * @todo: do this for reals |
182 | | - */ |
183 | | - private function checkPrefix( $key, $prefix, $fix, $suffix = '' ) { |
184 | | - $this->output( "Checking prefix \"$prefix\" vs namespace $key\n" ); |
185 | | - return $this->checkNamespace( $key, $prefix, $fix, $suffix ); |
186 | | - } |
187 | | - |
188 | | - /** |
189 | | - * Find pages in mainspace that have a prefix of the new namespace |
190 | | - * so we know titles that will need migrating |
191 | | - * @param $ns int Namespace id (id for new namespace?) |
192 | | - * @param $name String Prefix that is being made a namespace |
193 | | - */ |
194 | | - private function getConflicts( $ns, $name ) { |
195 | | - $page = 'page'; |
196 | | - $table = $this->db->tableName( $page ); |
197 | | - |
198 | | - $prefix = $this->db->strencode( $name ); |
199 | | - $encNamespace = $this->db->addQuotes( $ns ); |
200 | | - |
201 | | - $titleSql = "TRIM(LEADING '$prefix:' FROM {$page}_title)"; |
202 | | - if( $ns == 0 ) { |
203 | | - // An interwiki; try an alternate encoding with '-' for ':' |
204 | | - $titleSql = $this->db->buildConcat( array( "'$prefix-'", $titleSql ) ); |
205 | | - } |
206 | | - |
207 | | - $sql = "SELECT {$page}_id AS id, |
208 | | - {$page}_title AS oldtitle, |
209 | | - $encNamespace + {$page}_namespace AS namespace, |
210 | | - $titleSql AS title, |
211 | | - {$page}_namespace AS oldnamespace |
212 | | - FROM {$table} |
213 | | - WHERE ( {$page}_namespace=0 OR {$page}_namespace=1 ) |
214 | | - AND {$page}_title " . $this->db->buildLike( $name . ':', $this->db->anyString() ); |
215 | | - |
216 | | - $result = $this->db->query( $sql, __METHOD__ ); |
217 | | - |
218 | | - $set = array(); |
219 | | - foreach( $result as $row ) { |
220 | | - $set[] = $row; |
221 | | - } |
222 | | - |
223 | | - return $set; |
224 | | - } |
225 | | - |
226 | | - /** |
227 | | - * Report any conflicts we find |
228 | | - */ |
229 | | - private function reportConflict( $row, $suffix ) { |
230 | | - $newTitle = Title::makeTitleSafe( $row->namespace, $row->title ); |
231 | | - if( is_null($newTitle) || !$newTitle->canExist() ) { |
232 | | - // Title is also an illegal title... |
233 | | - // For the moment we'll let these slide to cleanupTitles or whoever. |
234 | | - $this->output( sprintf( "... %d (%d,\"%s\")\n", |
235 | | - $row->id, |
236 | | - $row->oldnamespace, |
237 | | - $row->oldtitle ) ); |
238 | | - $this->output( "... *** cannot resolve automatically; illegal title ***\n" ); |
239 | | - return false; |
240 | | - } |
241 | | - |
242 | | - $this->output( sprintf( "... %d (%d,\"%s\") -> (%d,\"%s\") [[%s]]\n", |
243 | | - $row->id, |
244 | | - $row->oldnamespace, |
245 | | - $row->oldtitle, |
246 | | - $newTitle->getNamespace(), |
247 | | - $newTitle->getDBkey(), |
248 | | - $newTitle->getPrefixedText() ) ); |
249 | | - |
250 | | - $id = $newTitle->getArticleId(); |
251 | | - if( $id ) { |
252 | | - $this->output( "... *** cannot resolve automatically; page exists with ID $id ***\n" ); |
253 | | - return false; |
254 | | - } else { |
255 | | - return true; |
256 | | - } |
257 | | - } |
258 | | - |
259 | | - /** |
260 | | - * Resolve any conflicts |
261 | | - * @param $row Row from the page table to fix |
262 | | - * @param $resolveable bool |
263 | | - * @param $suffix String Suffix to append to the fixed page |
264 | | - */ |
265 | | - private function resolveConflict( $row, $resolvable, $suffix ) { |
266 | | - if( !$resolvable ) { |
267 | | - $this->output( "... *** old title {$row->title}\n" ); |
268 | | - while( true ) { |
269 | | - $row->title .= $suffix; |
270 | | - $this->output( "... *** new title {$row->title}\n" ); |
271 | | - $title = Title::makeTitleSafe( $row->namespace, $row->title ); |
272 | | - if ( ! $title ) { |
273 | | - $this->output( "... !!! invalid title\n" ); |
274 | | - return false; |
275 | | - } |
276 | | - $id = $title->getArticleId(); |
277 | | - if ( $id ) { |
278 | | - $this->output( "... *** page exists with ID $id ***\n" ); |
279 | | - } else { |
280 | | - break; |
281 | | - } |
282 | | - } |
283 | | - $this->output( "... *** using suffixed form [[" . $title->getPrefixedText() . "]] ***\n" ); |
284 | | - } |
285 | | - $this->resolveConflictOn( $row, 'page', 'page' ); |
286 | | - return true; |
287 | | - } |
288 | | - |
289 | | - /** |
290 | | - * Resolve a given conflict |
291 | | - * @param $row Row from the old broken entry |
292 | | - * @param $table String Table to update |
293 | | - * @param $prefix String Prefix for column name, like page or ar |
294 | | - */ |
295 | | - private function resolveConflictOn( $row, $table, $prefix ) { |
296 | | - $this->output( "... resolving on $table... " ); |
297 | | - $newTitle = Title::makeTitleSafe( $row->namespace, $row->title ); |
298 | | - $this->db->update( $table, |
299 | | - array( |
300 | | - "{$prefix}_namespace" => $newTitle->getNamespace(), |
301 | | - "{$prefix}_title" => $newTitle->getDBkey(), |
302 | | - ), |
303 | | - array( |
304 | | - // "{$prefix}_namespace" => 0, |
305 | | - // "{$prefix}_title" => $row->oldtitle, |
306 | | - "{$prefix}_id" => $row->id, |
307 | | - ), |
308 | | - __METHOD__ ); |
309 | | - $this->output( "ok.\n" ); |
310 | | - return true; |
311 | | - } |
312 | | -} |
313 | | - |
314 | | -$maintClass = "NamespaceConflictChecker"; |
315 | | -require_once( DO_MAINTENANCE ); |
Index: branches/REL1_19/extensions/WikimediaMaintenance/jeluf.php |
— | — | @@ -1,103 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * This script starts pending jobs. |
5 | | - * |
6 | | - * Usage: |
7 | | - * --maxjobs <num> (default 10000) |
8 | | - * --type <job_cmd> |
9 | | - * |
10 | | - * This program is free software; you can redistribute it and/or modify |
11 | | - * it under the terms of the GNU General Public License as published by |
12 | | - * the Free Software Foundation; either version 2 of the License, or |
13 | | - * (at your option) any later version. |
14 | | - * |
15 | | - * This program is distributed in the hope that it will be useful, |
16 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | | - * GNU General Public License for more details. |
19 | | - * |
20 | | - * You should have received a copy of the GNU General Public License along |
21 | | - * with this program; if not, write to the Free Software Foundation, Inc., |
22 | | - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
23 | | - * http://www.gnu.org/copyleft/gpl.html |
24 | | - * |
25 | | - * @ingroup Maintenance |
26 | | - */ |
27 | | - |
28 | | -require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' ); |
29 | | - |
30 | | -class RunJobs extends WikimediaMaintenance { |
31 | | - public function __construct() { |
32 | | - parent::__construct(); |
33 | | - $this->mDescription = "Run pending jobs"; |
34 | | - $this->addOption( 'maxjobs', 'Maximum number of jobs to run', false, true ); |
35 | | - $this->addOption( 'type', 'Type of job to run', false, true ); |
36 | | - $this->addOption( 'procs', 'Number of processes to use', false, true ); |
37 | | - } |
38 | | - |
39 | | - public function memoryLimit() { |
40 | | - // Don't eat all memory on the machine if we get a bad job. |
41 | | - return "150M"; |
42 | | - } |
43 | | - |
44 | | - public function execute() { |
45 | | - global $wgTitle; |
46 | | - if ( $this->hasOption( 'procs' ) ) { |
47 | | - $procs = intval( $this->getOption('procs') ); |
48 | | - if ( $procs < 1 || $procs > 1000 ) { |
49 | | - $this->error( "Invalid argument to --procs", true ); |
50 | | - } |
51 | | - $fc = new ForkController( $procs ); |
52 | | - if ( $fc->start( $procs ) != 'child' ) { |
53 | | - exit( 0 ); |
54 | | - } |
55 | | - } |
56 | | - $maxJobs = $this->getOption( 'maxjobs', 10000 ); |
57 | | - $type = $this->getOption( 'type', false ); |
58 | | - $wgTitle = Title::newFromText( 'RunJobs.php' ); |
59 | | - $dbw = wfGetDB( DB_MASTER ); |
60 | | - $n = 0; |
61 | | - $conds = ''; |
62 | | - if ($type !== false) |
63 | | - $conds = "job_cmd = " . $dbw->addQuotes($type); |
64 | | - |
65 | | - while ( $dbw->selectField( 'job', 'job_id', $conds, 'runJobs.php' ) ) { |
66 | | - $offset=0; |
67 | | - for (;;) { |
68 | | - $job = ($type == false) ? |
69 | | - Job::pop($offset) |
70 | | - : Job::pop_type($type); |
71 | | - |
72 | | - if ($job == false) |
73 | | - break; |
74 | | - |
75 | | - wfWaitForSlaves( 5 ); |
76 | | - $t = microtime( true ); |
77 | | - $offset=$job->id; |
78 | | - $status = $job->run(); |
79 | | - $t = microtime( true ) - $t; |
80 | | - $timeMs = intval( $t * 1000 ); |
81 | | - if ( !$status ) { |
82 | | - $this->runJobsLog( $job->toString() . " t=$timeMs error={$job->error}" ); |
83 | | - } else { |
84 | | - $this->runJobsLog( $job->toString() . " t=$timeMs good" ); |
85 | | - } |
86 | | - if ( $maxJobs && ++$n > $maxJobs ) { |
87 | | - break 2; |
88 | | - } |
89 | | - } |
90 | | - } |
91 | | - } |
92 | | - |
93 | | - /** |
94 | | - * Log the job message |
95 | | - * @param $msg String The message to log |
96 | | - */ |
97 | | - private function runJobsLog( $msg ) { |
98 | | - $this->output( wfTimestamp( TS_DB ) . " $msg\n" ); |
99 | | - wfDebugLog( 'runJobs', $msg ); |
100 | | - } |
101 | | -} |
102 | | - |
103 | | -$maintClass = "RunJobs"; |
104 | | -require_once( DO_MAINTENANCE ); |