FOR UPDATE mode for Article class, and for getArticleID function of Title. Using...
[lhc/web/wiklou.git] / includes / EditPage.php
1 <?php
2 # $Id$
3
4 # Splitting edit page/HTML interface from Article...
5 # The actual database and text munging is still in Article,
6 # but it should get easier to call those from alternate
7 # interfaces.
8
9 class EditPage {
10 var $mArticle;
11 var $mTitle;
12
13 # Form values
14 var $save = false, $preview = false;
15 var $minoredit = false, $watchthis = false;
16 var $textbox1 = "", $textbox2 = "", $summary = "";
17 var $edittime = "", $section = "";
18 var $oldid = 0;
19
20 function EditPage( $article ) {
21 $this->mArticle =& $article;
22 global $wgTitle;
23 $this->mTitle =& $wgTitle;
24 }
25
26 # This is the function that gets called for "action=edit".
27
28 function edit()
29 {
30 global $wgOut, $wgUser, $wgWhitelistEdit, $wgRequest;
31 // this is not an article
32 $wgOut->setArticleFlag(false);
33
34 $this->importFormData( $wgRequest );
35
36 if ( ! $this->mTitle->userCanEdit() ) {
37 $wgOut->readOnlyPage( $this->mArticle->getContent( true ), true );
38 return;
39 }
40 if ( $wgUser->isBlocked() ) {
41 $this->blockedIPpage();
42 return;
43 }
44 if ( !$wgUser->getID() && $wgWhitelistEdit ) {
45 $this->userNotLoggedInPage();
46 return;
47 }
48 if ( wfReadOnly() ) {
49 if( $this->save || $this->preview ) {
50 $this->editForm( "preview" );
51 } else {
52 $wgOut->readOnlyPage( $this->mArticle->getContent( true ) );
53 }
54 return;
55 }
56 if ( $this->save ) {
57 $this->editForm( "save" );
58 } else if ( $this->preview ) {
59 $this->editForm( "preview" );
60 } else { # First time through
61 $this->editForm( "initial" );
62 }
63 }
64
65 function importFormData( &$request ) {
66 # These fields need to be checked for encoding.
67 # Also remove trailing whitespace, but don't remove _initial_
68 # whitespace from the text boxes. This may be significant formatting.
69 $this->textbox1 = rtrim( $request->getText( "wpTextbox1" ) );
70 $this->textbox2 = rtrim( $request->getText( "wpTextbox2" ) );
71 $this->summary = trim( $request->getText( "wpSummary" ) );
72
73 $this->edittime = $request->getVal( 'wpEdittime' );
74 if( !preg_match( '/^\d{14}$/', $this->edittime )) $this->edittime = "";
75
76 $this->preview = $request->getCheck( 'wpPreview' );
77 $this->save = $request->wasPosted() && !$this->preview;
78 $this->minoredit = $request->getCheck( 'wpMinoredit' );
79 $this->watchthis = $request->getCheck( 'wpWatchthis' );
80
81 $this->oldid = $request->getInt( 'oldid' );
82
83 # Section edit can come from either the form or a link
84 $this->section = $request->getVal( 'wpSection', $request->getVal( 'section' ) );
85 }
86
87 # Since there is only one text field on the edit form,
88 # pressing <enter> will cause the form to be submitted, but
89 # the submit button value won't appear in the query, so we
90 # Fake it here before going back to edit(). This is kind of
91 # ugly, but it helps some old URLs to still work.
92
93 function submit()
94 {
95 if( !$this->preview ) $this->save = true;
96
97 $this->edit();
98 }
99
100 # The edit form is self-submitting, so that when things like
101 # preview and edit conflicts occur, we get the same form back
102 # with the extra stuff added. Only when the final submission
103 # is made and all is well do we actually save and redirect to
104 # the newly-edited page.
105
106 function editForm( $formtype )
107 {
108 global $wgOut, $wgUser;
109 global $wgLang, $wgParser, $wgTitle;
110 global $wgAllowAnonymousMinor;
111 global $wgWhitelistEdit;
112 global $wgSpamRegex, $wgFilterCallback;
113
114 $sk = $wgUser->getSkin();
115 $isConflict = false;
116 // css / js subpages of user pages get a special treatment
117 $isCssJsSubpage = (Namespace::getUser() == $wgTitle->getNamespace() and preg_match("/\\.(css|js)$/", $wgTitle->getText() ));
118
119 if(!$this->mTitle->getArticleID()) { # new article
120 $wgOut->addWikiText(wfmsg("newarticletext"));
121 }
122
123 if( Namespace::isTalk( $this->mTitle->getNamespace() ) ) {
124 $wgOut->addWikiText(wfmsg("talkpagetext"));
125 }
126
127 # Attempt submission here. This will check for edit conflicts,
128 # and redundantly check for locked database, blocked IPs, etc.
129 # that edit() already checked just in case someone tries to sneak
130 # in the back door with a hand-edited submission URL.
131
132 if ( "save" == $formtype ) {
133 # Check for spam
134 if ( $wgSpamRegex && preg_match( $wgSpamRegex, $this->textbox1, $matches ) ) {
135 $this->spamPage ( $matches );
136 return;
137 }
138 if ( $wgFilterCallback && $wgFilterCallback( $this->mTitle, $this->textbox1, $this->section ) ) {
139 # Error messages or other handling should be performed by the filter function
140 return;
141 }
142 if ( $wgUser->isBlocked() ) {
143 $this->blockedIPpage();
144 return;
145 }
146 if ( !$wgUser->getID() && $wgWhitelistEdit ) {
147 $this->userNotLoggedInPage();
148 return;
149 }
150 if ( wfReadOnly() ) {
151 $wgOut->readOnlyPage();
152 return;
153 }
154
155 # If article is new, insert it.
156 $aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
157 if ( 0 == $aid ) {
158 # Don't save a new article if it's blank.
159 if ( ( "" == $this->textbox1 ) ||
160 ( wfMsg( "newarticletext" ) == $this->textbox1 ) ) {
161 $wgOut->redirect( $this->mTitle->getFullURL() );
162 return;
163 }
164 $this->mArticle->insertNewArticle( $this->textbox1, $this->summary, $this->minoredit, $this->watchthis );
165 return;
166 }
167
168 # Article exists. Check for edit conflict.
169
170 $this->mArticle->clear(); # Force reload of dates, etc.
171 $this->mArticle->forUpdate( true ); # Lock the article
172
173 if( ( $this->section != "new" ) &&
174 ($this->mArticle->getTimestamp() != $this->edittime ) ) {
175 $isConflict = true;
176 }
177 $userid = $wgUser->getID();
178
179 $text = $this->mArticle->getTextOfLastEditWithSectionReplacedOrAdded(
180 $this->section, $this->textbox1, $this->summary);
181 # Suppress edit conflict with self
182
183 if ( ( 0 != $userid ) && ( $this->mArticle->getUser() == $userid ) ) {
184 $isConflict = false;
185 } else {
186 # switch from section editing to normal editing in edit conflict
187 if($isConflict) {
188 # Attempt merge
189 if( $this->mergeChangesInto( $text ) ){
190 // Successful merge! Maybe we should tell the user the good news?
191 $isConflict = false;
192 } else {
193 $this->section = "";
194 $this->textbox1 = $text;
195 }
196 }
197 }
198 if ( ! $isConflict ) {
199 # All's well
200 $sectionanchor = '';
201 if( $this->section != '' ) {
202 # Try to get a section anchor from the section source, redirect to edited section if header found
203 # XXX: might be better to integrate this into Article::getTextOfLastEditWithSectionReplacedOrAdded
204 # for duplicate heading checking and maybe parsing
205 $hasmatch = preg_match( "/^ *([=]{1,6})(.*?)(\\1) *\\n/i", $this->textbox1, $matches );
206 # we can't deal with anchors, includes, html etc in the header for now,
207 # headline would need to be parsed to improve this
208 #if($hasmatch and strlen($matches[2]) > 0 and !preg_match( "/[\\['{<>]/", $matches[2])) {
209 if($hasmatch and strlen($matches[2]) > 0) {
210 global $wgInputEncoding;
211 $headline = do_html_entity_decode( $matches[2], ENT_COMPAT, $wgInputEncoding );
212 # strip out HTML
213 $headline = preg_replace( "/<.*?" . ">/","",$headline );
214 $headline = trim( $headline );
215 $sectionanchor = '#'.urlencode( str_replace(' ', '_', $headline ) );
216 $replacearray = array(
217 '%3A' => ':',
218 '%' => '.'
219 );
220 $sectionanchor = str_replace(array_keys($replacearray),array_values($replacearray),$sectionanchor);
221 }
222 }
223
224 # update the article here
225 if($this->mArticle->updateArticle( $text, $this->summary, $this->minoredit, $this->watchthis, '', $sectionanchor ))
226 return;
227 else
228 $isConflict = true;
229 }
230 }
231 # First time through: get contents, set time for conflict
232 # checking, etc.
233
234 if ( "initial" == $formtype ) {
235 $this->edittime = $this->mArticle->getTimestamp();
236 $this->textbox1 = $this->mArticle->getContent( true );
237 $this->summary = "";
238 $this->proxyCheck();
239 }
240 $wgOut->setRobotpolicy( "noindex,nofollow" );
241
242 # Enabled article-related sidebar, toplinks, etc.
243 $wgOut->setArticleRelated( true );
244
245 if ( $isConflict ) {
246 $s = wfMsg( "editconflict", $this->mTitle->getPrefixedText() );
247 $wgOut->setPageTitle( $s );
248 $wgOut->addHTML( wfMsg( "explainconflict" ) );
249
250 $this->textbox2 = $this->textbox1;
251 $this->textbox1 = $this->mArticle->getContent( true );
252 $this->edittime = $this->mArticle->getTimestamp();
253 } else {
254 $s = wfMsg( "editing", $this->mTitle->getPrefixedText() );
255
256 if( $this->section != "" ) {
257 if( $this->section == "new" ) {
258 $s.=wfMsg("commentedit");
259 } else {
260 $s.=wfMsg("sectionedit");
261 }
262 if(!$this->preview) {
263 $sectitle=preg_match("/^=+(.*?)=+/mi",
264 $this->textbox1,
265 $matches);
266 if( !empty( $matches[1] ) ) {
267 $this->summary = "/* ". trim($matches[1])." */ ";
268 }
269 }
270 }
271 $wgOut->setPageTitle( $s );
272 if ( $this->oldid ) {
273 $this->mArticle->setOldSubtitle();
274 $wgOut->addHTML( wfMsg( "editingold" ) );
275 }
276 }
277
278 if( wfReadOnly() ) {
279 $wgOut->addHTML( "<strong>" .
280 wfMsg( "readonlywarning" ) .
281 "</strong>" );
282 } else if ( $isCssJsSubpage and "preview" != $formtype) {
283 $wgOut->addHTML( wfMsg( "usercssjsyoucanpreview" ));
284 }
285 if( $this->mTitle->isProtected() ) {
286 $wgOut->addHTML( "<strong>" . wfMsg( "protectedpagewarning" ) .
287 "</strong><br />\n" );
288 }
289
290 $kblength = (int)(strlen( $this->textbox1 ) / 1024);
291 if( $kblength > 29 ) {
292 $wgOut->addHTML( "<strong>" .
293 wfMsg( "longpagewarning", $kblength )
294 . "</strong>" );
295 }
296
297 $rows = $wgUser->getOption( "rows" );
298 $cols = $wgUser->getOption( "cols" );
299
300 $ew = $wgUser->getOption( "editwidth" );
301 if ( $ew ) $ew = " style=\"width:100%\"";
302 else $ew = "" ;
303
304 $q = "action=submit";
305 #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
306 $action = $this->mTitle->escapeLocalURL( $q );
307
308 $summary = wfMsg( "summary" );
309 $subject = wfMsg("subject");
310 $minor = wfMsg( "minoredit" );
311 $watchthis = wfMsg ("watchthis");
312 $save = wfMsg( "savearticle" );
313 $prev = wfMsg( "showpreview" );
314
315 $cancel = $sk->makeKnownLink( $this->mTitle->getPrefixedText(),
316 wfMsg( "cancel" ) );
317 $edithelpurl = $sk->makeUrl( wfMsg( 'edithelppage' ));
318 $edithelp = '<a target="helpwindow" href="'.$edithelpurl.'">'.
319 htmlspecialchars( wfMsg( 'edithelp' ) ).'</a> '.
320 htmlspecialchars( wfMsg( 'newwindow' ) );
321
322 global $wgRightsText;
323 $copywarn = "<div id=\"editpage-copywarn\">\n" .
324 wfMsg( $wgRightsText ? "copyrightwarning" : "copyrightwarning2",
325 "[[" . wfMsg( "copyrightpage" ) . "]]",
326 $wgRightsText ) . "\n</div>";
327
328 if( $wgUser->getOption("showtoolbar") and !$isCssJsSubpage ) {
329 # prepare toolbar for edit buttons
330 $toolbar = $sk->getEditToolbar();
331 } else {
332 $toolbar = "";
333 }
334
335 // activate checkboxes if user wants them to be always active
336 if( !$this->preview ) {
337 if( $wgUser->getOption( "watchdefault" ) ) $this->watchthis = true;
338 if( $wgUser->getOption( "minordefault" ) ) $this->minoredit = true;
339
340 // activate checkbox also if user is already watching the page,
341 // require wpWatchthis to be unset so that second condition is not
342 // checked unnecessarily
343 if( !$this->watchthis && $this->mTitle->userIsWatching() ) $this->watchthis = true;
344 }
345
346 $minoredithtml = "";
347
348 if ( 0 != $wgUser->getID() || $wgAllowAnonymousMinor ) {
349 $minoredithtml =
350 "<input tabindex='3' type='checkbox' value='1' name='wpMinoredit'".($this->minoredit?" checked='checked'":"").
351 " accesskey='".wfMsg('accesskey-minoredit')."' id='wpMinoredit' />".
352 "<label for='wpMinoredit' title='".wfMsg('tooltip-minoredit')."'>{$minor}</label>";
353 }
354
355 $watchhtml = "";
356
357 if ( 0 != $wgUser->getID() ) {
358 $watchhtml = "<input tabindex='4' type='checkbox' name='wpWatchthis'".($this->watchthis?" checked='checked'":"").
359 " accesskey='".wfMsg('accesskey-watch')."' id='wpWatchthis' />".
360 "<label for='wpWatchthis' title='".wfMsg('tooltip-watch')."'>{$watchthis}</label>";
361 }
362
363 $checkboxhtml = $minoredithtml . $watchhtml . "<br />";
364
365 if ( "preview" == $formtype) {
366 $previewhead="<h2>" . wfMsg( "preview" ) . "</h2>\n<p><center><font color=\"#cc0000\">" .
367 wfMsg( "note" ) . wfMsg( "previewnote" ) . "</font></center></p>\n";
368 if ( $isConflict ) {
369 $previewhead.="<h2>" . wfMsg( "previewconflict" ) .
370 "</h2>\n";
371 }
372
373 $parserOptions = ParserOptions::newFromUser( $wgUser );
374 $parserOptions->setUseCategoryMagic( false );
375 $parserOptions->setEditSection( false );
376 $parserOptions->setEditSectionOnRightClick( false );
377
378 # don't parse user css/js, show message about preview
379 # XXX: stupid php bug won't let us use $wgTitle->isCssJsSubpage() here
380
381 if ( $isCssJsSubpage ) {
382 if(preg_match("/\\.css$/", $wgTitle->getText() ) ) {
383 $previewtext = wfMsg('usercsspreview');
384 } else if(preg_match("/\\.js$/", $wgTitle->getText() ) ) {
385 $previewtext = wfMsg('userjspreview');
386 }
387 $parserOutput = $wgParser->parse( $previewtext , $wgTitle, $parserOptions );
388 $wgOut->addHTML( $parserOutput->mText );
389 } else {
390 $parserOutput = $wgParser->parse( $this->mArticle->preSaveTransform( $this->textbox1 ) ."\n\n",
391 $wgTitle, $parserOptions );
392 $previewHTML = $parserOutput->mText;
393
394 if($wgUser->getOption("previewontop")) {
395 $wgOut->addHTML($previewhead);
396 $wgOut->addHTML($previewHTML);
397 }
398 $wgOut->addCategoryLinks($parserOutput->getCategoryLinks());
399 $wgOut->addLanguageLinks($parserOutput->getLanguageLinks());
400 $wgOut->addHTML( "<br style=\"clear:both;\" />\n" );
401 }
402 }
403
404 # if this is a comment, show a subject line at the top, which is also the edit summary.
405 # Otherwise, show a summary field at the bottom
406 $summarytext = htmlspecialchars( $wgLang->recodeForEdit( $this->summary ) ); # FIXME
407 if( $this->section == "new" ) {
408 $commentsubject="{$subject}: <input tabindex='1' type='text' value=\"$summarytext\" name=\"wpSummary\" maxlength='200' size='60' /><br />";
409 $editsummary = "";
410 } else {
411 $commentsubject = "";
412 $editsummary="{$summary}: <input tabindex='3' type='text' value=\"$summarytext\" name=\"wpSummary\" maxlength='200' size='60' /><br />";
413 }
414
415 if( !$this->preview ) {
416 # Don't select the edit box on preview; this interferes with seeing what's going on.
417 $wgOut->setOnloadHandler( "document.editform.wpTextbox1.focus()" );
418 }
419 # Prepare a list of templates used by this page
420 $db =& wfGetDB( DB_SLAVE );
421 $cur = $db->tableName( 'cur' );
422 $links = $db->tableName( 'links' );
423 $id = $this->mTitle->getArticleID();
424 $sql = "SELECT cur_namespace,cur_title,cur_id ".
425 "FROM $cur,$links WHERE l_to=cur_id AND l_from={$id} and cur_namespace=".NS_TEMPLATE;
426 $res = $db->query( $sql, "EditPage::editform" );
427
428 if ( $db->numRows( $res ) ) {
429 $templates = '<br />'. wfMsg( 'templatesused' ) . '<ul>';
430 while ( $row = $db->fetchObject( $res ) ) {
431 if ( $titleObj = Title::makeTitle( $row->cur_namespace, $row->cur_title ) ) {
432 $templates .= '<li>' . $sk->makeLinkObj( $titleObj ) . '</li>';
433 }
434 }
435 $templates .= '</ul>';
436 }
437 $wgOut->addHTML( "
438 {$toolbar}
439 <form id=\"editform\" name=\"editform\" method=\"post\" action=\"$action\"
440 enctype=\"application/x-www-form-urlencoded\">
441 {$commentsubject}
442 <textarea tabindex='1' accesskey=\",\" name=\"wpTextbox1\" rows='{$rows}'
443 cols='{$cols}'{$ew}>" .
444 htmlspecialchars( $wgLang->recodeForEdit( $this->textbox1 ) ) .
445 "
446 </textarea>
447 <br />{$editsummary}
448 {$checkboxhtml}
449 <input tabindex='5' id='wpSave' type='submit' value=\"{$save}\" name=\"wpSave\" accesskey=\"".wfMsg('accesskey-save')."\"".
450 " title=\"".wfMsg('tooltip-save')."\"/>
451 <input tabindex='6' id='wpPreview' type='submit' value=\"{$prev}\" name=\"wpPreview\" accesskey=\"".wfMsg('accesskey-preview')."\"".
452 " title=\"".wfMsg('tooltip-preview')."\"/>
453 <em>{$cancel}</em> | <em>{$edithelp}</em>{$templates}" );
454 $wgOut->addWikiText( $copywarn );
455 $wgOut->addHTML( "
456 <input type='hidden' value=\"" . htmlspecialchars( $this->section ) . "\" name=\"wpSection\" />
457 <input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n" );
458
459 if ( $isConflict ) {
460 $wgOut->addHTML( "<h2>" . wfMsg( "yourdiff" ) . "</h2>\n" );
461 DifferenceEngine::showDiff( $this->textbox2, $this->textbox1,
462 wfMsg( "yourtext" ), wfMsg( "storedversion" ) );
463
464 $wgOut->addHTML( "<h2>" . wfMsg( "yourtext" ) . "</h2>
465 <textarea tabindex=6 id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}' wrap='virtual'>"
466 . htmlspecialchars( $wgLang->recodeForEdit( $this->textbox2 ) ) .
467 "
468 </textarea>" );
469 }
470 $wgOut->addHTML( "</form>\n" );
471 if($formtype =="preview" && !$wgUser->getOption("previewontop")) {
472 $wgOut->addHTML($previewhead);
473 $wgOut->addHTML($previewHTML);
474 }
475 }
476
477 function blockedIPpage()
478 {
479 global $wgOut, $wgUser, $wgLang, $wgIP;
480
481 $wgOut->setPageTitle( wfMsg( "blockedtitle" ) );
482 $wgOut->setRobotpolicy( "noindex,nofollow" );
483 $wgOut->setArticleRelated( false );
484
485 $id = $wgUser->blockedBy();
486 $reason = $wgUser->blockedFor();
487 $ip = $wgIP;
488
489 if ( is_numeric( $id ) ) {
490 $name = User::whoIs( $id );
491 } else {
492 $name = $id;
493 }
494 $link = "[[" . $wgLang->getNsText( Namespace::getUser() ) .
495 ":{$name}|{$name}]]";
496
497 $wgOut->addWikiText( wfMsg( "blockedtext", $link, $reason, $ip, $name ) );
498 $wgOut->returnToMain( false );
499 }
500
501
502
503 function userNotLoggedInPage()
504 {
505 global $wgOut, $wgUser, $wgLang;
506
507 $wgOut->setPageTitle( wfMsg( "whitelistedittitle" ) );
508 $wgOut->setRobotpolicy( "noindex,nofollow" );
509 $wgOut->setArticleRelated( false );
510
511 $wgOut->addWikiText( wfMsg( "whitelistedittext" ) );
512 $wgOut->returnToMain( false );
513 }
514
515 function spamPage ( $matches = array() )
516 {
517 global $wgOut;
518 $wgOut->setPageTitle( wfMsg( "spamprotectiontitle" ) );
519 $wgOut->setRobotpolicy( "noindex,nofollow" );
520 $wgOut->setArticleRelated( false );
521
522 $wgOut->addWikiText( wfMsg( 'spamprotectiontext' ) );
523 if ( isset ( $matches[0] ) ) {
524 $wgOut->addWikiText( wfMsg( 'spamprotectionmatch', "<nowiki>{$matches[0]}</nowiki>" ) );
525 }
526 $wgOut->returnToMain( false );
527 }
528
529 # Forks processes to scan the originating IP for an open proxy server
530 # MemCached can be used to skip IPs that have already been scanned
531 function proxyCheck()
532 {
533 global $wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath;
534 global $wgIP, $wgUseMemCached, $wgMemc, $wgDBname, $wgProxyMemcExpiry;
535
536 if ( !$wgBlockOpenProxies ) {
537 return;
538 }
539
540 # Get MemCached key
541 $skip = false;
542 if ( $wgUseMemCached ) {
543 $mcKey = "$wgDBname:proxy:ip:$wgIP";
544 $mcValue = $wgMemc->get( $mcKey );
545 if ( $mcValue ) {
546 $skip = true;
547 }
548 }
549
550 # Fork the processes
551 if ( !$skip ) {
552 $title = Title::makeTitle( NS_SPECIAL, "Blockme" );
553 $iphash = md5( $wgIP . $wgProxyKey );
554 $url = $title->getFullURL( "ip=$iphash" );
555
556 foreach ( $wgProxyPorts as $port ) {
557 $params = implode( " ", array(
558 escapeshellarg( $wgProxyScriptPath ),
559 escapeshellarg( $wgIP ),
560 escapeshellarg( $port ),
561 escapeshellarg( $url )
562 ));
563 exec( "php $params &>/dev/null &" );
564 }
565 # Set MemCached key
566 if ( $wgUseMemCached ) {
567 $wgMemc->set( $mcKey, 1, $wgProxyMemcExpiry );
568 }
569 }
570 }
571
572 /* private */ function mergeChangesInto( &$text ){
573 $fname = 'EditPage::mergeChangesInto';
574 $oldDate = $this->edittime;
575 $dbw =& wfGetDB( DB_MASTER );
576 $obj = $dbw->getArray( 'cur', array( 'cur_text' ), array( 'cur_id' => $this->mTitle->getArticleID() ),
577 $fname, 'FOR UPDATE' );
578
579 $yourtext = $obj->cur_text;
580 $ns = $this->mTitle->getNamespace();
581 $title = $this->mTitle->getDBkey();
582 $obj = $dbw->getArray( 'old',
583 array( 'old_text','old_flags'),
584 array( 'old_namespace' => $ns, 'old_title' => $title,
585 'old_timestamp' => $dbw->timestamp($oldDate)),
586 $fname );
587 $oldText = Article::getRevisionText( $obj );
588
589 if(wfMerge($oldText, $text, $yourtext, $result)){
590 $text = $result;
591 return true;
592 } else {
593 return false;
594 }
595 }
596 }
597
598 ?>