Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -574,7 +574,7 @@ |
575 | 575 | # If the form is incomplete, force to preview. |
576 | 576 | wfDebug( "$fname: Form data appears to be incomplete\n" ); |
577 | 577 | wfDebug( "POST DATA: " . var_export( $_POST, true ) . "\n" ); |
578 | | - $this->preview = true; |
| 578 | + $this->preview = true; |
579 | 579 | } else { |
580 | 580 | /* Fallback for live preview */ |
581 | 581 | $this->preview = $request->getCheck( 'wpPreview' ) || $request->getCheck( 'wpLivePreview' ); |
— | — | @@ -900,15 +900,20 @@ |
901 | 901 | } |
902 | 902 | } |
903 | 903 | $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 | + } |
904 | 910 | |
905 | 911 | if ( $this->isConflict ) { |
906 | 912 | wfDebug( "EditPage::editForm conflict! getting section '$this->section' for time '$this->edittime' (article time '" . |
907 | 913 | $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 { |
911 | 916 | 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 ); |
913 | 918 | } |
914 | 919 | if ( is_null( $text ) ) { |
915 | 920 | wfDebug( "EditPage::editForm activating conflict; section replace failed.\n" ); |
— | — | @@ -916,23 +921,16 @@ |
917 | 922 | $text = $this->textbox1; |
918 | 923 | } |
919 | 924 | |
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" ); |
937 | 935 | } |
938 | 936 | } |
939 | 937 | |
— | — | @@ -1015,7 +1013,8 @@ |
1016 | 1014 | |
1017 | 1015 | # update the article here |
1018 | 1016 | if ( $this->mArticle->updateArticle( $text, $this->summary, $this->minoredit, |
1019 | | - $this->watchthis, $bot, $sectionanchor ) ) { |
| 1017 | + $this->watchthis, $bot, $sectionanchor ) ) |
| 1018 | + { |
1020 | 1019 | wfProfileOut( $fname ); |
1021 | 1020 | return self::AS_SUCCESS_UPDATE; |
1022 | 1021 | } else { |
— | — | @@ -1031,6 +1030,7 @@ |
1032 | 1031 | * 50 revisions for the sake of performance. |
1033 | 1032 | */ |
1034 | 1033 | protected function userWasLastToEdit( $id, $edittime ) { |
| 1034 | + if( !$id ) return false; |
1035 | 1035 | $dbw = wfGetDB( DB_MASTER ); |
1036 | 1036 | $res = $dbw->select( 'revision', |
1037 | 1037 | 'rev_user', |