r47614 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47613‎ | r47614 | r47615 >
Date:14:59, 21 February 2009
Author:aaron
Status:deferred
Tags:
Comment:
Removed double-profiling (hooks.php already does it)
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -123,8 +123,6 @@
124124 * Update flaggedrevs table on article history merge
125125 */
126126 public static function updateFromMerge( $sourceTitle, $destTitle ) {
127 - wfProfileIn( __METHOD__ );
128 -
129127 $oldPageID = $sourceTitle->getArticleID();
130128 $newPageID = $destTitle->getArticleID();
131129 # Get flagged revisions from old page id that point to destination page
@@ -151,7 +149,6 @@
152150 FlaggedRevs::titleLinksUpdate( $sourceTitle );
153151 FlaggedRevs::titleLinksUpdate( $destTitle );
154152
155 - wfProfileOut( __METHOD__ );
156153 return true;
157154 }
158155
@@ -171,7 +168,6 @@
172169 if( !FlaggedRevs::isPageReviewable( $linksUpdate->mTitle ) ) {
173170 return true;
174171 }
175 - wfProfileIn( __METHOD__ );
176172 $dbw = wfGetDB( DB_MASTER );
177173 $pageId = $linksUpdate->mTitle->getArticleId();
178174 # Check if this page has a stable version...
@@ -181,7 +177,6 @@
182178 if( !$sv ) {
183179 $dbw->delete( 'flaggedpages', array( 'fp_page_id' => $pageId ), __METHOD__ );
184180 $dbw->delete( 'flaggedrevs_tracking', array( 'ftr_from' => $pageId ), __METHOD__ );
185 - wfProfileOut( __METHOD__ );
186181 return true;
187182 }
188183 # Try the process cache...
@@ -239,7 +234,6 @@
240235 if( count($insertions) ) {
241236 $dbw->insert( 'flaggedrevs_tracking', $insertions, __METHOD__, 'IGNORE' );
242237 }
243 - wfProfileOut( __METHOD__ );
244238 return true;
245239 }
246240
@@ -554,10 +548,9 @@
555549 */
556550 public static function parserInjectTimestamps( $parser, &$text ) {
557551 # Don't trigger this for stable version parsing...it will do it separately.
558 - if( !empty($parser->fr_isStable) )
 552+ if( !empty($parser->fr_isStable) ) {
559553 return true;
560 -
561 - wfProfileIn( __METHOD__ );
 554+ }
562555 $maxRevision = 0;
563556 # Record the max template revision ID
564557 if( !empty($parser->mOutput->mTemplateIds) ) {
@@ -570,9 +563,8 @@
571564 }
572565 }
573566 $parser->mOutput->fr_newestTemplateID = $maxRevision;
574 -
575 - $maxTimestamp = "0";
576567 # Fetch the current timestamps of the images.
 568+ $maxTimestamp = "0";
