r114272 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114271‎ | r114272 | r114273 >
Date:14:21, 20 March 2012
Author:reedy
Status:ok
Tags:tstarling 
Comment:
Followup r114270 (essentially reverts it), and r114233, use class member variables as they are already defined
Modified paths:
  • /trunk/phase3/includes/CryptRand.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/CryptRand.php
@@ -187,9 +187,8 @@
188188 * @return String A hash algorithm
189189 */
190190 protected function hashAlgo() {
191 - static $algo;
192 - if ( !is_null( $algo ) ) {
193 - return $algo;
 191+ if ( !is_null( $this->algo ) ) {
 192+ return $this->algo;
194193 }
195194
196195 $algos = hash_algos();
@@ -197,9 +196,9 @@
198197
199198 foreach ( $preference as $algorithm ) {
200199 if ( in_array( $algorithm, $algos ) ) {
201 - $algo = $algorithm; # assign to static
202 - wfDebug( __METHOD__ . ": Using the $algo hash algorithm.\n" );
203 - return $algo;
 200+ $this->algo = $algorithm;
 201+ wfDebug( __METHOD__ . ": Using the {$this->algo} hash algorithm.\n" );
 202+ return $this->algo;
204203 }
205204 }
206205
@@ -218,11 +217,10 @@
219218 * @return int Number of bytes the hash outputs
220219 */
221220 protected function hashLength() {
222 - static $hashLength;
223 - if ( is_null( $hashLength ) ) {
224 - $hashLength = strlen( $this->hash( '' ) );
 221+ if ( is_null( $this->hashLength ) ) {
 222+ $this->hashLength = strlen( $this->hash( '' ) );
225223 }
226 - return $hashLength;
 224+ return $this->hashLength;
227225 }
228226
229227 /**

Sign-offs

UserFlagDate
Dantmaninspected16:05, 20 March 2012

Follow-up revisions

RevisionCommit summaryAuthorDate
r114283Backport r114272, Reedy's fix for r114233 to REL1_17, REL1_18, and REL1_19.dantman17:22, 20 March 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r114233Commit the cryptrand project worked on in git:...dantman05:17, 20 March 2012
r114270Followup r114233, define the method static variables to be usedreedy14:16, 20 March 2012

Status & tagging log