r59876 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59875‎ | r59876 | r59877 >
Date:10:20, 9 December 2009
Author:thomasv
Status:ok
Tags:
Comment:
fix counter bug for pages using old pagequality format
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -861,17 +861,24 @@
862862 return array( -1, null, $new_text );
863863 }
864864
865 - $header_regexp = "/^<pagequality level=\"(0|1|2|3|4)\" user=\"(.*?)\" \/>/";
866865 $header = $m[1];
867866 $body = $m[2];
868867 $footer = $m[3];
869 - if( !preg_match( $header_regexp, $header, $m2 ) ) {
870 - $new_text = "<noinclude><pagequality level=\"1\" user=\"$username\" />"
871 - ."$header\n\n\n</noinclude>$body<noinclude>\n$footer</noinclude>";
872 - return array( -1, null, $new_text );
 868+
 869+ $header_regexp = "/^<pagequality level=\"(0|1|2|3|4)\" user=\"(.*?)\" \/>/";
 870+ if( preg_match( $header_regexp, $header, $m2 ) ) {
 871+ return array( intval($m2[1]), $m2[2], null );
873872 }
874873
875 - return array( intval($m2[1]), $m2[2], null );
 874+ $old_header_regexp = "/^\{\{PageQuality\|(0|1|2|3|4)(|\|(.*?))\}\}/is";
 875+ if( preg_match( $old_header_regexp, $header, $m3 ) ) {
 876+ return array( intval($m3[1]), $m3[3], null );
 877+ }
 878+
 879+ $new_text = "<noinclude><pagequality level=\"1\" user=\"$username\" />"
 880+ ."$header\n\n\n</noinclude>$body<noinclude>\n$footer</noinclude>";
 881+ return array( -1, null, $new_text );
 882+
876883 }
877884
878885
@@ -946,7 +953,7 @@
947954 list( $q , $username, $ptext ) = pr_parse_page( $text );
948955 if( $q == -1 ) {
949956 $editpage->textbox1 = $ptext;
950 - return true;
 957+ $q = 1;
951958 }
952959
953960 //read previous revision, so that I know how much I need to add to pr_index
@@ -954,6 +961,22 @@
955962 if( $rev ) {
956963 $old_text = $rev->getText();
957964 list( $old_q , $old_username, $old_ptext ) = pr_parse_page( $old_text );
 965+ if( $old_q != -1 ) {
 966+ //check usernames
 967+ if( ($old_q != $q) && $wgUser->isAnon() ) {
 968+ $wgOut->showErrorPage( 'proofreadpage_nologin', 'proofreadpage_nologintext' );
 969+ return false;
 970+ }
 971+ if ( ( ($old_username != $username) || ($old_q != $q) ) && ($wgUser->getName() != $username) ) {
 972+ $wgOut->showErrorPage( 'proofreadpage_notallowed', 'proofreadpage_notallowedtext' );
 973+ return false;
 974+ }
 975+ if( ( ($q == 4) && ($old_q < 3) ) || ( ($q == 4) && ($old_q == 3) && ($old_username == $username) ) ) {
 976+ $wgOut->showErrorPage( 'proofreadpage_notallowed', 'proofreadpage_notallowedtext' );
 977+ return false;
 978+ }
 979+ }
 980+ else $old_q = 1;
958981 } else {
959982 if($q == 4) {
960983 $wgOut->showErrorPage( 'proofreadpage_notallowed', 'proofreadpage_notallowedtext' );
@@ -962,22 +985,6 @@
963986 $old_q = -1;
964987 }
965988
966 - //check usernames
967 - if( $old_q != -1 ) {
968 - if( ($old_q != $q) && $wgUser->isAnon() ) {
969 - $wgOut->showErrorPage( 'proofreadpage_nologin', 'proofreadpage_nologintext' );
970 - return false;
971 - }
972 - if ( ( ($old_username != $username) || ($old_q != $q) ) && ($wgUser->getName() != $username) ) {
973 - $wgOut->showErrorPage( 'proofreadpage_notallowed', 'proofreadpage_notallowedtext' );
974 - return false;
975 - }
976 - if( ( ($q == 4) && ($old_q < 3) ) || ( ($q == 4) && ($old_q == 3) && ($old_username == $username) ) ) {
977 - $wgOut->showErrorPage( 'proofreadpage_notallowed', 'proofreadpage_notallowedtext' );
978 - return false;
979 - }
980 - }
981 -
982989 $editpage->mArticle->new_q = $q;
983990 $editpage->mArticle->old_q = $old_q;
984991

Status & tagging log