r25840 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25839‎ | r25840 | r25841 >
Date:00:06, 14 September 2007
Author:yurik
Status:old
Tags:
Comment:
Matched against the trunk r25837 to ease future merge process.
Modified paths:
  • /branches/ApiEdit_Vodafone/includes/AutoLoader.php (modified) (history)
  • /branches/ApiEdit_Vodafone/includes/EditPage.php (modified) (history)
  • /branches/ApiEdit_Vodafone/includes/SpecialUpload.php (modified) (history)
  • /branches/ApiEdit_Vodafone/includes/SpecialUserlogin.php (modified) (history)

Diff [purge]

Index: branches/ApiEdit_Vodafone/includes/SpecialUpload.php
@@ -357,7 +357,6 @@
358358 {
359359 wfDebug( "Hook 'UploadForm:BeforeProcessing' broke processing the file." );
360360 return self::BEFORE_PROCESSING;
361 -
362361 }
363362
364363 /* Check for PHP error if any, requires php 4.2 or newer */
@@ -399,7 +398,6 @@
400399 $partname .= '.' . $ext[$i];
401400 }
402401
403 -
404402 if( strlen( $partname ) < 1 ) {
405403 return self::MIN_LENGHT_PARTNAME;
406404 }
@@ -410,7 +408,6 @@
411409 */
412410 $filtered = preg_replace ( "/[^".Title::legalChars()."]|:/", '-', $filtered );
413411 $nt = Title::makeTitleSafe( NS_IMAGE, $filtered );
414 -
415412 if( is_null( $nt ) ) {
416413 $resultDetails = array( 'filtered' => $filtered );
417414 return self::ILLEGAL_FILENAME;
@@ -439,10 +436,8 @@
440437 /* Don't allow users to override the blacklist (check file extension) */
441438 global $wgStrictFileExtensions;
442439 global $wgFileExtensions, $wgFileBlacklist;
443 -
444440 if ($finalExt == '') {
445441 return self::FILETYPE_MISSING;
446 -
447442 } elseif ( $this->checkFileExtensionList( $ext, $wgFileBlacklist ) ||
448443 ($wgStrictFileExtensions && !$this->checkFileExtension( $finalExt, $wgFileExtensions ) ) ) {
449444 $resultDetails = array( 'finalExt' => $finalExt );
@@ -481,6 +476,7 @@
482477 */
483478 if ( ! $this->mIgnoreWarning ) {
484479 $warning = '';
 480+
485481 global $wgCapitalLinks;
486482 if( $wgCapitalLinks ) {
487483 $filtered = ucfirst( $filtered );
@@ -511,7 +507,6 @@
512508 if ( !$this->mDestWarningAck ) {
513509 $warning .= self::getExistsWarning( $this->mLocalFile );
514510 }
515 -
516511 if( $warning != '' ) {
517512 /**
518513 * Stash the file in a temporary location; the user can choose
@@ -656,7 +651,6 @@
657652 $llink = $sk->makeKnownLinkObj( $ltitle, wfMsgHtml( 'deletionlog' ),
658653 'type=delete&page=' . $file->getTitle()->getPrefixedUrl() );
659654 $warning .= '<li>' . wfMsgWikiHtml( 'filewasdeleted', $llink ) . '</li>';
660 -
661655 }
662656 return $warning;
663657 }
@@ -1160,6 +1154,7 @@
11611155 #check mime type, if desired
11621156 global $wgVerifyMimeType;
11631157 if ($wgVerifyMimeType) {
 1158+
11641159 wfDebug ( "\n\nmime: <$mime> extension: <$extension>\n\n");
11651160 #check mime type against file extension
11661161 if( !$this->verifyExtension( $mime, $extension ) ) {
@@ -1170,7 +1165,6 @@
11711166 global $wgMimeTypeBlacklist;
11721167 if( isset($wgMimeTypeBlacklist) && !is_null($wgMimeTypeBlacklist)
11731168 && $this->checkFileExtension( $mime, $wgMimeTypeBlacklist ) ) {
1174 -
11751169 return new WikiErrorMsg( 'filetype-badmime', htmlspecialchars( $mime ) );
11761170 }
11771171 }
@@ -1189,7 +1183,6 @@
11901184 }
11911185
11921186 wfDebug( __METHOD__.": all clear; passing.\n" );
1193 -
11941187 return true;
11951188 }
11961189
@@ -1563,5 +1556,3 @@
15641557 return $pageText;
15651558 }
15661559 }
1567 -
1568 -
Index: branches/ApiEdit_Vodafone/includes/SpecialUserlogin.php
@@ -8,7 +8,6 @@
99 * constructor
1010 */
1111 function wfSpecialUserlogin() {
12 -
1312 global $wgRequest;
1413 if( session_id() == '' ) {
1514 wfSetupSession();
@@ -57,7 +56,6 @@
5857 const ERROR = 30;
5958 const SUCCESFUL_LOGIN = 31;
6059
61 -
6260 var $mName, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted;
6361 var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword;
6462 var $mLoginattempt, $mRemember, $mEmail, $mDomain, $mLanguage;
@@ -76,8 +74,6 @@
7775 $this->mRetype = $request->getText( 'wpRetype' );
7876 $this->mDomain = $request->getText( 'wpDomain' );
7977 $this->mReturnTo = $request->getVal( 'returnto' );
80 -
81 -
8278 $this->mCookieCheck = $request->getVal( 'wpCookieCheck' );
8379 $this->mPosted = $request->wasPosted();
8480 $this->mCreateaccount = $request->getCheck( 'wpCreateaccount' );
@@ -115,7 +111,7 @@
116112 function execute() {
117113 $resultDetails = null;
118114 $value = null;
119 -
 115+
120116 if ( !is_null( $this->mCookieCheck ) ) {
121117 $value = $this->onCookieRedirectCheck( $this->mCookieCheck, $resultDetails );
122118 return $this->processRest($value, $resultDetails);
@@ -167,6 +163,7 @@
168164 }
169165 }
170166
 167+
171168 /**
172169 * @private
173170 */
@@ -259,7 +256,6 @@
260257 {
261258 $results['ip'] = $ip;
262259 return self::SORBS;
263 -
264260 }
265261
266262 # Now create a dummy user ($u) and check if it is valid
@@ -267,22 +263,18 @@
268264 $u = User::newFromName( $name, 'creatable' );
269265 if ( is_null( $u ) ) {
270266 return self::NO_NAME;
271 -
272267 }
273268
274269 if ( 0 != $u->idForName() ) {
275270 return self::USER_EXISTS;
276 -
277271 }
278272
279273 if ( 0 != strcmp( $this->mPassword, $this->mRetype ) ) {
280274 return self::BAD_RETYPE;
281 -
282275 }
283276
284277 if ( !$u->isValidPassword( $this->mPassword ) ) {
285278 return self::TOO_SHORT;
286 -
287279 }
288280
289281 # Set some additional data so the AbortNewAccount hook can be
@@ -296,7 +288,6 @@
297289 wfDebug( "LoginForm::addNewAccountInternal: a hook blocked creation\n" );
298290 $results['error'] = $abortError;
299291 return self::ABORT_ERROR;
300 -
301292 }
302293
303294 if ( $wgAccountCreationThrottle && $wgUser->isPingLimitable() ) {
@@ -313,7 +304,6 @@
314305
315306 if( !$wgAuth->addUser( $u, $this->mPassword, $this->mEmail, $this->mRealName ) ) {
316307 return self::DB_ERROR;
317 -
318308 }
319309
320310 return $this->initUser( $u, false );
@@ -611,35 +601,29 @@
612602
613603 if( !$wgAuth->allowPasswordChange() ) {
614604 return self::RESETPASS_FORBIDDEN;
615 -
616605 }
617606
618607 # Check against blocked IPs
619608 # fixme -- should we not?
620609 if( $wgUser->isBlocked() ) {
621610 return self::MAILPASSWORD_BLOCKED;
622 -
623611 }
624612
625613 # Check against the rate limiter
626614 if( $wgUser->pingLimiter( 'mailpassword' ) ) {
627615 return self::RATE_LIMITED;
628 -
629616 }
630617
631618 if ( '' == $this->mName ) {
632619 return self::NO_NAME;
633 -
634620 }
635621 $u = User::newFromName( $this->mName );
636622 if( is_null( $u ) ) {
637623 return self::NO_NAME;
638 -
639624 }
640625 if ( 0 == $u->getID() ) {
641626 $results['user']=$u;
642627 return self::NO_SUCH_USER;
643 -
644628 }
645629
646630 # Check against password throttle
Index: branches/ApiEdit_Vodafone/includes/EditPage.php
@@ -16,7 +16,7 @@
1717 const AS_SUCCESS_NEW_ARTICLE = 201;
1818 const AS_HOOK_ERROR = 210;
1919 const AS_FILTERING = 211;
20 - const AS_HOOK_ERROR_EXPECTED = 212;
 20+ const AS_HOOK_ERROR_EXPECTED = 212;
2121 const AS_BLOCKED_PAGE_FOR_USER = 215;
2222 const AS_CONTENT_TOO_BIG = 216;
2323 const AS_USER_CANNOT_EDIT = 217;
@@ -364,7 +364,7 @@
365365 {
366366 if ($this->edit) {
367367 $this->formtype = 'preview';
368 - } else if ($this->save || $this->preview || $this->diff) {
 368+ } elseif ($this->save || $this->preview || $this->diff) {
369369 $remove[] = $error;
370370 }
371371 }
@@ -663,7 +663,6 @@
664664 {
665665 wfDebug( "Hook 'EditPage::attemptSave' aborted article saving" );
666666 return self::AS_HOOK_ERROR;
667 -// return false;
668667 }
669668
670669 # Reintegrate metadata
@@ -677,27 +676,23 @@
678677 wfProfileOut( "$fname-checks" );
679678 wfProfileOut( $fname );
680679 return self::AS_SPAM_ERROR;
681 -// return false;
682680 }
683681 if ( $wgFilterCallback && $wgFilterCallback( $this->mTitle, $this->textbox1, $this->section ) ) {
684682 # Error messages or other handling should be performed by the filter function
685683 wfProfileOut( $fname );
686684 wfProfileOut( "$fname-checks" );
687685 return self::AS_FILTERING;
688 -// return false;
689686 }
690687 if ( !wfRunHooks( 'EditFilter', array( $this, $this->textbox1, $this->section, &$this->hookError ) ) ) {
691688 # Error messages etc. could be handled within the hook...
692689 wfProfileOut( $fname );
693690 wfProfileOut( "$fname-checks" );
694 - return AS_HOOK_ERROR;
695 -// return false;
 691+ return self::AS_HOOK_ERROR;
696692 } elseif( $this->hookError != '' ) {
697693 # ...or the hook could be expecting us to produce an error
698694 wfProfileOut( "$fname-checks " );
699695 wfProfileOut( $fname );
700696 return self::AS_HOOK_ERROR_EXPECTED;
701 -// return true;
702697 }
703698 if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) {
704699 # Check block state against master, thus 'false'.
@@ -705,7 +700,6 @@
706701 wfProfileOut( "$fname-checks" );
707702 wfProfileOut( $fname );
708703 return self::AS_BLOCKED_PAGE_FOR_USER;
709 -// return false;
710704 }
711705 $this->kblength = (int)(strlen( $this->textbox1 ) / 1024);
712706 if ( $this->kblength > $wgMaxArticleSize ) {
@@ -714,7 +708,6 @@
715709 wfProfileOut( "$fname-checks" );
716710 wfProfileOut( $fname );
717711 return self::AS_CONTENT_TOO_BIG;
718 -// return true;
719712 }
720713
721714 if ( !$wgUser->isAllowed('edit') ) {
@@ -723,14 +716,12 @@
724717 wfProfileOut( "$fname-checks" );
725718 wfProfileOut( $fname );
726719 return self::AS_READ_ONLY_PAGE_ANON;
727 -// return false;
728720 }
729721 else {
730722 // $wgOut->readOnlyPage();
731723 wfProfileOut( "$fname-checks" );
732724 wfProfileOut( $fname );
733725 return self::AS_READ_ONLY_PAGE_LOGGED;
734 -// return false;
735726 }
736727 }
737728
@@ -739,14 +730,12 @@
740731 wfProfileOut( "$fname-checks" );
741732 wfProfileOut( $fname );
742733 return self::AS_READ_ONLY_PAGE;
743 -// return false;
744734 }
745735 if ( $wgUser->pingLimiter() ) {
746736 // $wgOut->rateLimited();
747737 wfProfileOut( "$fname-checks" );
748738 wfProfileOut( $fname );
749739 return self::AS_RATE_LIMITED;
750 -// return false;
751740 }
752741
753742 # If the article has been deleted while editing, don't save it without
@@ -755,7 +744,6 @@
756745 wfProfileOut( "$fname-checks" );
757746 wfProfileOut( $fname );
758747 return self::AS_ARTICLE_WAS_DELETED;
759 -// return true;
760748 }
761749
762750 wfProfileOut( "$fname-checks" );
@@ -763,33 +751,37 @@
764752 # If article is new, insert it.
765753 $aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
766754 if ( 0 == $aid ) {
 755+
767756 // Late check for create permission, just in case *PARANOIA*
768757 if ( !$this->mTitle->userCan( 'create' ) ) {
769758 wfDebug( "$fname: no create permission\n" );
 759+// $this->noCreatePermission();
770760 wfProfileOut( $fname );
771761 return self::AS_NO_CREATE_PERMISSION;
772 -// $this->noCreatePermission();
773 -// return;
774762 }
775763
776764 # Don't save a new article if it's blank.
777765 if ( ( '' == $this->textbox1 ) ) {
 766+// $wgOut->redirect( $this->mTitle->getFullURL() );
778767 wfProfileOut( $fname );
779768 return self::AS_BLANK_ARTICLE;
780 -// return false;
781769 }
782770
783771 $isComment=($this->section=='new');
784772 $this->mArticle->insertNewArticle( $this->textbox1, $this->summary,
785773 $this->minoredit, $this->watchthis, false, $isComment);
 774+
786775 wfProfileOut( $fname );
787776 return self::AS_SUCCESS_NEW_ARTICLE;
788 -// return false;
789777 }
 778+
790779 # Article exists. Check for edit conflict.
 780+
791781 $this->mArticle->clear(); # Force reload of dates, etc.
792782 $this->mArticle->forUpdate( true ); # Lock the article
 783+
793784 wfDebug("timestamp: {$this->mArticle->getTimestamp()}, edittime: {$this->edittime}\n");
 785+
794786 if( $this->mArticle->getTimestamp() != $this->edittime ) {
795787 $this->isConflict = true;
796788 if( $this->section == 'new' ) {
@@ -807,6 +799,7 @@
808800 }
809801 }
810802 $userid = $wgUser->getID();
 803+
811804 if ( $this->isConflict) {
812805 wfDebug( "EditPage::editForm conflict! getting section '$this->section' for time '$this->edittime' (article time '" .
813806 $this->mArticle->getTimestamp() . "')\n" );
@@ -816,7 +809,6 @@
817810 wfDebug( "EditPage::editForm getting section '$this->section'\n" );
818811 $text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $this->summary);
819812 }
820 -
821813 if( is_null( $text ) ) {
822814 wfDebug( "EditPage::editForm activating conflict; section replace failed.\n" );
823815 $this->isConflict = true;
@@ -846,7 +838,6 @@
847839 if ( $this->isConflict ) {
848840 wfProfileOut( $fname );
849841 return self::AS_CONFLICT_DETECTED;
850 -// return true;
851842 }
852843
853844 $oldtext = $this->mArticle->getContent();
@@ -858,7 +849,6 @@
859850 $this->missingSummary = true;
860851 wfProfileOut( $fname );
861852 return self::AS_SUMMARY_NEEDED;
862 -// return( true );
863853 }
864854 }
865855
@@ -868,9 +858,9 @@
869859 $this->missingSummary = true;
870860 wfProfileOut( $fname );
871861 return self::AS_SUMMARY_NEEDED;
872 -// return( true );
873862 }
874863 }
 864+
