r20223 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20222‎ | r20223 | r20224 >
Date:03:53, 8 March 2007
Author:river
Status:old
Tags:
Comment:
need to use mb_strlen, not strlen, for article length
provide stub mb_strlen for installations missing mb
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/Revision.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -61,6 +61,13 @@
6262 }
6363 }
6464
 65+if ( !function_exists( 'mb_strlen' ) ) {
 66+ function mb_strlen( $str, $enc = "" ) {
 67+ preg_match_all( '/./us', $str, $matches );
 68+ return count($matches);
 69+ }
 70+}
 71+
6572 if ( !function_exists( 'array_diff_key' ) ) {
6673 /**
6774 * Exists in PHP 5.1.0+
Index: trunk/phase3/includes/Revision.php
@@ -307,7 +307,7 @@
308308 $this->mTitle = null; # Load on demand if needed
309309 $this->mCurrent = false;
310310
311 - $this->mSize = is_null($this->mText) ? null : strlen($this->mText);
 311+ $this->mSize = is_null($this->mText) ? null : mb_strlen($this->mText);
312312 } else {
313313 throw new MWException( 'Revision constructor passed invalid row format.' );
314314 }
@@ -692,7 +692,7 @@
693693 'rev_user_text' => $this->mUserText,
694694 'rev_timestamp' => $dbw->timestamp( $this->mTimestamp ),
695695 'rev_deleted' => $this->mDeleted,
696 - 'rev_len' => strlen($this->mText),
 696+ 'rev_len' => mb_strlen($this->mText),
697697 ), $fname
698698 );
699699