Index: trunk/extensions/ConfirmAccount/SpecialConfirmAccount.php |
— | — | @@ -121,23 +121,32 @@ |
122 | 122 | } |
123 | 123 | |
124 | 124 | function wfConfirmAccountsNotice( $notice ) { |
125 | | - global $wgConfirmAccountNotice, $wgUser; |
| 125 | + global $wgConfirmAccountNotice, $wgUser, $wgMemc; |
126 | 126 | |
127 | 127 | if( !$wgConfirmAccountNotice || !$wgUser->isAllowed('confirmaccount') ) |
128 | 128 | return true; |
| 129 | + # Check cached results |
| 130 | + $key = wfMemcKey( 'confirmaccount', 'notice' ); |
| 131 | + $message = $wgMemc->get( $key ); |
129 | 132 | |
130 | | - $dbr = wfGetDB( DB_SLAVE ); |
131 | | - $count = $dbr->selectField( 'account_requests', 'COUNT(*)', |
132 | | - array( 'acr_deleted' => 0, 'acr_held IS NULL' ), |
133 | | - __METHOD__ ); |
134 | | - |
135 | | - if( !$count ) |
136 | | - return true; |
| 133 | + if( !$message ) { |
| 134 | + $dbr = wfGetDB( DB_SLAVE ); |
| 135 | + $count = $dbr->selectField( 'account_requests', 'COUNT(*)', |
| 136 | + array( 'acr_deleted' => 0, 'acr_held IS NULL' ), |
| 137 | + __METHOD__ ); |
137 | 138 | |
138 | | - wfLoadExtensionMessages( 'ConfirmAccount' ); |
| 139 | + if( $count ) { |
| 140 | + wfLoadExtensionMessages( 'ConfirmAccount' ); |
| 141 | + $message = '<div id="mw-confirmaccount-msg" class="mw-confirmaccount-bar">' . |
| 142 | + wfMsgExt( 'confirmaccount-newrequests', array('parseinline'), $count ) . '</div>'; |
| 143 | + } else { |
| 144 | + $message = ''; |
| 145 | + } |
| 146 | + } |
| 147 | + # Cache results |
| 148 | + $wgMemc->set( $key, $message, 3600*24*7 ); |
139 | 149 | |
140 | | - $notice .= '<div id="mw-confirmaccount-msg" class="mw-confirmaccount-bar">' . |
141 | | - wfMsgExt( 'confirmaccount-newrequests', array('parseinline'), $count ) . '</div>'; |
| 150 | + $notice .= $message; |
142 | 151 | |
143 | 152 | return true; |
144 | 153 | } |
Index: trunk/extensions/ConfirmAccount/ConfirmAccount_body.php |
— | — | @@ -379,6 +379,10 @@ |
380 | 380 | ), |
381 | 381 | __METHOD__ |
382 | 382 | ); |
| 383 | + # Clear cache for notice of how many account requests there are |
| 384 | + global $wgMemc; |
| 385 | + $key = wfMemcKey( 'confirmaccount', 'notice' ); |
| 386 | + $wgMemc->delete( $key ); |
383 | 387 | # Send confirmation, required! |
384 | 388 | $result = $this->sendConfirmationMail( $u, $token, $expires ); |
385 | 389 | if( WikiError::isError( $result ) ) { |
— | — | @@ -1003,6 +1007,10 @@ |
1004 | 1008 | 'acr_deleted' => 1 ), |
1005 | 1009 | array( 'acr_id' => $this->acrID, 'acr_deleted' => 0 ), |
1006 | 1010 | __METHOD__ ); |
| 1011 | + # Clear cache for notice of how many account requests there are |
| 1012 | + global $wgMemc; |
| 1013 | + $key = wfMemcKey( 'confirmaccount', 'notice' ); |
| 1014 | + $wgMemc->delete( $key ); |
1007 | 1015 | |
1008 | 1016 | $this->showSuccess( $this->submitType ); |
1009 | 1017 | } else if( $this->submitType == 'accept' ) { |
— | — | @@ -1144,6 +1152,10 @@ |
1145 | 1153 | wfRunHooks( 'AddNewAccount', array( $user ) ); |
1146 | 1154 | # OK, now remove the request from the queue |
1147 | 1155 | $dbw->delete( 'account_requests', array('acr_id' => $this->acrID), __METHOD__ ); |
| 1156 | + # Clear cache for notice of how many account requests there are |
| 1157 | + global $wgMemc; |
| 1158 | + $key = wfMemcKey( 'confirmaccount', 'notice' ); |
| 1159 | + $wgMemc->delete( $key ); |
1148 | 1160 | # Delete any attached file. Do not stop the whole process if this fails |
1149 | 1161 | $key = $row->acr_storage_key; |
1150 | 1162 | if( $key ) { |
— | — | @@ -1229,6 +1241,10 @@ |
1230 | 1242 | 'acr_comment' => $this->reason ), |
1231 | 1243 | array( 'acr_id' => $this->acrID, 'acr_held IS NULL', 'acr_deleted' => 0 ), |
1232 | 1244 | __METHOD__ ); |
| 1245 | + # Clear cache for notice of how many account requests there are |
| 1246 | + global $wgMemc; |
| 1247 | + $key = wfMemcKey( 'confirmaccount', 'notice' ); |
| 1248 | + $wgMemc->delete( $key ); |
1233 | 1249 | # Do not send multiple times |
1234 | 1250 | if( !$row->acr_held && !($row->acr_deleted && $row->acr_deleted !='f') ) { |
1235 | 1251 | $result = $u->sendMail( wfMsg( 'confirmaccount-email-subj' ), |
Index: trunk/extensions/ConfirmAccount/ConfirmAccount.i18n.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | 'requestaccount-loginnotice' => 'To obtain a user account, you must \'\'\'[[Special:RequestAccount|request one]]\'\'\'.', |
74 | 74 | |
75 | 75 | # Site message for admins |
76 | | - 'confirmaccount-newrequests' => 'There are currently $1 open [[Special:ConfirmAccounts|account requests]] pending.', |
| 76 | + 'confirmaccount-newrequests' => 'There are currently \'\'\'$1\'\'\' open [[Special:ConfirmAccounts|account requests]] pending.', |
77 | 77 | |
78 | 78 | # Confirm account page |
79 | 79 | 'confirmaccounts' => 'Confirm account requests', |