875865 # All's well
876866 wfProfileIn( "$fname-sectionanchor" );
877867 $sectionanchor = '';
@@ -878,7 +868,6 @@
879869 if ( $this->textbox1 == '' ) {
880870 $this->missingComment = true;
881871 return self::AS_TEXTBOX_EMPTY;
882 -// return true;
883872 }
884873 if( $this->summary != '' ) {
885874 $sectionanchor = $wgParser->guessSectionNameFromWikiText( $this->summary );
@@ -906,27 +895,25 @@
907896 // replace that into a duplicated mess.
908897 $this->textbox1 = $text;
909898 $this->section = '';
 899+
910900 // Check for length errors again now that the section is merged in
911901 $this->kblength = (int)(strlen( $text ) / 1024);
912902 if ( $this->kblength > $wgMaxArticleSize ) {
913903 $this->tooBig = true;
914904 wfProfileOut( $fname );
915905 return self::AS_MAX_ARTICLE_SIZE_EXCEDED;
916 -// return true;
917906 }
918907
919908 # update the article here
920909 if( $this->mArticle->updateArticle( $text, $this->summary, $this->minoredit,
921910 $this->watchthis, '', $sectionanchor ) ) {
922911 wfProfileOut( $fname );
923 -return self::AS_SUCCESS_UPDATE;
924 -// return false;
 912+ return self::AS_SUCCESS_UPDATE;
925913 } else {
926914 $this->isConflict = true;
927915 }
928916 wfProfileOut( $fname );
929917 return self::AS_END;
930 -// return true;
931918 }
932919
933920 /**
@@ -2205,8 +2192,7 @@
22062193 // case DEFAULT:
22072194 // return true;
22082195 }
 2196+ }
22092197 }
22102198
2211 -}
22122199
2213 -
Index: branches/ApiEdit_Vodafone/includes/AutoLoader.php
@@ -335,9 +335,10 @@
336336 'ApiQueryUserInfo' => 'includes/api/ApiQueryUserInfo.php',
337337 'ApiQueryWatchlist' => 'includes/api/ApiQueryWatchlist.php',
338338 'ApiResult' => 'includes/api/ApiResult.php',
339 - // Added by VF
 339+
 340+ # Added by VF - Api Edit branch
340341 'ApiEditPage' => 'includes/api/ApiEditPage.php',
341 - 'ApiRegUser' => 'includes/api/ApiRegUser.php',
 342+ 'ApiRegUser' => 'includes/api/ApiRegUser.php',
342343 'ApiUploadFile' => 'includes/api/ApiUploadFile.php',
343344 );
344345
@@ -388,6 +389,4 @@
389390 require( $file );
390391 }
391392 }
392 -}
393 -
394 -
 393+}
\ No newline at end of file

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r25837Localisation updates from Betawiki....siebrand23:24, 13 September 2007

Status & tagging log