Index: branches/REL1_17/phase3/maintenance/renameDbPrefix.php |
— | — | @@ -65,7 +65,7 @@ |
66 | 66 | $count = 0; |
67 | 67 | |
68 | 68 | $dbw = wfGetDB( DB_MASTER ); |
69 | | - $res = $dbw->query( "SHOW TABLES LIKE '" . $dbw->escapeLike( $old ) . "%'" ); |
| 69 | + $res = $dbw->query( "SHOW TABLES " . $dbw->buildLike( $old, $dbw->anyString() ) ); |
70 | 70 | foreach ( $res as $row ) { |
71 | 71 | // XXX: odd syntax. MySQL outputs an oddly cased "Tables of X" |
72 | 72 | // sort of message. Best not to try $row->x stuff... |
Index: branches/REL1_17/phase3/maintenance/language/messages.inc |
— | — | @@ -2954,6 +2954,7 @@ |
2955 | 2955 | 'confirmemail_subject', |
2956 | 2956 | 'confirmemail_body', |
2957 | 2957 | 'confirmemail_body_changed', |
| 2958 | + 'confirmemail_body_set', |
2958 | 2959 | 'confirmemail_invalidated', |
2959 | 2960 | 'invalidateemail', |
2960 | 2961 | ), |
Index: branches/REL1_17/phase3/maintenance/dumpTextPass.php |
— | — | @@ -157,7 +157,7 @@ |
158 | 158 | $reader = new XMLReader(); |
159 | 159 | $reader->open( $this->input ); |
160 | 160 | $writer = new XMLWriter(); |
161 | | - $writer->openURI( 'php://stdout' ); |
| 161 | + $writer->openMemory(); |
162 | 162 | |
163 | 163 | |
164 | 164 | while ( $reader->read() ) { |
— | — | @@ -216,8 +216,8 @@ |
217 | 217 | } |
218 | 218 | $writer->text( $reader->value ); |
219 | 219 | } |
| 220 | + $this->sink->write( $writer->outputMemory() ); |
220 | 221 | } |
221 | | - $writer->flush(); |
222 | 222 | } |
223 | 223 | |
224 | 224 | function getText( $id ) { |
— | — | @@ -451,6 +451,8 @@ |
452 | 452 | --report=n Report position and speed after every n pages processed. |
453 | 453 | (Default: 100) |
454 | 454 | --server=h Force reading from MySQL server h |
| 455 | + --output=<type>:<file> Write to a file instead of stdout |
| 456 | + <type>s: file, gzip, bzip2, 7zip |
455 | 457 | --current Base ETA on number of pages in database instead of all revisions |
456 | 458 | --spawn Spawn a subprocess for loading text records |
457 | 459 | --help Display this help message |
Index: branches/REL1_17/phase3/includes/ImportXMLReader.php |
— | — | @@ -1,737 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * XML file reader for the page data importer |
5 | | - * |
6 | | - * @file |
7 | | - */ |
8 | | - |
9 | | -/** |
10 | | - * implements Special:Import |
11 | | - * @ingroup SpecialPage |
12 | | - */ |
13 | | -class WikiImporter { |
14 | | - private $reader = null; |
15 | | - private $mLogItemCallback, $mUploadCallback, $mRevisionCallback, $mPageCallback; |
16 | | - private $mSiteInfoCallback, $mTargetNamespace, $mPageOutCallback; |
17 | | - private $mDebug; |
18 | | - |
19 | | - /** |
20 | | - * Creates an ImportXMLReader drawing from the source provided |
21 | | - */ |
22 | | - function __construct( $source ) { |
23 | | - $this->reader = new XMLReader2(); |
24 | | - |
25 | | - stream_wrapper_register( 'uploadsource', 'UploadSourceAdapter' ); |
26 | | - $id = UploadSourceAdapter::registerSource( $source ); |
27 | | - $this->reader->open( "uploadsource://$id" ); |
28 | | - |
29 | | - // Default callbacks |
30 | | - $this->setRevisionCallback( array( $this, "importRevision" ) ); |
31 | | - $this->setUploadCallback( array( $this, 'importUpload' ) ); |
32 | | - $this->setLogItemCallback( array( $this, 'importLogItem' ) ); |
33 | | - $this->setPageOutCallback( array( $this, 'finishImportPage' ) ); |
34 | | - } |
35 | | - |
36 | | - private function throwXmlError( $err ) { |
37 | | - $this->debug( "FAILURE: $err" ); |
38 | | - wfDebug( "WikiImporter XML error: $err\n" ); |
39 | | - } |
40 | | - |
41 | | - private function debug( $data ) { |
42 | | - if( $this->mDebug ) { |
43 | | - wfDebug( "IMPORT: $data\n" ); |
44 | | - } |
45 | | - } |
46 | | - |
47 | | - private function warn( $data ) { |
48 | | - wfDebug( "IMPORT: $data\n" ); |
49 | | - } |
50 | | - |
51 | | - private function notice( $data ) { |
52 | | - global $wgCommandLineMode; |
53 | | - if( $wgCommandLineMode ) { |
54 | | - print "$data\n"; |
55 | | - } else { |
56 | | - global $wgOut; |
57 | | - $wgOut->addHTML( "<li>" . htmlspecialchars( $data ) . "</li>\n" ); |
58 | | - } |
59 | | - } |
60 | | - |
61 | | - /** |
62 | | - * Set debug mode... |
63 | | - */ |
64 | | - function setDebug( $debug ) { |
65 | | - $this->mDebug = $debug; |
66 | | - } |
67 | | - |
68 | | - /** |
69 | | - * Sets the action to perform as each new page in the stream is reached. |
70 | | - * @param $callback callback |
71 | | - * @return callback |
72 | | - */ |
73 | | - public function setPageCallback( $callback ) { |
74 | | - $previous = $this->mPageCallback; |
75 | | - $this->mPageCallback = $callback; |
76 | | - return $previous; |
77 | | - } |
78 | | - |
79 | | - /** |
80 | | - * Sets the action to perform as each page in the stream is completed. |
81 | | - * Callback accepts the page title (as a Title object), a second object |
82 | | - * with the original title form (in case it's been overridden into a |
83 | | - * local namespace), and a count of revisions. |
84 | | - * |
85 | | - * @param $callback callback |
86 | | - * @return callback |
87 | | - */ |
88 | | - public function setPageOutCallback( $callback ) { |
89 | | - $previous = $this->mPageOutCallback; |
90 | | - $this->mPageOutCallback = $callback; |
91 | | - return $previous; |
92 | | - } |
93 | | - |
94 | | - /** |
95 | | - * Sets the action to perform as each page revision is reached. |
96 | | - * @param $callback callback |
97 | | - * @return callback |
98 | | - */ |
99 | | - public function setRevisionCallback( $callback ) { |
100 | | - $previous = $this->mRevisionCallback; |
101 | | - $this->mRevisionCallback = $callback; |
102 | | - return $previous; |
103 | | - } |
104 | | - |
105 | | - /** |
106 | | - * Sets the action to perform as each file upload version is reached. |
107 | | - * @param $callback callback |
108 | | - * @return callback |
109 | | - */ |
110 | | - public function setUploadCallback( $callback ) { |
111 | | - $previous = $this->mUploadCallback; |
112 | | - $this->mUploadCallback = $callback; |
113 | | - return $previous; |
114 | | - } |
115 | | - |
116 | | - /** |
117 | | - * Sets the action to perform as each log item reached. |
118 | | - * @param $callback callback |
119 | | - * @return callback |
120 | | - */ |
121 | | - public function setLogItemCallback( $callback ) { |
122 | | - $previous = $this->mLogItemCallback; |
123 | | - $this->mLogItemCallback = $callback; |
124 | | - return $previous; |
125 | | - } |
126 | | - |
127 | | - /** |
128 | | - * Sets the action to perform when site info is encountered |
129 | | - * @param $callback callback |
130 | | - * @return callback |
131 | | - */ |
132 | | - public function setSiteInfoCallback( $callback ) { |
133 | | - $previous = $this->mSiteInfoCallback; |
134 | | - $this->mSiteInfoCallback = $callback; |
135 | | - return $previous; |
136 | | - } |
137 | | - |
138 | | - /** |
139 | | - * Set a target namespace to override the defaults |
140 | | - */ |
141 | | - public function setTargetNamespace( $namespace ) { |
142 | | - if( is_null( $namespace ) ) { |
143 | | - // Don't override namespaces |
144 | | - $this->mTargetNamespace = null; |
145 | | - } elseif( $namespace >= 0 ) { |
146 | | - // FIXME: Check for validity |
147 | | - $this->mTargetNamespace = intval( $namespace ); |
148 | | - } else { |
149 | | - return false; |
150 | | - } |
151 | | - } |
152 | | - |
153 | | - /** |
154 | | - * Default per-revision callback, performs the import. |
155 | | - * @param $revision WikiRevision |
156 | | - */ |
157 | | - public function importRevision( $revision ) { |
158 | | - $dbw = wfGetDB( DB_MASTER ); |
159 | | - return $dbw->deadlockLoop( array( $revision, 'importOldRevision' ) ); |
160 | | - } |
161 | | - |
162 | | - /** |
163 | | - * Default per-revision callback, performs the import. |
164 | | - * @param $rev WikiRevision |
165 | | - */ |
166 | | - public function importLogItem( $rev ) { |
167 | | - $dbw = wfGetDB( DB_MASTER ); |
168 | | - return $dbw->deadlockLoop( array( $rev, 'importLogItem' ) ); |
169 | | - } |
170 | | - |
171 | | - /** |
172 | | - * Dummy for now... |
173 | | - */ |
174 | | - public function importUpload( $revision ) { |
175 | | - //$dbw = wfGetDB( DB_MASTER ); |
176 | | - //return $dbw->deadlockLoop( array( $revision, 'importUpload' ) ); |
177 | | - return false; |
178 | | - } |
179 | | - |
180 | | - /** |
181 | | - * Mostly for hook use |
182 | | - */ |
183 | | - public function finishImportPage( $title, $origTitle, $revCount, $sRevCount, $pageInfo ) { |
184 | | - $args = func_get_args(); |
185 | | - return wfRunHooks( 'AfterImportPage', $args ); |
186 | | - } |
187 | | - |
188 | | - /** |
189 | | - * Alternate per-revision callback, for debugging. |
190 | | - * @param $revision WikiRevision |
191 | | - */ |
192 | | - public function debugRevisionHandler( &$revision ) { |
193 | | - $this->debug( "Got revision:" ); |
194 | | - if( is_object( $revision->title ) ) { |
195 | | - $this->debug( "-- Title: " . $revision->title->getPrefixedText() ); |
196 | | - } else { |
197 | | - $this->debug( "-- Title: <invalid>" ); |
198 | | - } |
199 | | - $this->debug( "-- User: " . $revision->user_text ); |
200 | | - $this->debug( "-- Timestamp: " . $revision->timestamp ); |
201 | | - $this->debug( "-- Comment: " . $revision->comment ); |
202 | | - $this->debug( "-- Text: " . $revision->text ); |
203 | | - } |
204 | | - |
205 | | - /** |
206 | | - * Notify the callback function when a new <page> is reached. |
207 | | - * @param $title Title |
208 | | - */ |
209 | | - function pageCallback( $title ) { |
210 | | - if( isset( $this->mPageCallback ) ) { |
211 | | - call_user_func( $this->mPageCallback, $title ); |
212 | | - } |
213 | | - } |
214 | | - |
215 | | - /** |
216 | | - * Notify the callback function when a </page> is closed. |
217 | | - * @param $title Title |
218 | | - * @param $origTitle Title |
219 | | - * @param $revCount Integer |
220 | | - * @param $sucCount Int: number of revisions for which callback returned true |
221 | | - * @param $pageInfo Array: associative array of page information |
222 | | - */ |
223 | | - private function pageOutCallback( $title, $origTitle, $revCount, $sucCount, $pageInfo ) { |
224 | | - if( isset( $this->mPageOutCallback ) ) { |
225 | | - $args = func_get_args(); |
226 | | - call_user_func_array( $this->mPageOutCallback, $args ); |
227 | | - } |
228 | | - } |
229 | | - |
230 | | - /** |
231 | | - * Notify the callback function of a revision |
232 | | - * @param $revision A WikiRevision object |
233 | | - */ |
234 | | - private function revisionCallback( $revision ) { |
235 | | - if ( isset( $this->mRevisionCallback ) ) { |
236 | | - return call_user_func_array( $this->mRevisionCallback, |
237 | | - array( $revision, $this ) ); |
238 | | - } else { |
239 | | - return false; |
240 | | - } |
241 | | - } |
242 | | - |
243 | | - /** |
244 | | - * Notify the callback function of a new log item |
245 | | - * @param $revision A WikiRevision object |
246 | | - */ |
247 | | - private function logItemCallback( $revision ) { |
248 | | - if ( isset( $this->mLogItemCallback ) ) { |
249 | | - return call_user_func_array( $this->mLogItemCallback, |
250 | | - array( $revision, $this ) ); |
251 | | - } else { |
252 | | - return false; |
253 | | - } |
254 | | - } |
255 | | - |
256 | | - /** |
257 | | - * Shouldn't something like this be built-in to XMLReader? |
258 | | - * Fetches text contents of the current element, assuming |
259 | | - * no sub-elements or such scary things. |
260 | | - * @return string |
261 | | - * @access private |
262 | | - */ |
263 | | - private function nodeContents() { |
264 | | - return $this->reader->nodeContents(); |
265 | | - } |
266 | | - |
267 | | - # -------------- |
268 | | - |
269 | | - /** Left in for debugging */ |
270 | | - private function dumpElement() { |
271 | | - static $lookup = null; |
272 | | - if (!$lookup) { |
273 | | - $xmlReaderConstants = array( |
274 | | - "NONE", |
275 | | - "ELEMENT", |
276 | | - "ATTRIBUTE", |
277 | | - "TEXT", |
278 | | - "CDATA", |
279 | | - "ENTITY_REF", |
280 | | - "ENTITY", |
281 | | - "PI", |
282 | | - "COMMENT", |
283 | | - "DOC", |
284 | | - "DOC_TYPE", |
285 | | - "DOC_FRAGMENT", |
286 | | - "NOTATION", |
287 | | - "WHITESPACE", |
288 | | - "SIGNIFICANT_WHITESPACE", |
289 | | - "END_ELEMENT", |
290 | | - "END_ENTITY", |
291 | | - "XML_DECLARATION", |
292 | | - ); |
293 | | - $lookup = array(); |
294 | | - |
295 | | - foreach( $xmlReaderConstants as $name ) { |
296 | | - $lookup[constant("XmlReader::$name")] = $name; |
297 | | - } |
298 | | - } |
299 | | - |
300 | | - print( var_dump( |
301 | | - $lookup[$this->reader->nodeType], |
302 | | - $this->reader->name, |
303 | | - $this->reader->value |
304 | | - )."\n\n" ); |
305 | | - } |
306 | | - |
307 | | - /** |
308 | | - * Primary entry point |
309 | | - */ |
310 | | - public function doImport() { |
311 | | - $this->reader->read(); |
312 | | - |
313 | | - if ( $this->reader->name != 'mediawiki' ) { |
314 | | - throw new MWException( "Expected <mediawiki> tag, got ". |
315 | | - $this->reader->name ); |
316 | | - } |
317 | | - $this->debug( "<mediawiki> tag is correct." ); |
318 | | - |
319 | | - $this->debug( "Starting primary dump processing loop." ); |
320 | | - |
321 | | - $keepReading = $this->reader->read(); |
322 | | - $skip = false; |
323 | | - while ( $keepReading ) { |
324 | | - $tag = $this->reader->name; |
325 | | - $type = $this->reader->nodeType; |
326 | | - |
327 | | - if ( !wfRunHooks( 'ImportHandleToplevelXMLTag', $this->reader ) ) { |
328 | | - // Do nothing |
329 | | - } elseif ( $tag == 'mediawiki' && $type == XmlReader::END_ELEMENT ) { |
330 | | - break; |
331 | | - } elseif ( $tag == 'siteinfo' ) { |
332 | | - $this->handleSiteInfo(); |
333 | | - } elseif ( $tag == 'page' ) { |
334 | | - $this->handlePage(); |
335 | | - } elseif ( $tag == 'logitem' ) { |
336 | | - $this->handleLogItem(); |
337 | | - } elseif ( $tag != '#text' ) { |
338 | | - $this->warn( "Unhandled top-level XML tag $tag" ); |
339 | | - |
340 | | - $skip = true; |
341 | | - } |
342 | | - |
343 | | - if ($skip) { |
344 | | - $keepReading = $this->reader->next(); |
345 | | - $skip = false; |
346 | | - $this->debug( "Skip" ); |
347 | | - } else { |
348 | | - $keepReading = $this->reader->read(); |
349 | | - } |
350 | | - } |
351 | | - |
352 | | - return true; |
353 | | - } |
354 | | - |
355 | | - private function handleSiteInfo() { |
356 | | - // Site info is useful, but not actually used for dump imports. |
357 | | - // Includes a quick short-circuit to save performance. |
358 | | - if ( ! $this->mSiteInfoCallback ) { |
359 | | - $this->reader->next(); |
360 | | - return true; |
361 | | - } |
362 | | - throw new MWException( "SiteInfo tag is not yet handled, do not set mSiteInfoCallback" ); |
363 | | - } |
364 | | - |
365 | | - private function handleLogItem() { |
366 | | - $this->debug( "Enter log item handler." ); |
367 | | - $logInfo = array(); |
368 | | - |
369 | | - // Fields that can just be stuffed in the pageInfo object |
370 | | - $normalFields = array( 'id', 'comment', 'type', 'action', 'timestamp', |
371 | | - 'logtitle', 'params' ); |
372 | | - |
373 | | - while ( $this->reader->read() ) { |
374 | | - if ( $this->reader->nodeType == XmlReader::END_ELEMENT && |
375 | | - $this->reader->name == 'logitem') { |
376 | | - break; |
377 | | - } |
378 | | - |
379 | | - $tag = $this->reader->name; |
380 | | - |
381 | | - if ( !wfRunHooks( 'ImportHandleLogItemXMLTag', |
382 | | - $this->reader, $logInfo ) ) { |
383 | | - // Do nothing |
384 | | - } elseif ( in_array( $tag, $normalFields ) ) { |
385 | | - $logInfo[$tag] = $this->nodeContents(); |
386 | | - } elseif ( $tag == 'contributor' ) { |
387 | | - $logInfo['contributor'] = $this->handleContributor(); |
388 | | - } elseif ( $tag != '#text' ) { |
389 | | - $this->warn( "Unhandled log-item XML tag $tag" ); |
390 | | - } |
391 | | - } |
392 | | - |
393 | | - $this->processLogItem( $logInfo ); |
394 | | - } |
395 | | - |
396 | | - private function processLogItem( $logInfo ) { |
397 | | - $revision = new WikiRevision; |
398 | | - |
399 | | - $revision->setID( $logInfo['id'] ); |
400 | | - $revision->setType( $logInfo['type'] ); |
401 | | - $revision->setAction( $logInfo['action'] ); |
402 | | - $revision->setTimestamp( $logInfo['timestamp'] ); |
403 | | - $revision->setParams( $logInfo['params'] ); |
404 | | - $revision->setTitle( Title::newFromText( $logInfo['logtitle'] ) ); |
405 | | - |
406 | | - if ( isset( $logInfo['comment'] ) ) { |
407 | | - $revision->setComment( $logInfo['comment'] ); |
408 | | - } |
409 | | - |
410 | | - if ( isset( $logInfo['contributor']['ip'] ) ) { |
411 | | - $revision->setUserIP( $logInfo['contributor']['ip'] ); |
412 | | - } |
413 | | - if ( isset( $logInfo['contributor']['username'] ) ) { |
414 | | - $revision->setUserName( $logInfo['contributor']['username'] ); |
415 | | - } |
416 | | - |
417 | | - return $this->logItemCallback( $revision ); |
418 | | - } |
419 | | - |
420 | | - private function handlePage() { |
421 | | - // Handle page data. |
422 | | - $this->debug( "Enter page handler." ); |
423 | | - $pageInfo = array( 'revisionCount' => 0, 'successfulRevisionCount' => 0 ); |
424 | | - |
425 | | - // Fields that can just be stuffed in the pageInfo object |
426 | | - $normalFields = array( 'title', 'id', 'redirect', 'restrictions' ); |
427 | | - |
428 | | - $skip = false; |
429 | | - $badTitle = false; |
430 | | - |
431 | | - while ( $skip ? $this->reader->next() : $this->reader->read() ) { |
432 | | - if ( $this->reader->nodeType == XmlReader::END_ELEMENT && |
433 | | - $this->reader->name == 'page') { |
434 | | - break; |
435 | | - } |
436 | | - |
437 | | - $tag = $this->reader->name; |
438 | | - |
439 | | - if ( $badTitle ) { |
440 | | - // The title is invalid, bail out of this page |
441 | | - $skip = true; |
442 | | - } elseif ( !wfRunHooks( 'ImportHandlePageXMLTag', array( $this->reader, |
443 | | - &$pageInfo ) ) ) { |
444 | | - // Do nothing |
445 | | - } elseif ( in_array( $tag, $normalFields ) ) { |
446 | | - $pageInfo[$tag] = $this->nodeContents(); |
447 | | - if ( $tag == 'title' ) { |
448 | | - $title = $this->processTitle( $pageInfo['title'] ); |
449 | | - |
450 | | - if ( !$title ) { |
451 | | - $badTitle = true; |
452 | | - $skip = true; |
453 | | - } |
454 | | - |
455 | | - $this->pageCallback( $title ); |
456 | | - list( $pageInfo['_title'], $origTitle ) = $title; |
457 | | - } |
458 | | - } elseif ( $tag == 'revision' ) { |
459 | | - $this->handleRevision( $pageInfo ); |
460 | | - } elseif ( $tag == 'upload' ) { |
461 | | - $this->handleUpload( $pageInfo ); |
462 | | - } elseif ( $tag != '#text' ) { |
463 | | - $this->warn( "Unhandled page XML tag $tag" ); |
464 | | - $skip = true; |
465 | | - } |
466 | | - } |
467 | | - |
468 | | - $this->pageOutCallback( $pageInfo['_title'], $origTitle, |
469 | | - $pageInfo['revisionCount'], |
470 | | - $pageInfo['successfulRevisionCount'], |
471 | | - $pageInfo ); |
472 | | - } |
473 | | - |
474 | | - private function handleRevision( &$pageInfo ) { |
475 | | - $this->debug( "Enter revision handler" ); |
476 | | - $revisionInfo = array(); |
477 | | - |
478 | | - $normalFields = array( 'id', 'timestamp', 'comment', 'minor', 'text' ); |
479 | | - |
480 | | - $skip = false; |
481 | | - |
482 | | - while ( $skip ? $this->reader->next() : $this->reader->read() ) { |
483 | | - if ( $this->reader->nodeType == XmlReader::END_ELEMENT && |
484 | | - $this->reader->name == 'revision') { |
485 | | - break; |
486 | | - } |
487 | | - |
488 | | - $tag = $this->reader->name; |
489 | | - |
490 | | - if ( !wfRunHooks( 'ImportHandleRevisionXMLTag', $this->reader, |
491 | | - $pageInfo, $revisionInfo ) ) { |
492 | | - // Do nothing |
493 | | - } elseif ( in_array( $tag, $normalFields ) ) { |
494 | | - $revisionInfo[$tag] = $this->nodeContents(); |
495 | | - } elseif ( $tag == 'contributor' ) { |
496 | | - $revisionInfo['contributor'] = $this->handleContributor(); |
497 | | - } elseif ( $tag != '#text' ) { |
498 | | - $this->warn( "Unhandled revision XML tag $tag" ); |
499 | | - $skip = true; |
500 | | - } |
501 | | - } |
502 | | - |
503 | | - $pageInfo['revisionCount']++; |
504 | | - if ( $this->processRevision( $pageInfo, $revisionInfo ) ) { |
505 | | - $pageInfo['successfulRevisionCount']++; |
506 | | - } |
507 | | - } |
508 | | - |
509 | | - private function processRevision( $pageInfo, $revisionInfo ) { |
510 | | - $revision = new WikiRevision; |
511 | | - |
512 | | - $revision->setID( $revisionInfo['id'] ); |
513 | | - $revision->setText( $revisionInfo['text'] ); |
514 | | - $revision->setTitle( $pageInfo['_title'] ); |
515 | | - $revision->setTimestamp( $revisionInfo['timestamp'] ); |
516 | | - |
517 | | - if ( isset( $revisionInfo['comment'] ) ) { |
518 | | - $revision->setComment( $revisionInfo['comment'] ); |
519 | | - } |
520 | | - |
521 | | - if ( isset( $revisionInfo['minor'] ) ) |
522 | | - $revision->setMinor( true ); |
523 | | - |
524 | | - if ( isset( $revisionInfo['contributor']['ip'] ) ) { |
525 | | - $revision->setUserIP( $revisionInfo['contributor']['ip'] ); |
526 | | - } |
527 | | - if ( isset( $revisionInfo['contributor']['username'] ) ) { |
528 | | - $revision->setUserName( $revisionInfo['contributor']['username'] ); |
529 | | - } |
530 | | - |
531 | | - return $this->revisionCallback( $revision ); |
532 | | - } |
533 | | - |
534 | | - private function handleUpload( &$pageInfo ) { |
535 | | - $this->debug( "Enter upload handler" ); |
536 | | - $uploadInfo = array(); |
537 | | - |
538 | | - $normalFields = array( 'timestamp', 'comment', 'filename', 'text', |
539 | | - 'src', 'size' ); |
540 | | - |
541 | | - $skip = false; |
542 | | - |
543 | | - while ( $skip ? $this->reader->next() : $this->reader->read() ) { |
544 | | - if ( $this->reader->nodeType == XmlReader::END_ELEMENT && |
545 | | - $this->reader->name == 'upload') { |
546 | | - break; |
547 | | - } |
548 | | - |
549 | | - $tag = $this->reader->name; |
550 | | - |
551 | | - if ( !wfRunHooks( 'ImportHandleUploadXMLTag', $this->reader, |
552 | | - $pageInfo ) ) { |
553 | | - // Do nothing |
554 | | - } elseif ( in_array( $tag, $normalFields ) ) { |
555 | | - $uploadInfo[$tag] = $this->nodeContents(); |
556 | | - } elseif ( $tag == 'contributor' ) { |
557 | | - $uploadInfo['contributor'] = $this->handleContributor(); |
558 | | - } elseif ( $tag != '#text' ) { |
559 | | - $this->warn( "Unhandled upload XML tag $tag" ); |
560 | | - $skip = true; |
561 | | - } |
562 | | - } |
563 | | - |
564 | | - return $this->processUpload( $pageInfo, $uploadInfo ); |
565 | | - } |
566 | | - |
567 | | - private function processUpload( $pageInfo, $uploadInfo ) { |
568 | | - $revision = new WikiRevision; |
569 | | - |
570 | | - $revision->setTitle( $pageInfo['_title'] ); |
571 | | - $revision->setID( $uploadInfo['id'] ); |
572 | | - $revision->setTimestamp( $uploadInfo['timestamp'] ); |
573 | | - $revision->setText( $uploadInfo['text'] ); |
574 | | - $revision->setFilename( $uploadInfo['filename'] ); |
575 | | - $revision->setSrc( $uploadInfo['src'] ); |
576 | | - $revision->setSize( intval( $uploadInfo['size'] ) ); |
577 | | - $revision->setComment( $uploadInfo['comment'] ); |
578 | | - |
579 | | - if ( isset( $uploadInfo['contributor']['ip'] ) ) { |
580 | | - $revision->setUserIP( $uploadInfo['contributor']['ip'] ); |
581 | | - } |
582 | | - if ( isset( $uploadInfo['contributor']['username'] ) ) { |
583 | | - $revision->setUserName( $uploadInfo['contributor']['username'] ); |
584 | | - } |
585 | | - |
586 | | - return $this->uploadCallback( $revision ); |
587 | | - } |
588 | | - |
589 | | - private function handleContributor() { |
590 | | - $fields = array( 'id', 'ip', 'username' ); |
591 | | - $info = array(); |
592 | | - |
593 | | - while ( $this->reader->read() ) { |
594 | | - if ( $this->reader->nodeType == XmlReader::END_ELEMENT && |
595 | | - $this->reader->name == 'contributor') { |
596 | | - break; |
597 | | - } |
598 | | - |
599 | | - $tag = $this->reader->name; |
600 | | - |
601 | | - if ( in_array( $tag, $fields ) ) { |
602 | | - $info[$tag] = $this->nodeContents(); |
603 | | - } |
604 | | - } |
605 | | - |
606 | | - return $info; |
607 | | - } |
608 | | - |
609 | | - private function processTitle( $text ) { |
610 | | - $workTitle = $text; |
611 | | - $origTitle = Title::newFromText( $workTitle ); |
612 | | - |
613 | | - if( !is_null( $this->mTargetNamespace ) && !is_null( $origTitle ) ) { |
614 | | - $title = Title::makeTitle( $this->mTargetNamespace, |
615 | | - $origTitle->getDBkey() ); |
616 | | - } else { |
617 | | - $title = Title::newFromText( $workTitle ); |
618 | | - } |
619 | | - |
620 | | - if( is_null( $title ) ) { |
621 | | - // Invalid page title? Ignore the page |
622 | | - $this->notice( "Skipping invalid page title '$workTitle'" ); |
623 | | - return false; |
624 | | - } elseif( $title->getInterwiki() != '' ) { |
625 | | - $this->notice( "Skipping interwiki page title '$workTitle'" ); |
626 | | - return false; |
627 | | - } |
628 | | - |
629 | | - return array( $origTitle, $title ); |
630 | | - } |
631 | | -} |
632 | | - |
633 | | -/** This is a horrible hack used to keep source compatibility */ |
634 | | -class UploadSourceAdapter { |
635 | | - static $sourceRegistrations = array(); |
636 | | - |
637 | | - private $mSource; |
638 | | - private $mBuffer; |
639 | | - private $mPosition; |
640 | | - |
641 | | - static function registerSource( $source ) { |
642 | | - $id = wfGenerateToken(); |
643 | | - |
644 | | - self::$sourceRegistrations[$id] = $source; |
645 | | - |
646 | | - return $id; |
647 | | - } |
648 | | - |
649 | | - function stream_open( $path, $mode, $options, &$opened_path ) { |
650 | | - $url = parse_url($path); |
651 | | - $id = $url['host']; |
652 | | - |
653 | | - if ( !isset( self::$sourceRegistrations[$id] ) ) { |
654 | | - return false; |
655 | | - } |
656 | | - |
657 | | - $this->mSource = self::$sourceRegistrations[$id]; |
658 | | - |
659 | | - return true; |
660 | | - } |
661 | | - |
662 | | - function stream_read( $count ) { |
663 | | - $return = ''; |
664 | | - $leave = false; |
665 | | - |
666 | | - while ( !$leave && !$this->mSource->atEnd() && |
667 | | - strlen($this->mBuffer) < $count ) { |
668 | | - $read = $this->mSource->readChunk(); |
669 | | - |
670 | | - if ( !strlen($read) ) { |
671 | | - $leave = true; |
672 | | - } |
673 | | - |
674 | | - $this->mBuffer .= $read; |
675 | | - } |
676 | | - |
677 | | - if ( strlen($this->mBuffer) ) { |
678 | | - $return = substr( $this->mBuffer, 0, $count ); |
679 | | - $this->mBuffer = substr( $this->mBuffer, $count ); |
680 | | - } |
681 | | - |
682 | | - $this->mPosition += strlen($return); |
683 | | - |
684 | | - return $return; |
685 | | - } |
686 | | - |
687 | | - function stream_write( $data ) { |
688 | | - return false; |
689 | | - } |
690 | | - |
691 | | - function stream_tell() { |
692 | | - return $this->mPosition; |
693 | | - } |
694 | | - |
695 | | - function stream_eof() { |
696 | | - return $this->mSource->atEnd(); |
697 | | - } |
698 | | - |
699 | | - function url_stat() { |
700 | | - $result = array(); |
701 | | - |
702 | | - $result['dev'] = $result[0] = 0; |
703 | | - $result['ino'] = $result[1] = 0; |
704 | | - $result['mode'] = $result[2] = 0; |
705 | | - $result['nlink'] = $result[3] = 0; |
706 | | - $result['uid'] = $result[4] = 0; |
707 | | - $result['gid'] = $result[5] = 0; |
708 | | - $result['rdev'] = $result[6] = 0; |
709 | | - $result['size'] = $result[7] = 0; |
710 | | - $result['atime'] = $result[8] = 0; |
711 | | - $result['mtime'] = $result[9] = 0; |
712 | | - $result['ctime'] = $result[10] = 0; |
713 | | - $result['blksize'] = $result[11] = 0; |
714 | | - $result['blocks'] = $result[12] = 0; |
715 | | - |
716 | | - return $result; |
717 | | - } |
718 | | -} |
719 | | - |
720 | | -class XMLReader2 extends XMLReader { |
721 | | - function nodeContents() { |
722 | | - if( $this->isEmptyElement ) { |
723 | | - return ""; |
724 | | - } |
725 | | - $buffer = ""; |
726 | | - while( $this->read() ) { |
727 | | - switch( $this->nodeType ) { |
728 | | - case XmlReader::TEXT: |
729 | | - case XmlReader::SIGNIFICANT_WHITESPACE: |
730 | | - $buffer .= $this->value; |
731 | | - break; |
732 | | - case XmlReader::END_ELEMENT: |
733 | | - return $buffer; |
734 | | - } |
735 | | - } |
736 | | - return $this->close(); |
737 | | - } |
738 | | -} |
Index: branches/REL1_17/phase3/includes/upload/UploadFromStash.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | public static function isValidRequest( $request ) { |
21 | 21 | $sessionData = $request->getSessionData( self::SESSION_KEYNAME ); |
22 | 22 | return self::isValidSessionKey( |
23 | | - $request->getInt( 'wpSessionKey' ), |
| 23 | + $request->getText( 'wpSessionKey' ), |
24 | 24 | $sessionData |
25 | 25 | ); |
26 | 26 | } |
— | — | @@ -44,7 +44,7 @@ |
45 | 45 | } |
46 | 46 | |
47 | 47 | public function initializeFromRequest( &$request ) { |
48 | | - $sessionKey = $request->getInt( 'wpSessionKey' ); |
| 48 | + $sessionKey = $request->getText( 'wpSessionKey' ); |
49 | 49 | $sessionData = $request->getSessionData( self::SESSION_KEYNAME ); |
50 | 50 | |
51 | 51 | $desiredDestName = $request->getText( 'wpDestFile' ); |
Index: branches/REL1_17/phase3/includes/upload/UploadStash.php |
— | — | @@ -329,7 +329,7 @@ |
330 | 330 | */ |
331 | 331 | public function getThumbUrl( $thumbName = false ) { |
332 | 332 | wfDebug( __METHOD__ . " getting for $thumbName \n" ); |
333 | | - return $this->getSpecialUrl( $thumbName ); |
| 333 | + return $this->getSpecialUrl( 'thumb/' . $this->getUrlName() . '/' . $thumbName ); |
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
— | — | @@ -353,7 +353,7 @@ |
354 | 354 | */ |
355 | 355 | public function getUrl() { |
356 | 356 | if ( !isset( $this->url ) ) { |
357 | | - $this->url = $this->getSpecialUrl( $this->getUrlName() ); |
| 357 | + $this->url = $this->getSpecialUrl( 'file/' . $this->getUrlName() ); |
358 | 358 | } |
359 | 359 | return $this->url; |
360 | 360 | } |
Property changes on: branches/REL1_17/phase3/includes/upload/UploadStash.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
361 | 361 | Merged /trunk/phase3/includes/upload/UploadStash.php:r81186-81187,81197,81209-81211,81215,81238,81246,81262,81264 |
Index: branches/REL1_17/phase3/includes/User.php |
— | — | @@ -2924,10 +2924,10 @@ |
2925 | 2925 | * Generate a new e-mail confirmation token and send a confirmation/invalidation |
2926 | 2926 | * mail to the user's given address. |
2927 | 2927 | * |
2928 | | - * @param $changed Boolean: whether the adress changed |
| 2928 | + * @param $type String: message to send, either "created", "changed" or "set" |
2929 | 2929 | * @return Status object |
2930 | 2930 | */ |
2931 | | - function sendConfirmationMail( $changed = false ) { |
| 2931 | + function sendConfirmationMail( $type = 'created' ) { |
2932 | 2932 | global $wgLang; |
2933 | 2933 | $expiration = null; // gets passed-by-ref and defined in next line. |
2934 | 2934 | $token = $this->confirmationToken( $expiration ); |
— | — | @@ -2935,7 +2935,14 @@ |
2936 | 2936 | $invalidateURL = $this->invalidationTokenUrl( $token ); |
2937 | 2937 | $this->saveSettings(); |
2938 | 2938 | |
2939 | | - $message = $changed ? 'confirmemail_body_changed' : 'confirmemail_body'; |
| 2939 | + if ( $type == 'created' || $type === false ) { |
| 2940 | + $message = 'confirmemail_body'; |
| 2941 | + } elseif ( $type === true ) { |
| 2942 | + $message = 'confirmemail_body_changed'; |
| 2943 | + } else { |
| 2944 | + $message = 'confirmemail_body_' . $type; |
| 2945 | + } |
| 2946 | + |
2940 | 2947 | return $this->sendMail( wfMsg( 'confirmemail_subject' ), |
2941 | 2948 | wfMsg( $message, |
2942 | 2949 | wfGetIP(), |
Index: branches/REL1_17/phase3/includes/installer/Installer.i18n.php |
— | — | @@ -444,6 +444,8 @@ |
445 | 445 | They may require additional configuration, but you can enable them now', |
446 | 446 | 'config-install-alreadydone' => "'''Warning:''' You seem to have already installed MediaWiki and are trying to install it again. |
447 | 447 | Please proceed to the next page.", |
| 448 | + 'config-install-begin' => 'By pressing next, you will begin the installation of MediaWiki. |
| 449 | +If you still want to make changes, press back.', |
448 | 450 | 'config-install-step-done' => 'done', |
449 | 451 | 'config-install-step-failed' => 'failed', |
450 | 452 | 'config-install-extensions' => 'Including extensions', |
Index: branches/REL1_17/phase3/includes/installer/WebInstallerPage.php |
— | — | @@ -1010,25 +1010,29 @@ |
1011 | 1011 | class WebInstaller_Install extends WebInstallerPage { |
1012 | 1012 | |
1013 | 1013 | public function execute() { |
1014 | | - if( $this->parent->request->wasPosted() ) { |
| 1014 | + if( $this->getVar( '_UpgradeDone' ) ) { |
| 1015 | + return 'skip'; |
| 1016 | + } elseif( $this->getVar( '_InstallDone' ) ) { |
1015 | 1017 | return 'continue'; |
1016 | | - } elseif( $this->getVar( '_InstallDone' ) ) { |
| 1018 | + } elseif( $this->parent->request->wasPosted() ) { |
1017 | 1019 | $this->startForm(); |
1018 | | - $status = new Status(); |
1019 | | - $status->warning( 'config-install-alreadydone' ); |
1020 | | - $this->parent->showStatusBox( $status ); |
1021 | | - } elseif( $this->getVar( '_UpgradeDone' ) ) { |
1022 | | - return 'skip'; |
1023 | | - } else { |
1024 | | - $this->startForm(); |
1025 | 1020 | $this->addHTML("<ul>"); |
1026 | | - $this->parent->performInstallation( |
| 1021 | + $results = $this->parent->performInstallation( |
1027 | 1022 | array( $this, 'startStage'), |
1028 | 1023 | array( $this, 'endStage' ) |
1029 | 1024 | ); |
1030 | 1025 | $this->addHTML("</ul>"); |
| 1026 | + // PerformInstallation bails on a fatal, so make sure the last item |
| 1027 | + // completed before giving 'next.' Likewise, only provide back on failure |
| 1028 | + $lastStep = end( $results ); |
| 1029 | + $continue = $lastStep->isOK() ? 'continue' : false; |
| 1030 | + $back = $lastStep->isOK() ? false : 'back'; |
| 1031 | + $this->endForm( $continue, $back ); |
| 1032 | + } else { |
| 1033 | + $this->startForm(); |
| 1034 | + $this->addHTML( $this->parent->getInfoBox( wfMsgNoTrans( 'config-install-begin' ) ) ); |
| 1035 | + $this->endForm(); |
1031 | 1036 | } |
1032 | | - $this->endForm(); |
1033 | 1037 | return true; |
1034 | 1038 | } |
1035 | 1039 | |
Property changes on: branches/REL1_17/phase3/includes/installer/WebInstallerPage.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
1036 | 1040 | Merged /trunk/phase3/includes/installer/WebInstallerPage.php:r81186-81187,81197,81209-81211,81215,81238,81246,81262,81264 |
Index: branches/REL1_17/phase3/includes/AutoLoader.php |
— | — | @@ -670,7 +670,7 @@ |
671 | 671 | 'WantedPagesPage' => 'includes/specials/SpecialWantedpages.php', |
672 | 672 | 'WantedTemplatesPage' => 'includes/specials/SpecialWantedtemplates.php', |
673 | 673 | 'WhatLinksHerePage' => 'includes/specials/SpecialWhatlinkshere.php', |
674 | | - 'WikiImporter' => 'includes/ImportXMLReader.php', |
| 674 | + 'WikiImporter' => 'includes/Import.php', |
675 | 675 | 'WikiRevision' => 'includes/Import.php', |
676 | 676 | 'WithoutInterwikiPage' => 'includes/specials/SpecialWithoutinterwiki.php', |
677 | 677 | |
Property changes on: branches/REL1_17/phase3/includes/AutoLoader.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
678 | 678 | Merged /trunk/phase3/includes/AutoLoader.php:r81186-81187,81197,81209-81211,81215,81238,81246,81262,81264 |
Index: branches/REL1_17/phase3/includes/libs/JavaScriptDistiller.php |
— | — | @@ -84,7 +84,8 @@ |
85 | 85 | $parser->add( '/[^\\w\\$\\/\'"*)\\?:]\\/[^\\/\\r\\n\\*][^\\/\\r\\n]*\\/g?i?/', '$1' ); |
86 | 86 | // Remove comments |
87 | 87 | $parser->add( '/\\/\\*(.|[\\r\\n])*?\\*\\//' ); |
88 | | - $parser->add( '/\\/\\/[^\\r\\n]*[\\r\\n]/' ); |
| 88 | + // Preserve the newline after a C++-style comment -- bug 27046 |
| 89 | + $parser->add( '/\\/\\/[^\\r\\n]*([\\r\\n])/', '$2' ); |
89 | 90 | return $parser; |
90 | 91 | } |
91 | 92 | } |
Index: branches/REL1_17/phase3/includes/specials/SpecialUploadStash.php |
— | — | @@ -84,11 +84,11 @@ |
85 | 85 | $wgOut->disable(); |
86 | 86 | |
87 | 87 | try { |
88 | | - if ( preg_match( '/^(\d+)px-(.*)$/', $key, $matches ) ) { |
89 | | - list( /* full match */, $width, $key ) = $matches; |
90 | | - return $this->outputThumbFromStash( $key, $width ); |
| 88 | + $params = $this->parseKey( $key ); |
| 89 | + if ( $params['type'] === 'thumb' ) { |
| 90 | + return $this->outputThumbFromStash( $params['file'], $params['params'] ); |
91 | 91 | } else { |
92 | | - return $this->outputFileFromStash( $key ); |
| 92 | + return $this->outputLocalFile( $params['file'] ); |
93 | 93 | } |
94 | 94 | } catch( UploadStashFileNotFoundException $e ) { |
95 | 95 | $code = 404; |
— | — | @@ -110,43 +110,62 @@ |
111 | 111 | wfHttpError( $code, OutputPage::getStatusMessage( $code ), $message ); |
112 | 112 | return false; |
113 | 113 | } |
114 | | - |
| 114 | + |
115 | 115 | /** |
116 | | - * Get a file from stash and stream it out. Rely on parent to catch exceptions and transform them into HTTP |
117 | | - * @param String: $key - key of this file in the stash, which probably looks like a filename with extension. |
118 | | - * @return boolean |
| 116 | + * Parse the key passed to the SpecialPage. Returns an array containing |
| 117 | + * the associated file object, the type ('file' or 'thumb') and if |
| 118 | + * application the transform parameters |
| 119 | + * |
| 120 | + * @param string $key |
| 121 | + * @return array |
119 | 122 | */ |
120 | | - private function outputFileFromStash( $key ) { |
121 | | - $file = $this->stash->getFile( $key ); |
122 | | - return $this->outputLocalFile( $file ); |
| 123 | + private function parseKey( $key ) { |
| 124 | + $type = strtok( $key, '/' ); |
| 125 | + |
| 126 | + if ( $type !== 'file' && $type !== 'thumb' ) { |
| 127 | + throw new UploadStashBadPathException( "Unknown type '$type'" ); |
| 128 | + } |
| 129 | + $fileName = strtok( '/' ); |
| 130 | + $thumbPart = strtok( '/' ); |
| 131 | + $file = $this->stash->getFile( $fileName ); |
| 132 | + if ( $type === 'thumb' ) { |
| 133 | + $srcNamePos = strrpos( $thumbPart, $fileName ); |
| 134 | + if ( $srcNamePos === false || $srcNamePos < 1 ) { |
| 135 | + throw new UploadStashBadPathException( 'Unrecognized thumb name' ); |
| 136 | + } |
| 137 | + $paramString = substr( $thumbPart, 0, $srcNamePos - 1 ); |
| 138 | + |
| 139 | + $handler = $file->getHandler(); |
| 140 | + $params = $handler->parseParamString( $paramString ); |
| 141 | + return array( 'file' => $file, 'type' => $type, 'params' => $params ); |
| 142 | + } |
| 143 | + |
| 144 | + return array( 'file' => $file, 'type' => $type ); |
123 | 145 | } |
| 146 | + |
124 | 147 | |
125 | 148 | |
| 149 | + |
126 | 150 | /** |
127 | 151 | * Get a thumbnail for file, either generated locally or remotely, and stream it out |
128 | 152 | * @param String $key: key for the file in the stash |
129 | 153 | * @param int $width: width of desired thumbnail |
130 | 154 | * @return boolean success |
131 | 155 | */ |
132 | | - private function outputThumbFromStash( $key, $width ) { |
| 156 | + private function outputThumbFromStash( $file, $params ) { |
133 | 157 | |
134 | 158 | // this global, if it exists, points to a "scaler", as you might find in the Wikimedia Foundation cluster. See outputRemoteScaledThumb() |
135 | 159 | // this is part of our horrible NFS-based system, we create a file on a mount point here, but fetch the scaled file from somewhere else that |
136 | 160 | // happens to share it over NFS |
137 | 161 | global $wgUploadStashScalerBaseUrl; |
138 | 162 | |
139 | | - // let exceptions propagate to caller. |
140 | | - $file = $this->stash->getFile( $key ); |
141 | | - |
142 | | - // OK, we're here and no exception was thrown, |
143 | | - // so the original file must exist. |
144 | | - |
145 | | - // let's get ready to transform the original -- these are standard |
146 | | - $params = array( 'width' => $width ); |
147 | 163 | $flags = 0; |
| 164 | + if ( $wgUploadStashScalerBaseUrl ) { |
| 165 | + $this->outputRemoteScaledThumb( $file, $params, $flags ); |
| 166 | + } else { |
| 167 | + $this->outputLocallyScaledThumb( $file, $params, $flags ); |
| 168 | + } |
148 | 169 | |
149 | | - return $wgUploadStashScalerBaseUrl ? $this->outputRemoteScaledThumb( $file, $params, $flags ) |
150 | | - : $this->outputLocallyScaledThumb( $file, $params, $flags ); |
151 | 170 | |
152 | 171 | } |
153 | 172 | |
— | — | @@ -353,7 +372,8 @@ |
354 | 373 | $fileListItemsHtml = ''; |
355 | 374 | foreach ( $files as $file ) { |
356 | 375 | $fileListItemsHtml .= Html::rawElement( 'li', array(), |
357 | | - Html::element( 'a', array( 'href' => $this->getTitle( $file )->getLocalURL() ), $file ) |
| 376 | + Html::element( 'a', array( 'href' => |
| 377 | + $this->getTitle( "file/$file" )->getLocalURL() ), $file ) |
358 | 378 | ); |
359 | 379 | } |
360 | 380 | $wgOut->addHtml( Html::rawElement( 'ul', array(), $fileListItemsHtml ) ); |
Property changes on: branches/REL1_17/phase3/includes/specials/SpecialUploadStash.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
361 | 381 | Merged /trunk/phase3/includes/specials/SpecialUploadStash.php:r81186-81187,81197,81209-81211,81215,81238,81246,81262,81264 |
Index: branches/REL1_17/phase3/includes/specials/SpecialWatchlist.php |
— | — | @@ -105,7 +105,7 @@ |
106 | 106 | $prefs['days'] = floatval( $wgUser->getOption( 'watchlistdays' ) ); |
107 | 107 | $prefs['hideminor'] = $wgUser->getBoolOption( 'watchlisthideminor' ); |
108 | 108 | $prefs['hidebots'] = $wgUser->getBoolOption( 'watchlisthidebots' ); |
109 | | - $prefs['hideanons'] = $wgUser->getBoolOption( 'watchlisthideanon' ); |
| 109 | + $prefs['hideanons'] = $wgUser->getBoolOption( 'watchlisthideanons' ); |
110 | 110 | $prefs['hideliu'] = $wgUser->getBoolOption( 'watchlisthideliu' ); |
111 | 111 | $prefs['hideown' ] = $wgUser->getBoolOption( 'watchlisthideown' ); |
112 | 112 | $prefs['hidepatrolled' ] = $wgUser->getBoolOption( 'watchlisthidepatrolled' ); |
Index: branches/REL1_17/phase3/includes/Preferences.php |
— | — | @@ -1280,7 +1280,8 @@ |
1281 | 1281 | if ( $wgEmailAuthentication ) { |
1282 | 1282 | # Mail a temporary password to the dirty address. |
1283 | 1283 | # User can come back through the confirmation URL to re-enable email. |
1284 | | - $result = $wgUser->sendConfirmationMail( $oldaddr != '' ); |
| 1284 | + $type = $oldaddr != '' ? 'changed' : 'set'; |
| 1285 | + $result = $wgUser->sendConfirmationMail( $type ); |
1285 | 1286 | if ( !$result->isGood() ) { |
1286 | 1287 | return htmlspecialchars( $result->getWikiText( 'mailerror' ) ); |
1287 | 1288 | } elseif ( $entryPoint == 'ui' ) { |
Index: branches/REL1_17/phase3/includes/Import.php |
— | — | @@ -25,6 +25,739 @@ |
26 | 26 | */ |
27 | 27 | |
28 | 28 | /** |
| 29 | + * XML file reader for the page data importer |
| 30 | + * |
| 31 | + * implements Special:Import |
| 32 | + * @ingroup SpecialPage |
| 33 | + */ |
| 34 | +class WikiImporter { |
| 35 | + private $reader = null; |
| 36 | + private $mLogItemCallback, $mUploadCallback, $mRevisionCallback, $mPageCallback; |
| 37 | + private $mSiteInfoCallback, $mTargetNamespace, $mPageOutCallback; |
| 38 | + private $mDebug; |
| 39 | + |
| 40 | + /** |
| 41 | + * Creates an ImportXMLReader drawing from the source provided |
| 42 | + */ |
| 43 | + function __construct( $source ) { |
| 44 | + $this->reader = new XMLReader2(); |
| 45 | + |
| 46 | + stream_wrapper_register( 'uploadsource', 'UploadSourceAdapter' ); |
| 47 | + $id = UploadSourceAdapter::registerSource( $source ); |
| 48 | + $this->reader->open( "uploadsource://$id" ); |
| 49 | + |
| 50 | + // Default callbacks |
| 51 | + $this->setRevisionCallback( array( $this, "importRevision" ) ); |
| 52 | + $this->setUploadCallback( array( $this, 'importUpload' ) ); |
| 53 | + $this->setLogItemCallback( array( $this, 'importLogItem' ) ); |
| 54 | + $this->setPageOutCallback( array( $this, 'finishImportPage' ) ); |
| 55 | + } |
| 56 | + |
| 57 | + private function throwXmlError( $err ) { |
| 58 | + $this->debug( "FAILURE: $err" ); |
| 59 | + wfDebug( "WikiImporter XML error: $err\n" ); |
| 60 | + } |
| 61 | + |
| 62 | + private function debug( $data ) { |
| 63 | + if( $this->mDebug ) { |
| 64 | + wfDebug( "IMPORT: $data\n" ); |
| 65 | + } |
| 66 | + } |
| 67 | + |
| 68 | + private function warn( $data ) { |
| 69 | + wfDebug( "IMPORT: $data\n" ); |
| 70 | + } |
| 71 | + |
| 72 | + private function notice( $data ) { |
| 73 | + global $wgCommandLineMode; |
| 74 | + if( $wgCommandLineMode ) { |
| 75 | + print "$data\n"; |
| 76 | + } else { |
| 77 | + global $wgOut; |
| 78 | + $wgOut->addHTML( "<li>" . htmlspecialchars( $data ) . "</li>\n" ); |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + /** |
| 83 | + * Set debug mode... |
| 84 | + */ |
| 85 | + function setDebug( $debug ) { |
| 86 | + $this->mDebug = $debug; |
| 87 | + } |
| 88 | + |
| 89 | + /** |
| 90 | + * Sets the action to perform as each new page in the stream is reached. |
| 91 | + * @param $callback callback |
| 92 | + * @return callback |
| 93 | + */ |
| 94 | + public function setPageCallback( $callback ) { |
| 95 | + $previous = $this->mPageCallback; |
| 96 | + $this->mPageCallback = $callback; |
| 97 | + return $previous; |
| 98 | + } |
| 99 | + |
| 100 | + /** |
| 101 | + * Sets the action to perform as each page in the stream is completed. |
| 102 | + * Callback accepts the page title (as a Title object), a second object |
| 103 | + * with the original title form (in case it's been overridden into a |
| 104 | + * local namespace), and a count of revisions. |
| 105 | + * |
| 106 | + * @param $callback callback |
| 107 | + * @return callback |
| 108 | + */ |
| 109 | + public function setPageOutCallback( $callback ) { |
| 110 | + $previous = $this->mPageOutCallback; |
| 111 | + $this->mPageOutCallback = $callback; |
| 112 | + return $previous; |
| 113 | + } |
| 114 | + |
| 115 | + /** |
| 116 | + * Sets the action to perform as each page revision is reached. |
| 117 | + * @param $callback callback |
| 118 | + * @return callback |
| 119 | + */ |
| 120 | + public function setRevisionCallback( $callback ) { |
| 121 | + $previous = $this->mRevisionCallback; |
| 122 | + $this->mRevisionCallback = $callback; |
| 123 | + return $previous; |
| 124 | + } |
| 125 | + |
| 126 | + /** |
| 127 | + * Sets the action to perform as each file upload version is reached. |
| 128 | + * @param $callback callback |
| 129 | + * @return callback |
| 130 | + */ |
| 131 | + public function setUploadCallback( $callback ) { |
| 132 | + $previous = $this->mUploadCallback; |
| 133 | + $this->mUploadCallback = $callback; |
| 134 | + return $previous; |
| 135 | + } |
| 136 | + |
| 137 | + /** |
| 138 | + * Sets the action to perform as each log item reached. |
| 139 | + * @param $callback callback |
| 140 | + * @return callback |
| 141 | + */ |
| 142 | + public function setLogItemCallback( $callback ) { |
| 143 | + $previous = $this->mLogItemCallback; |
| 144 | + $this->mLogItemCallback = $callback; |
| 145 | + return $previous; |
| 146 | + } |
| 147 | + |
| 148 | + /** |
| 149 | + * Sets the action to perform when site info is encountered |
| 150 | + * @param $callback callback |
| 151 | + * @return callback |
| 152 | + */ |
| 153 | + public function setSiteInfoCallback( $callback ) { |
| 154 | + $previous = $this->mSiteInfoCallback; |
| 155 | + $this->mSiteInfoCallback = $callback; |
| 156 | + return $previous; |
| 157 | + } |
| 158 | + |
| 159 | + /** |
| 160 | + * Set a target namespace to override the defaults |
| 161 | + */ |
| 162 | + public function setTargetNamespace( $namespace ) { |
| 163 | + if( is_null( $namespace ) ) { |
| 164 | + // Don't override namespaces |
| 165 | + $this->mTargetNamespace = null; |
| 166 | + } elseif( $namespace >= 0 ) { |
| 167 | + // FIXME: Check for validity |
| 168 | + $this->mTargetNamespace = intval( $namespace ); |
| 169 | + } else { |
| 170 | + return false; |
| 171 | + } |
| 172 | + } |
| 173 | + |
| 174 | + /** |
| 175 | + * Default per-revision callback, performs the import. |
| 176 | + * @param $revision WikiRevision |
| 177 | + */ |
| 178 | + public function importRevision( $revision ) { |
| 179 | + $dbw = wfGetDB( DB_MASTER ); |
| 180 | + return $dbw->deadlockLoop( array( $revision, 'importOldRevision' ) ); |
| 181 | + } |
| 182 | + |
| 183 | + /** |
| 184 | + * Default per-revision callback, performs the import. |
| 185 | + * @param $rev WikiRevision |
| 186 | + */ |
| 187 | + public function importLogItem( $rev ) { |
| 188 | + $dbw = wfGetDB( DB_MASTER ); |
| 189 | + return $dbw->deadlockLoop( array( $rev, 'importLogItem' ) ); |
| 190 | + } |
| 191 | + |
| 192 | + /** |
| 193 | + * Dummy for now... |
| 194 | + */ |
| 195 | + public function importUpload( $revision ) { |
| 196 | + //$dbw = wfGetDB( DB_MASTER ); |
| 197 | + //return $dbw->deadlockLoop( array( $revision, 'importUpload' ) ); |
| 198 | + return false; |
| 199 | + } |
| 200 | + |
| 201 | + /** |
| 202 | + * Mostly for hook use |
| 203 | + */ |
| 204 | + public function finishImportPage( $title, $origTitle, $revCount, $sRevCount, $pageInfo ) { |
| 205 | + $args = func_get_args(); |
| 206 | + return wfRunHooks( 'AfterImportPage', $args ); |
| 207 | + } |
| 208 | + |
| 209 | + /** |
| 210 | + * Alternate per-revision callback, for debugging. |
| 211 | + * @param $revision WikiRevision |
| 212 | + */ |
| 213 | + public function debugRevisionHandler( &$revision ) { |
| 214 | + $this->debug( "Got revision:" ); |
| 215 | + if( is_object( $revision->title ) ) { |
| 216 | + $this->debug( "-- Title: " . $revision->title->getPrefixedText() ); |
| 217 | + } else { |
| 218 | + $this->debug( "-- Title: <invalid>" ); |
| 219 | + } |
| 220 | + $this->debug( "-- User: " . $revision->user_text ); |
| 221 | + $this->debug( "-- Timestamp: " . $revision->timestamp ); |
| 222 | + $this->debug( "-- Comment: " . $revision->comment ); |
| 223 | + $this->debug( "-- Text: " . $revision->text ); |
| 224 | + } |
| 225 | + |
| 226 | + /** |
| 227 | + * Notify the callback function when a new <page> is reached. |
| 228 | + * @param $title Title |
| 229 | + */ |
| 230 | + function pageCallback( $title ) { |
| 231 | + if( isset( $this->mPageCallback ) ) { |
| 232 | + call_user_func( $this->mPageCallback, $title ); |
| 233 | + } |
| 234 | + } |
| 235 | + |
| 236 | + /** |
| 237 | + * Notify the callback function when a </page> is closed. |
| 238 | + * @param $title Title |
| 239 | + * @param $origTitle Title |
| 240 | + * @param $revCount Integer |
| 241 | + * @param $sucCount Int: number of revisions for which callback returned true |
| 242 | + * @param $pageInfo Array: associative array of page information |
| 243 | + */ |
| 244 | + private function pageOutCallback( $title, $origTitle, $revCount, $sucCount, $pageInfo ) { |
| 245 | + if( isset( $this->mPageOutCallback ) ) { |
| 246 | + $args = func_get_args(); |
| 247 | + call_user_func_array( $this->mPageOutCallback, $args ); |
| 248 | + } |
| 249 | + } |
| 250 | + |
| 251 | + /** |
| 252 | + * Notify the callback function of a revision |
| 253 | + * @param $revision A WikiRevision object |
| 254 | + */ |
| 255 | + private function revisionCallback( $revision ) { |
| 256 | + if ( isset( $this->mRevisionCallback ) ) { |
| 257 | + return call_user_func_array( $this->mRevisionCallback, |
| 258 | + array( $revision, $this ) ); |
| 259 | + } else { |
| 260 | + return false; |
| 261 | + } |
| 262 | + } |
| 263 | + |
| 264 | + /** |
| 265 | + * Notify the callback function of a new log item |
| 266 | + * @param $revision A WikiRevision object |
| 267 | + */ |
| 268 | + private function logItemCallback( $revision ) { |
| 269 | + if ( isset( $this->mLogItemCallback ) ) { |
| 270 | + return call_user_func_array( $this->mLogItemCallback, |
| 271 | + array( $revision, $this ) ); |
| 272 | + } else { |
| 273 | + return false; |
| 274 | + } |
| 275 | + } |
| 276 | + |
| 277 | + /** |
| 278 | + * Shouldn't something like this be built-in to XMLReader? |
| 279 | + * Fetches text contents of the current element, assuming |
| 280 | + * no sub-elements or such scary things. |
| 281 | + * @return string |
| 282 | + * @access private |
| 283 | + */ |
| 284 | + private function nodeContents() { |
| 285 | + return $this->reader->nodeContents(); |
| 286 | + } |
| 287 | + |
| 288 | + # -------------- |
| 289 | + |
| 290 | + /** Left in for debugging */ |
| 291 | + private function dumpElement() { |
| 292 | + static $lookup = null; |
| 293 | + if (!$lookup) { |
| 294 | + $xmlReaderConstants = array( |
| 295 | + "NONE", |
| 296 | + "ELEMENT", |
| 297 | + "ATTRIBUTE", |
| 298 | + "TEXT", |
| 299 | + "CDATA", |
| 300 | + "ENTITY_REF", |
| 301 | + "ENTITY", |
| 302 | + "PI", |
| 303 | + "COMMENT", |
| 304 | + "DOC", |
| 305 | + "DOC_TYPE", |
| 306 | + "DOC_FRAGMENT", |
| 307 | + "NOTATION", |
| 308 | + "WHITESPACE", |
| 309 | + "SIGNIFICANT_WHITESPACE", |
| 310 | + "END_ELEMENT", |
| 311 | + "END_ENTITY", |
| 312 | + "XML_DECLARATION", |
| 313 | + ); |
| 314 | + $lookup = array(); |
| 315 | + |
| 316 | + foreach( $xmlReaderConstants as $name ) { |
| 317 | + $lookup[constant("XmlReader::$name")] = $name; |
| 318 | + } |
| 319 | + } |
| 320 | + |
| 321 | + print( var_dump( |
| 322 | + $lookup[$this->reader->nodeType], |
| 323 | + $this->reader->name, |
| 324 | + $this->reader->value |
| 325 | + )."\n\n" ); |
| 326 | + } |
| 327 | + |
| 328 | + /** |
| 329 | + * Primary entry point |
| 330 | + */ |
| 331 | + public function doImport() { |
| 332 | + $this->reader->read(); |
| 333 | + |
| 334 | + if ( $this->reader->name != 'mediawiki' ) { |
| 335 | + throw new MWException( "Expected <mediawiki> tag, got ". |
| 336 | + $this->reader->name ); |
| 337 | + } |
| 338 | + $this->debug( "<mediawiki> tag is correct." ); |
| 339 | + |
| 340 | + $this->debug( "Starting primary dump processing loop." ); |
| 341 | + |
| 342 | + $keepReading = $this->reader->read(); |
| 343 | + $skip = false; |
| 344 | + while ( $keepReading ) { |
| 345 | + $tag = $this->reader->name; |
| 346 | + $type = $this->reader->nodeType; |
| 347 | + |
| 348 | + if ( !wfRunHooks( 'ImportHandleToplevelXMLTag', $this->reader ) ) { |
| 349 | + // Do nothing |
| 350 | + } elseif ( $tag == 'mediawiki' && $type == XmlReader::END_ELEMENT ) { |
| 351 | + break; |
| 352 | + } elseif ( $tag == 'siteinfo' ) { |
| 353 | + $this->handleSiteInfo(); |
| 354 | + } elseif ( $tag == 'page' ) { |
| 355 | + $this->handlePage(); |
| 356 | + } elseif ( $tag == 'logitem' ) { |
| 357 | + $this->handleLogItem(); |
| 358 | + } elseif ( $tag != '#text' ) { |
| 359 | + $this->warn( "Unhandled top-level XML tag $tag" ); |
| 360 | + |
| 361 | + $skip = true; |
| 362 | + } |
| 363 | + |
| 364 | + if ($skip) { |
| 365 | + $keepReading = $this->reader->next(); |
| 366 | + $skip = false; |
| 367 | + $this->debug( "Skip" ); |
| 368 | + } else { |
| 369 | + $keepReading = $this->reader->read(); |
| 370 | + } |
| 371 | + } |
| 372 | + |
| 373 | + return true; |
| 374 | + } |
| 375 | + |
| 376 | + private function handleSiteInfo() { |
| 377 | + // Site info is useful, but not actually used for dump imports. |
| 378 | + // Includes a quick short-circuit to save performance. |
| 379 | + if ( ! $this->mSiteInfoCallback ) { |
| 380 | + $this->reader->next(); |
| 381 | + return true; |
| 382 | + } |
| 383 | + throw new MWException( "SiteInfo tag is not yet handled, do not set mSiteInfoCallback" ); |
| 384 | + } |
| 385 | + |
| 386 | + private function handleLogItem() { |
| 387 | + $this->debug( "Enter log item handler." ); |
| 388 | + $logInfo = array(); |
| 389 | + |
| 390 | + // Fields that can just be stuffed in the pageInfo object |
| 391 | + $normalFields = array( 'id', 'comment', 'type', 'action', 'timestamp', |
| 392 | + 'logtitle', 'params' ); |
| 393 | + |
| 394 | + while ( $this->reader->read() ) { |
| 395 | + if ( $this->reader->nodeType == XmlReader::END_ELEMENT && |
| 396 | + $this->reader->name == 'logitem') { |
| 397 | + break; |
| 398 | + } |
| 399 | + |
| 400 | + $tag = $this->reader->name; |
| 401 | + |
| 402 | + if ( !wfRunHooks( 'ImportHandleLogItemXMLTag', |
| 403 | + $this->reader, $logInfo ) ) { |
| 404 | + // Do nothing |
| 405 | + } elseif ( in_array( $tag, $normalFields ) ) { |
| 406 | + $logInfo[$tag] = $this->nodeContents(); |
| 407 | + } elseif ( $tag == 'contributor' ) { |
| 408 | + $logInfo['contributor'] = $this->handleContributor(); |
| 409 | + } elseif ( $tag != '#text' ) { |
| 410 | + $this->warn( "Unhandled log-item XML tag $tag" ); |
| 411 | + } |
| 412 | + } |
| 413 | + |
| 414 | + $this->processLogItem( $logInfo ); |
| 415 | + } |
| 416 | + |
| 417 | + private function processLogItem( $logInfo ) { |
| 418 | + $revision = new WikiRevision; |
| 419 | + |
| 420 | + $revision->setID( $logInfo['id'] ); |
| 421 | + $revision->setType( $logInfo['type'] ); |
| 422 | + $revision->setAction( $logInfo['action'] ); |
| 423 | + $revision->setTimestamp( $logInfo['timestamp'] ); |
| 424 | + $revision->setParams( $logInfo['params'] ); |
| 425 | + $revision->setTitle( Title::newFromText( $logInfo['logtitle'] ) ); |
| 426 | + |
| 427 | + if ( isset( $logInfo['comment'] ) ) { |
| 428 | + $revision->setComment( $logInfo['comment'] ); |
| 429 | + } |
| 430 | + |
| 431 | + if ( isset( $logInfo['contributor']['ip'] ) ) { |
| 432 | + $revision->setUserIP( $logInfo['contributor']['ip'] ); |
| 433 | + } |
| 434 | + if ( isset( $logInfo['contributor']['username'] ) ) { |
| 435 | + $revision->setUserName( $logInfo['contributor']['username'] ); |
| 436 | + } |
| 437 | + |
| 438 | + return $this->logItemCallback( $revision ); |
| 439 | + } |
| 440 | + |
| 441 | + private function handlePage() { |
| 442 | + // Handle page data. |
| 443 | + $this->debug( "Enter page handler." ); |
| 444 | + $pageInfo = array( 'revisionCount' => 0, 'successfulRevisionCount' => 0 ); |
| 445 | + |
| 446 | + // Fields that can just be stuffed in the pageInfo object |
| 447 | + $normalFields = array( 'title', 'id', 'redirect', 'restrictions' ); |
| 448 | + |
| 449 | + $skip = false; |
| 450 | + $badTitle = false; |
| 451 | + |
| 452 | + while ( $skip ? $this->reader->next() : $this->reader->read() ) { |
| 453 | + if ( $this->reader->nodeType == XmlReader::END_ELEMENT && |
| 454 | + $this->reader->name == 'page') { |
| 455 | + break; |
| 456 | + } |
| 457 | + |
| 458 | + $tag = $this->reader->name; |
| 459 | + |
| 460 | + if ( $badTitle ) { |
| 461 | + // The title is invalid, bail out of this page |
| 462 | + $skip = true; |
| 463 | + } elseif ( !wfRunHooks( 'ImportHandlePageXMLTag', array( $this->reader, |
| 464 | + &$pageInfo ) ) ) { |
| 465 | + // Do nothing |
| 466 | + } elseif ( in_array( $tag, $normalFields ) ) { |
| 467 | + $pageInfo[$tag] = $this->nodeContents(); |
| 468 | + if ( $tag == 'title' ) { |
| 469 | + $title = $this->processTitle( $pageInfo['title'] ); |
| 470 | + |
| 471 | + if ( !$title ) { |
| 472 | + $badTitle = true; |
| 473 | + $skip = true; |
| 474 | + } |
| 475 | + |
| 476 | + $this->pageCallback( $title ); |
| 477 | + list( $pageInfo['_title'], $origTitle ) = $title; |
| 478 | + } |
| 479 | + } elseif ( $tag == 'revision' ) { |
| 480 | + $this->handleRevision( $pageInfo ); |
| 481 | + } elseif ( $tag == 'upload' ) { |
| 482 | + $this->handleUpload( $pageInfo ); |
| 483 | + } elseif ( $tag != '#text' ) { |
| 484 | + $this->warn( "Unhandled page XML tag $tag" ); |
| 485 | + $skip = true; |
| 486 | + } |
| 487 | + } |
| 488 | + |
| 489 | + $this->pageOutCallback( $pageInfo['_title'], $origTitle, |
| 490 | + $pageInfo['revisionCount'], |
| 491 | + $pageInfo['successfulRevisionCount'], |
| 492 | + $pageInfo ); |
| 493 | + } |
| 494 | + |
| 495 | + private function handleRevision( &$pageInfo ) { |
| 496 | + $this->debug( "Enter revision handler" ); |
| 497 | + $revisionInfo = array(); |
| 498 | + |
| 499 | + $normalFields = array( 'id', 'timestamp', 'comment', 'minor', 'text' ); |
| 500 | + |
| 501 | + $skip = false; |
| 502 | + |
| 503 | + while ( $skip ? $this->reader->next() : $this->reader->read() ) { |
| 504 | + if ( $this->reader->nodeType == XmlReader::END_ELEMENT && |
| 505 | + $this->reader->name == 'revision') { |
| 506 | + break; |
| 507 | + } |
| 508 | + |
| 509 | + $tag = $this->reader->name; |
| 510 | + |
| 511 | + if ( !wfRunHooks( 'ImportHandleRevisionXMLTag', $this->reader, |
| 512 | + $pageInfo, $revisionInfo ) ) { |
| 513 | + // Do nothing |
| 514 | + } elseif ( in_array( $tag, $normalFields ) ) { |
| 515 | + $revisionInfo[$tag] = $this->nodeContents(); |
| 516 | + } elseif ( $tag == 'contributor' ) { |
| 517 | + $revisionInfo['contributor'] = $this->handleContributor(); |
| 518 | + } elseif ( $tag != '#text' ) { |
| 519 | + $this->warn( "Unhandled revision XML tag $tag" ); |
| 520 | + $skip = true; |
| 521 | + } |
| 522 | + } |
| 523 | + |
| 524 | + $pageInfo['revisionCount']++; |
| 525 | + if ( $this->processRevision( $pageInfo, $revisionInfo ) ) { |
| 526 | + $pageInfo['successfulRevisionCount']++; |
| 527 | + } |
| 528 | + } |
| 529 | + |
| 530 | + private function processRevision( $pageInfo, $revisionInfo ) { |
| 531 | + $revision = new WikiRevision; |
| 532 | + |
| 533 | + $revision->setID( $revisionInfo['id'] ); |
| 534 | + $revision->setText( $revisionInfo['text'] ); |
| 535 | + $revision->setTitle( $pageInfo['_title'] ); |
| 536 | + $revision->setTimestamp( $revisionInfo['timestamp'] ); |
| 537 | + |
| 538 | + if ( isset( $revisionInfo['comment'] ) ) { |
| 539 | + $revision->setComment( $revisionInfo['comment'] ); |
| 540 | + } |
| 541 | + |
| 542 | + if ( isset( $revisionInfo['minor'] ) ) |
| 543 | + $revision->setMinor( true ); |
| 544 | + |
| 545 | + if ( isset( $revisionInfo['contributor']['ip'] ) ) { |
| 546 | + $revision->setUserIP( $revisionInfo['contributor']['ip'] ); |
| 547 | + } |
| 548 | + if ( isset( $revisionInfo['contributor']['username'] ) ) { |
| 549 | + $revision->setUserName( $revisionInfo['contributor']['username'] ); |
| 550 | + } |
| 551 | + |
| 552 | + return $this->revisionCallback( $revision ); |
| 553 | + } |
| 554 | + |
| 555 | + private function handleUpload( &$pageInfo ) { |
| 556 | + $this->debug( "Enter upload handler" ); |
| 557 | + $uploadInfo = array(); |
| 558 | + |
| 559 | + $normalFields = array( 'timestamp', 'comment', 'filename', 'text', |
| 560 | + 'src', 'size' ); |
| 561 | + |
| 562 | + $skip = false; |
| 563 | + |
| 564 | + while ( $skip ? $this->reader->next() : $this->reader->read() ) { |
| 565 | + if ( $this->reader->nodeType == XmlReader::END_ELEMENT && |
| 566 | + $this->reader->name == 'upload') { |
| 567 | + break; |
| 568 | + } |
| 569 | + |
| 570 | + $tag = $this->reader->name; |
| 571 | + |
| 572 | + if ( !wfRunHooks( 'ImportHandleUploadXMLTag', $this->reader, |
| 573 | + $pageInfo ) ) { |
| 574 | + // Do nothing |
| 575 | + } elseif ( in_array( $tag, $normalFields ) ) { |
| 576 | + $uploadInfo[$tag] = $this->nodeContents(); |
| 577 | + } elseif ( $tag == 'contributor' ) { |
| 578 | + $uploadInfo['contributor'] = $this->handleContributor(); |
| 579 | + } elseif ( $tag != '#text' ) { |
| 580 | + $this->warn( "Unhandled upload XML tag $tag" ); |
| 581 | + $skip = true; |
| 582 | + } |
| 583 | + } |
| 584 | + |
| 585 | + return $this->processUpload( $pageInfo, $uploadInfo ); |
| 586 | + } |
| 587 | + |
| 588 | + private function processUpload( $pageInfo, $uploadInfo ) { |
| 589 | + $revision = new WikiRevision; |
| 590 | + |
| 591 | + $revision->setTitle( $pageInfo['_title'] ); |
| 592 | + $revision->setID( $uploadInfo['id'] ); |
| 593 | + $revision->setTimestamp( $uploadInfo['timestamp'] ); |
| 594 | + $revision->setText( $uploadInfo['text'] ); |
| 595 | + $revision->setFilename( $uploadInfo['filename'] ); |
| 596 | + $revision->setSrc( $uploadInfo['src'] ); |
| 597 | + $revision->setSize( intval( $uploadInfo['size'] ) ); |
| 598 | + $revision->setComment( $uploadInfo['comment'] ); |
| 599 | + |
| 600 | + if ( isset( $uploadInfo['contributor']['ip'] ) ) { |
| 601 | + $revision->setUserIP( $uploadInfo['contributor']['ip'] ); |
| 602 | + } |
| 603 | + if ( isset( $uploadInfo['contributor']['username'] ) ) { |
| 604 | + $revision->setUserName( $uploadInfo['contributor']['username'] ); |
| 605 | + } |
| 606 | + |
| 607 | + return $this->uploadCallback( $revision ); |
| 608 | + } |
| 609 | + |
| 610 | + private function handleContributor() { |
| 611 | + $fields = array( 'id', 'ip', 'username' ); |
| 612 | + $info = array(); |
| 613 | + |
| 614 | + while ( $this->reader->read() ) { |
| 615 | + if ( $this->reader->nodeType == XmlReader::END_ELEMENT && |
| 616 | + $this->reader->name == 'contributor') { |
| 617 | + break; |
| 618 | + } |
| 619 | + |
| 620 | + $tag = $this->reader->name; |
| 621 | + |
| 622 | + if ( in_array( $tag, $fields ) ) { |
| 623 | + $info[$tag] = $this->nodeContents(); |
| 624 | + } |
| 625 | + } |
| 626 | + |
| 627 | + return $info; |
| 628 | + } |
| 629 | + |
| 630 | + private function processTitle( $text ) { |
| 631 | + $workTitle = $text; |
| 632 | + $origTitle = Title::newFromText( $workTitle ); |
| 633 | + |
| 634 | + if( !is_null( $this->mTargetNamespace ) && !is_null( $origTitle ) ) { |
| 635 | + $title = Title::makeTitle( $this->mTargetNamespace, |
| 636 | + $origTitle->getDBkey() ); |
| 637 | + } else { |
| 638 | + $title = Title::newFromText( $workTitle ); |
| 639 | + } |
| 640 | + |
| 641 | + if( is_null( $title ) ) { |
| 642 | + // Invalid page title? Ignore the page |
| 643 | + $this->notice( "Skipping invalid page title '$workTitle'" ); |
| 644 | + return false; |
| 645 | + } elseif( $title->getInterwiki() != '' ) { |
| 646 | + $this->notice( "Skipping interwiki page title '$workTitle'" ); |
| 647 | + return false; |
| 648 | + } |
| 649 | + |
| 650 | + return array( $origTitle, $title ); |
| 651 | + } |
| 652 | +} |
| 653 | + |
| 654 | +/** This is a horrible hack used to keep source compatibility */ |
| 655 | +class UploadSourceAdapter { |
| 656 | + static $sourceRegistrations = array(); |
| 657 | + |
| 658 | + private $mSource; |
| 659 | + private $mBuffer; |
| 660 | + private $mPosition; |
| 661 | + |
| 662 | + static function registerSource( $source ) { |
| 663 | + $id = wfGenerateToken(); |
| 664 | + |
| 665 | + self::$sourceRegistrations[$id] = $source; |
| 666 | + |
| 667 | + return $id; |
| 668 | + } |
| 669 | + |
| 670 | + function stream_open( $path, $mode, $options, &$opened_path ) { |
| 671 | + $url = parse_url($path); |
| 672 | + $id = $url['host']; |
| 673 | + |
| 674 | + if ( !isset( self::$sourceRegistrations[$id] ) ) { |
| 675 | + return false; |
| 676 | + } |
| 677 | + |
| 678 | + $this->mSource = self::$sourceRegistrations[$id]; |
| 679 | + |
| 680 | + return true; |
| 681 | + } |
| 682 | + |
| 683 | + function stream_read( $count ) { |
| 684 | + $return = ''; |
| 685 | + $leave = false; |
| 686 | + |
| 687 | + while ( !$leave && !$this->mSource->atEnd() && |
| 688 | + strlen($this->mBuffer) < $count ) { |
| 689 | + $read = $this->mSource->readChunk(); |
| 690 | + |
| 691 | + if ( !strlen($read) ) { |
| 692 | + $leave = true; |
| 693 | + } |
| 694 | + |
| 695 | + $this->mBuffer .= $read; |
| 696 | + } |
| 697 | + |
| 698 | + if ( strlen($this->mBuffer) ) { |
| 699 | + $return = substr( $this->mBuffer, 0, $count ); |
| 700 | + $this->mBuffer = substr( $this->mBuffer, $count ); |
| 701 | + } |
| 702 | + |
| 703 | + $this->mPosition += strlen($return); |
| 704 | + |
| 705 | + return $return; |
| 706 | + } |
| 707 | + |
| 708 | + function stream_write( $data ) { |
| 709 | + return false; |
| 710 | + } |
| 711 | + |
| 712 | + function stream_tell() { |
| 713 | + return $this->mPosition; |
| 714 | + } |
| 715 | + |
| 716 | + function stream_eof() { |
| 717 | + return $this->mSource->atEnd(); |
| 718 | + } |
| 719 | + |
| 720 | + function url_stat() { |
| 721 | + $result = array(); |
| 722 | + |
| 723 | + $result['dev'] = $result[0] = 0; |
| 724 | + $result['ino'] = $result[1] = 0; |
| 725 | + $result['mode'] = $result[2] = 0; |
| 726 | + $result['nlink'] = $result[3] = 0; |
| 727 | + $result['uid'] = $result[4] = 0; |
| 728 | + $result['gid'] = $result[5] = 0; |
| 729 | + $result['rdev'] = $result[6] = 0; |
| 730 | + $result['size'] = $result[7] = 0; |
| 731 | + $result['atime'] = $result[8] = 0; |
| 732 | + $result['mtime'] = $result[9] = 0; |
| 733 | + $result['ctime'] = $result[10] = 0; |
| 734 | + $result['blksize'] = $result[11] = 0; |
| 735 | + $result['blocks'] = $result[12] = 0; |
| 736 | + |
| 737 | + return $result; |
| 738 | + } |
| 739 | +} |
| 740 | + |
| 741 | +class XMLReader2 extends XMLReader { |
| 742 | + function nodeContents() { |
| 743 | + if( $this->isEmptyElement ) { |
| 744 | + return ""; |
| 745 | + } |
| 746 | + $buffer = ""; |
| 747 | + while( $this->read() ) { |
| 748 | + switch( $this->nodeType ) { |
| 749 | + case XmlReader::TEXT: |
| 750 | + case XmlReader::SIGNIFICANT_WHITESPACE: |
| 751 | + $buffer .= $this->value; |
| 752 | + break; |
| 753 | + case XmlReader::END_ELEMENT: |
| 754 | + return $buffer; |
| 755 | + } |
| 756 | + } |
| 757 | + return $this->close(); |
| 758 | + } |
| 759 | +} |
| 760 | + |
| 761 | +/** |
29 | 762 | * @todo document (e.g. one-sentence class description). |
30 | 763 | * @ingroup SpecialPage |
31 | 764 | */ |
Index: branches/REL1_17/phase3/languages/messages/MessagesEn.php |
— | — | @@ -4040,6 +4040,20 @@ |
4041 | 4041 | $5 |
4042 | 4042 | |
4043 | 4043 | This confirmation code will expire at $4.', |
| 4044 | +'confirmemail_body_set' => 'Someone, probably you, from IP address $1, |
| 4045 | +has set the e-mail address of the account "$2" to this address on {{SITENAME}}. |
| 4046 | + |
| 4047 | +To confirm that this account really does belong to you and reactivate |
| 4048 | +e-mail features on {{SITENAME}}, open this link in your browser: |
| 4049 | + |
| 4050 | +$3 |
| 4051 | + |
| 4052 | +If the account does *not* belong to you, follow this link |
| 4053 | +to cancel the e-mail address confirmation: |
| 4054 | + |
| 4055 | +$5 |
| 4056 | + |
| 4057 | +This confirmation code will expire at $4.', |
4044 | 4058 | 'confirmemail_invalidated' => 'E-mail address confirmation canceled', |
4045 | 4059 | 'invalidateemail' => 'Cancel e-mail confirmation', |
4046 | 4060 | |
Index: branches/REL1_17/phase3/RELEASE-NOTES |
— | — | @@ -490,10 +490,12 @@ |
491 | 491 | * (bug 26733) Wrap initial table creation in transaction |
492 | 492 | * (bug 26208) Mark directionality of some interlanguage links |
493 | 493 | * (bug 26716) Provide link to instructions for external editor related preferences. |
| 494 | +* (bug 26961) Hide anon edits in watchlist preference now actually works. |
494 | 495 | |
495 | 496 | === API changes in 1.17 === |
496 | 497 | * BREAKING CHANGE: action=patrol now requires POST |
497 | 498 | * BREAKING CHANGE: patrol token is no longer the same as edit token |
| 499 | +* BREAKING CHANGE: Session keys returned by ApiUpload are now strings instead of integers |
498 | 500 | * (bug 24650) Fix API to work with categorylinks changes |
499 | 501 | * action=parse now correctly returns an error for nonexistent pages |
500 | 502 | |
Property changes on: branches/REL1_17/phase3/RELEASE-NOTES |
___________________________________________________________________ |
Modified: svn:mergeinfo |
501 | 503 | Merged /trunk/phase3/RELEASE-NOTES:r81186-81187,81197,81209-81211,81215,81238,81246,81262,81264 |
Index: branches/REL1_17/phase3/resources/jquery/jquery.checkboxShiftClick.js |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * @author Krinkle <krinklemail@gmail.com> |
8 | 8 | * @license GPL v2 |
9 | 9 | */ |
10 | | - |
| 10 | +( function( $ ) { |
11 | 11 | jQuery.fn.checkboxShiftClick = function( text ) { |
12 | 12 | var prevCheckbox = null; |
13 | 13 | var $box = this; |
— | — | @@ -24,4 +24,5 @@ |
25 | 25 | prevCheckbox = e.target; |
26 | 26 | }); |
27 | 27 | return $box; |
28 | | -}; |
\ No newline at end of file |
| 28 | +}; |
| 29 | +} )( jQuery ); |
\ No newline at end of file |
Index: branches/REL1_17/phase3/resources/jquery/jquery.tabIndex.js |
— | — | @@ -1,4 +1,8 @@ |
2 | 2 | /** |
| 3 | + * jQuery tabIndex |
| 4 | + */ |
| 5 | +( function( $ ) { |
| 6 | +/** |
3 | 7 | * Finds the lowerst tabindex in use within a selection |
4 | 8 | * |
5 | 9 | * @return Integer of lowest tabindex on the page |
— | — | @@ -27,4 +31,5 @@ |
28 | 32 | } |
29 | 33 | } ); |
30 | 34 | return maxTabIndex; |
31 | | -}; |
\ No newline at end of file |
| 35 | +}; |
| 36 | +} )( jQuery ); |
\ No newline at end of file |
Index: branches/REL1_17/phase3/resources/jquery/jquery.delayedBind.js |
— | — | @@ -65,4 +65,4 @@ |
66 | 66 | } ); |
67 | 67 | } |
68 | 68 | } ); |
69 | | -} )( jQuery ); |
| 69 | +} )( jQuery ); |
\ No newline at end of file |
Index: branches/REL1_17/phase3/resources/jquery/jquery.autoEllipsis.js |
— | — | @@ -128,4 +128,4 @@ |
129 | 129 | } ); |
130 | 130 | }; |
131 | 131 | |
132 | | -} )( jQuery ); |
| 132 | +} )( jQuery ); |
\ No newline at end of file |
Index: branches/REL1_17/phase3/resources/jquery/jquery.client.js |
— | — | @@ -1,7 +1,8 @@ |
2 | 2 | /* |
3 | 3 | * User-agent detection |
4 | 4 | */ |
5 | | -jQuery.client = new ( function() { |
| 5 | +( function( $ ) { |
| 6 | +$.client = new ( function() { |
6 | 7 | |
7 | 8 | /* Private Members */ |
8 | 9 | |
— | — | @@ -201,3 +202,5 @@ |
202 | 203 | .addClass( 'client-' + profile.layout ) |
203 | 204 | .addClass( 'client-' + profile.platform ); |
204 | 205 | } ); |
| 206 | + |
| 207 | +} )( jQuery ); |
Index: branches/REL1_17/phase3/resources/jquery/jquery.placeholder.js |
— | — | @@ -8,6 +8,7 @@ |
9 | 9 | * @version 0.2.0 |
10 | 10 | * @license GPL v2 |
11 | 11 | */ |
| 12 | +( function( $ ) { |
12 | 13 | |
13 | 14 | jQuery.fn.placeholder = function() { |
14 | 15 | |
— | — | @@ -58,4 +59,5 @@ |
59 | 60 | }); |
60 | 61 | |
61 | 62 | }); |
62 | | -}; |
\ No newline at end of file |
| 63 | +}; |
| 64 | +} )( jQuery ); |
Index: branches/REL1_17/phase3/resources/mediawiki.util/mediawiki.util.test.js |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | |
10 | 10 | (function ($, mw) { |
11 | 11 | |
12 | | - mediaWiki.test = { |
| 12 | + mw.test = { |
13 | 13 | |
14 | 14 | /* Variables */ |
15 | 15 | '$table' : null, |
— | — | @@ -167,6 +167,6 @@ |
168 | 168 | } |
169 | 169 | }; |
170 | 170 | |
171 | | - mediaWiki.test.init(); |
| 171 | + mw.test.init(); |
172 | 172 | |
173 | | -} )(jQuery, mediaWiki); |
| 173 | +} )(jQuery, mediaWiki); |
\ No newline at end of file |
Index: branches/REL1_17/phase3/resources/mediawiki.util/mediawiki.util.js |
— | — | @@ -1,9 +1,8 @@ |
2 | 2 | /* |
3 | 3 | * Utilities |
4 | 4 | */ |
| 5 | +( function( $, mw ) { |
5 | 6 | |
6 | | -(function ($, mw) { |
7 | | - |
8 | 7 | mediaWiki.util = { |
9 | 8 | |
10 | 9 | /* Initialisation */ |
— | — | @@ -13,7 +12,7 @@ |
14 | 13 | this.initialised = true; |
15 | 14 | |
16 | 15 | // Any initialisation after the DOM is ready |
17 | | - $(function () { |
| 16 | + $( function() { |
18 | 17 | |
19 | 18 | // Shortcut |
20 | 19 | var profile = $.client.profile(); |
— | — | @@ -394,4 +393,4 @@ |
395 | 394 | |
396 | 395 | mediaWiki.util.init(); |
397 | 396 | |
398 | | -})(jQuery, mediaWiki); |
| 397 | +} )( jQuery, mediaWiki ); |
Index: branches/REL1_17/phase3/resources/mediawiki.special/mediawiki.special.search.js |
— | — | @@ -1,8 +1,11 @@ |
2 | 2 | /* |
3 | 3 | * JavaScript for Specical:Search |
4 | 4 | */ |
| 5 | +( function( $, mw ) { |
5 | 6 | |
6 | 7 | // Emulate HTML5 autofocus behavior in non HTML5 compliant browsers |
7 | 8 | if ( !( 'autofocus' in document.createElement( 'input' ) ) ) { |
8 | | - $( 'input[autofocus]' ).focus(); |
| 9 | + $( 'input[autofocus]:first' ).focus(); |
9 | 10 | } |
| 11 | + |
| 12 | +} )( jQuery, mediaWiki ); |
\ No newline at end of file |
Index: branches/REL1_17/phase3/resources/mediawiki.special/mediawiki.special.preferences.js |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | /* |
3 | 3 | * JavaScript for Special:Preferences |
4 | 4 | */ |
| 5 | +( function( $, mw ) { |
5 | 6 | |
6 | 7 | $( '#prefsubmit' ).attr( 'id', 'prefcontrol' ); |
7 | 8 | $( '#preferences' ) |
— | — | @@ -73,3 +74,4 @@ |
74 | 75 | updateMailValidityLabel( $(this).val() ); |
75 | 76 | } ); |
76 | 77 | } ); |
| 78 | +} )( jQuery, mediaWiki ); |
\ No newline at end of file |
Index: branches/REL1_17/phase3/resources/mediawiki.language/mediawiki.language.js |
— | — | @@ -5,8 +5,9 @@ |
6 | 6 | * Language.php in MediaWiki. This object contains methods for loading and |
7 | 7 | * transforming message text. |
8 | 8 | */ |
| 9 | +( function( $, mw ) { |
9 | 10 | |
10 | | -mediaWiki.language = { |
| 11 | +mw.language = { |
11 | 12 | /** |
12 | 13 | * Process the PLURAL template substitution |
13 | 14 | * |
— | — | @@ -19,15 +20,15 @@ |
20 | 21 | * @example {{Template:title|params}} |
21 | 22 | */ |
22 | 23 | 'procPLURAL': function( template ) { |
23 | | - if ( template.title && template.parameters && mediaWiki.language.convertPlural ) { |
| 24 | + if ( template.title && template.parameters && mw.language.convertPlural ) { |
24 | 25 | // Check if we have forms to replace |
25 | 26 | if ( template.parameters.length == 0 ) { |
26 | 27 | return ''; |
27 | 28 | } |
28 | 29 | // Restore the count into a Number ( if it got converted earlier ) |
29 | | - var count = mediaWiki.language.convertNumber( template.title, true ); |
| 30 | + var count = mw.language.convertNumber( template.title, true ); |
30 | 31 | // Do convertPlural call |
31 | | - return mediaWiki.language.convertPlural( parseInt( count ), template.parameters ); |
| 32 | + return mw.language.convertPlural( parseInt( count ), template.parameters ); |
32 | 33 | } |
33 | 34 | // Could not process plural return first form or nothing |
34 | 35 | if ( template.parameters[0] ) { |
— | — | @@ -68,11 +69,11 @@ |
69 | 70 | * @param {boolean} integer Convert the return value to an integer |
70 | 71 | */ |
71 | 72 | 'convertNumber': function( number, integer ) { |
72 | | - if ( !mediaWiki.language.digitTransformTable ) { |
| 73 | + if ( !mw.language.digitTransformTable ) { |
73 | 74 | return number; |
74 | 75 | } |
75 | 76 | // Set the target Transform table: |
76 | | - var transformTable = mediaWiki.language.digitTransformTable; |
| 77 | + var transformTable = mw.language.digitTransformTable; |
77 | 78 | // Check if the "restore" to Latin number flag is set: |
78 | 79 | if ( integer ) { |
79 | 80 | if ( parseInt( number ) == number ) { |
— | — | @@ -98,3 +99,4 @@ |
99 | 100 | // Digit Transform Table, populated by language classes where applicable |
100 | 101 | 'digitTransformTable': null |
101 | 102 | }; |
| 103 | +} )( jQuery, mediaWiki ); |
\ No newline at end of file |