577569 if( !empty($parser->mOutput->mImages) ) {
578570 foreach( $parser->mOutput->mImages as $filename => $x ) {
579571 # FIXME: it would be nice not to double fetch these!
@@ -591,8 +583,6 @@
592584 }
593585 # Record the max timestamp
594586 $parser->mOutput->fr_newestImageTime = $maxTimestamp;
595 -
596 - wfProfileOut( __METHOD__ );
597587 return true;
598588 }
599589
@@ -911,14 +901,11 @@
912902 */
913903 public static function checkAutoPromote( $user, &$promote ) {
914904 global $wgFlaggedRevsAutopromote;
915 - wfProfileIn( __METHOD__ );
916905 if( empty($wgFlaggedRevsAutopromote) || !$user->getId() || $user->isAllowed('autoreview') ) {
917 - wfProfileOut( __METHOD__ );
918906 return true; // not needed
919907 }
920908 # Check user email
921909 if( $wgFlaggedRevsAutopromote['email'] && !$user->isEmailConfirmed() ) {
922 - wfProfileOut( __METHOD__ );
923910 return true;
924911 }
925912 # Get requirments
@@ -929,17 +916,14 @@
930917 $usercreation = wfTimestampOrNull( TS_UNIX, $user->getRegistration() );
931918 $userage = $usercreation ? floor(($now - $usercreation) / 86400) : NULL;
932919 if( !is_null($userage) && $userage < $timeReq ) {
933 - wfProfileOut( __METHOD__ );
934920 return true;
935921 }
936922 # Check user edit count. Should be stored.
937923 if( $user->getEditCount() < $editsReq ) {
938 - wfProfileOut( __METHOD__ );
939924 return true;
940925 }
941926 # Add the right
942927 $promote[] = 'autoreview';
943 - wfProfileOut( __METHOD__ );
944928 return true;
945929 }
946930
@@ -952,18 +936,15 @@
953937 if( empty($wgFlaggedRevsAutopromote) || !$rev || !$user->getId() )
954938 return true;
955939 # Check implicitly sighted edits
956 - wfProfileIn( __METHOD__ );
957940 # Grab current groups
958941 $groups = $user->getGroups();
959942 # Do not give this to current holders or bots
960943 if( $user->isAllowed('bot') || in_array('editor',$groups) ) {
961 - wfProfileOut( __METHOD__ );
962944 return true;
963945 }
964946 # Do not re-add status if it was previously removed!
965947 $p = FlaggedRevs::getUserParams( $user->getId() );
966948 if( isset($p['demoted']) && $p['demoted'] ) {
967 - wfProfileOut( __METHOD__ );
968949 return true;
969950 }
970951 # Update any special counters for non-null revisions
@@ -996,29 +977,24 @@
997978 $totalCheckedEditsNeeded = false;
998979 if( $wgFlaggedRevsAutopromote['totalContentEdits'] > $p['totalContentEdits'] ) {
999980 if( !$wgFlaggedRevsAutopromote['totalCheckedEdits'] ) {
1000 - wfProfileOut( __METHOD__ );
1001981 return true;
1002982 }
1003983 $totalCheckedEditsNeeded = true;
1004984 }
1005985 # Check if user edited enough unique pages
1006986 if( $wgFlaggedRevsAutopromote['uniqueContentPages'] > count($pages) ) {
1007 - wfProfileOut( __METHOD__ );
1008987 return true;
1009988 }
1010989 # Check edit comment use
1011990 if( $wgFlaggedRevsAutopromote['editComments'] > $p['editComments'] ) {
1012 - wfProfileOut( __METHOD__ );
1013991 return true;
1014992 }
1015993 # Check reverted edits
1016994 if( $wgFlaggedRevsAutopromote['maxRevertedEdits'] < $p['revertedEdits'] ) {
1017 - wfProfileOut( __METHOD__ );
1018995 return true;
1019996 }
1020997 # Check user email
1021998 if( $wgFlaggedRevsAutopromote['email'] && !$user->isEmailConfirmed() ) {
1022 - wfProfileOut( __METHOD__ );
1023999 return true;
10241000 }
10251001 # Check account age
@@ -1026,12 +1002,10 @@
10271003 $usercreation = wfTimestampOrNull( TS_UNIX, $user->getRegistration() );
10281004 $userage = $usercreation ? floor(($now - $usercreation) / 86400) : NULL;
10291005 if( !is_null($userage) && $userage < $wgFlaggedRevsAutopromote['days'] ) {
1030 - wfProfileOut( __METHOD__ );
10311006 return true;
10321007 }
10331008 # Check user edit count. Should be stored.
10341009 if( $user->getEditCount() < $wgFlaggedRevsAutopromote['edits'] ) {
1035 - wfProfileOut( __METHOD__ );
10361010 return true;
10371011 }
10381012 # Check if results are cached to avoid DB queries.
@@ -1039,12 +1013,10 @@
10401014 $key = wfMemcKey( 'flaggedrevs', 'autopromote-skip', $user->getID() );
10411015 $value = $wgMemc->get( $key );
10421016 if( $value == 'true' ) {
1043 - wfProfileOut( __METHOD__ );
10441017 return true;
10451018 }
10461019 # Don't grant to currently blocked users...
10471020 if( $user->isBlocked() ) {
1048 - wfProfileOut( __METHOD__ );
10491021 return true;
10501022 }
10511023 # Check if user was ever blocked before
@@ -1060,14 +1032,12 @@
10611033 if( $blocked ) {
10621034 # Make a key to store the results
10631035 $wgMemc->set( $key, 'true', 3600*24*7 );
1064 - wfProfileOut( __METHOD__ );
10651036 return true;
10661037 }
10671038 }
10681039 # See if the page actually has sufficient content...
10691040 if( $wgFlaggedRevsAutopromote['userpageBytes'] > 0 ) {
10701041 if( !$user->getUserPage()->exists() ) {
1071 - wfProfileOut( __METHOD__ );
10721042 return true;
10731043 }
10741044 $dbr = isset($dbr) ? $dbr : wfGetDB( DB_SLAVE );
@@ -1076,7 +1046,6 @@
10771047 'page_title' => $user->getUserPage()->getDBKey() ),
10781048 __METHOD__ );
10791049 if( $size < $wgFlaggedRevsAutopromote['userpageBytes'] ) {
1080 - wfProfileOut( __METHOD__ );
10811050 return true;
10821051 }
10831052 }
@@ -1110,7 +1079,6 @@
11111080 if( $benchmarks < $needed ) {
11121081 # Make a key to store the results
11131082 $wgMemc->set( $key, 'true', 3600*24*$spacing*($benchmarks - $needed - 1) );
1114 - wfProfileOut( __METHOD__ );
11151083 return true;
11161084 }
11171085 }
@@ -1127,7 +1095,6 @@
11281096 if( $shared ) {
11291097 # Make a key to store the results
11301098 $wgMemc->set( $key, 'true', 3600*24*7 );
1131 - wfProfileOut( __METHOD__ );
11321099 return true;
11331100 }
11341101 }
@@ -1143,7 +1110,6 @@
11441111 array( 'USE INDEX' => 'rc_ns_usertext',
11451112 'LIMIT' => $wgFlaggedRevsAutopromote['recentContent'] ) );
11461113 if( $dbr->numRows($res) < $wgFlaggedRevsAutopromote['recentContent'] ) {
1147 - wfProfileOut( __METHOD__ );
11481114 return true;
11491115 }
11501116 }
@@ -1167,7 +1133,6 @@
11681134 array( 'USE INDEX' => 'usertext_timestamp' ) );
11691135 }
11701136 if( $deletedEdits >= $minDiff ) {
1171 - wfProfileOut( __METHOD__ );
11721137 return true;
11731138 }
11741139 }
@@ -1181,7 +1146,6 @@
11821147 'LIMIT' => $wgFlaggedRevsAutopromote['totalCheckedEdits'] )
11831148 );
11841149 if( $dbr->numRows($res) < $wgFlaggedRevsAutopromote['totalCheckedEdits'] ) {
1185 - wfProfileOut( __METHOD__ );
11861150 return true;
11871151 }
11881152 }
@@ -1196,7 +1160,6 @@
11971161 array( implode(', ',$groups), implode(', ',$newGroups) ) );
11981162 $user->addGroup('editor');
11991163
1200 - wfProfileOut( __METHOD__ );
12011164 return true;
12021165 }
12031166

Status & tagging log