r45711 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45710‎ | r45711 | r45712 >
Date:18:05, 13 January 2009
Author:aaron
Status:ok
Tags:
Comment:
* Short-circuit userWasLastToEdit()
* Move edit conflict suppress check up
* Code style tweaks
Modified paths:
  • /trunk/phase3/includes/EditPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/EditPage.php
@@ -574,7 +574,7 @@
575575 # If the form is incomplete, force to preview.
576576 wfDebug( "$fname: Form data appears to be incomplete\n" );
577577 wfDebug( "POST DATA: " . var_export( $_POST, true ) . "\n" );
578 - $this->preview = true;
 578+ $this->preview = true;
579579 } else {
580580 /* Fallback for live preview */
581581 $this->preview = $request->getCheck( 'wpPreview' ) || $request->getCheck( 'wpLivePreview' );
@@ -900,15 +900,20 @@
901901 }
902902 }
903903 $userid = $wgUser->getId();
 904+
 905+ # Suppress edit conflict with self, except for section edits where merging is required.
 906+ if ( $this->isConflict && $this->section == '' && $this->userWasLastToEdit($userid,$this->edittime) ) {
 907+ wfDebug( "EditPage::editForm Suppressing edit conflict, same user.\n" );
 908+ $this->isConflict = false;
 909+ }
904910
905911 if ( $this->isConflict ) {
906912 wfDebug( "EditPage::editForm conflict! getting section '$this->section' for time '$this->edittime' (article time '" .
907913 $this->mArticle->getTimestamp() . "')\n" );
908 - $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary, $this->edittime);
909 - }
910 - else {
 914+ $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary, $this->edittime );
 915+ } else {
911916 wfDebug( "EditPage::editForm getting section '$this->section'\n" );
912 - $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary);
 917+ $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary );
913918 }
914919 if ( is_null( $text ) ) {
915920 wfDebug( "EditPage::editForm activating conflict; section replace failed.\n" );
@@ -916,23 +921,16 @@
917922 $text = $this->textbox1;
918923 }
919924
920 - # Suppress edit conflict with self, except for section edits where merging is required.
921 - if ( $this->section == '' && $userid && $this->userWasLastToEdit($userid,$this->edittime) ) {
922 - wfDebug( "EditPage::editForm Suppressing edit conflict, same user.\n" );
923 - $this->isConflict = false;
924 - } else {
925 - # switch from section editing to normal editing in edit conflict
926 - if ( $this->isConflict ) {
927 - # Attempt merge
928 - if ( $this->mergeChangesInto( $text ) ) {
929 - // Successful merge! Maybe we should tell the user the good news?
930 - $this->isConflict = false;
931 - wfDebug( "EditPage::editForm Suppressing edit conflict, successful merge.\n" );
932 - } else {
933 - $this->section = '';
934 - $this->textbox1 = $text;
935 - wfDebug( "EditPage::editForm Keeping edit conflict, failed merge.\n" );
936 - }
 925+ if ( $this->isConflict ) {
 926+ # Attempt merge
 927+ if ( $this->mergeChangesInto( $text ) ) {
 928+ // Successful merge! Maybe we should tell the user the good news?
 929+ $this->isConflict = false;
 930+ wfDebug( "EditPage::editForm Suppressing edit conflict, successful merge.\n" );
 931+ } else {
 932+ $this->section = '';
 933+ $this->textbox1 = $text;
 934+ wfDebug( "EditPage::editForm Keeping edit conflict, failed merge.\n" );
937935 }
938936 }
939937
@@ -1015,7 +1013,8 @@
10161014
10171015 # update the article here
10181016 if ( $this->mArticle->updateArticle( $text, $this->summary, $this->minoredit,
1019 - $this->watchthis, $bot, $sectionanchor ) ) {
 1017+ $this->watchthis, $bot, $sectionanchor ) )
 1018+ {
10201019 wfProfileOut( $fname );
10211020 return self::AS_SUCCESS_UPDATE;
10221021 } else {
@@ -1031,6 +1030,7 @@
10321031 * 50 revisions for the sake of performance.
10331032 */
10341033 protected function userWasLastToEdit( $id, $edittime ) {
 1034+ if( !$id ) return false;
10351035 $dbw = wfGetDB( DB_MASTER );
10361036 $res = $dbw->select( 'revision',
10371037 'rev_user',

Status & tagging log