From: River Tarnell Date: Thu, 8 Mar 2007 03:53:32 +0000 (+0000) Subject: need to use mb_strlen, not strlen, for article length X-Git-Tag: 1.31.0-rc.0~53860 X-Git-Url: http://git.cyclocoop.org/%22.%24redirect_annul.%22?a=commitdiff_plain;h=4afd40843e83deaf3fd5293322b378f72ddf1c4c;p=lhc%2Fweb%2Fwiklou.git need to use mb_strlen, not strlen, for article length provide stub mb_strlen for installations missing mb --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index b009a4b716..61b930d458 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -61,6 +61,13 @@ if ( !function_exists( 'mb_substr' ) ) { } } +if ( !function_exists( 'mb_strlen' ) ) { + function mb_strlen( $str, $enc = "" ) { + preg_match_all( '/./us', $str, $matches ); + return count($matches); + } +} + if ( !function_exists( 'array_diff_key' ) ) { /** * Exists in PHP 5.1.0+ diff --git a/includes/Revision.php b/includes/Revision.php index 3dcb471781..9432f0c339 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -307,7 +307,7 @@ class Revision { $this->mTitle = null; # Load on demand if needed $this->mCurrent = false; - $this->mSize = is_null($this->mText) ? null : strlen($this->mText); + $this->mSize = is_null($this->mText) ? null : mb_strlen($this->mText); } else { throw new MWException( 'Revision constructor passed invalid row format.' ); } @@ -692,7 +692,7 @@ class Revision { 'rev_user_text' => $this->mUserText, 'rev_timestamp' => $dbw->timestamp( $this->mTimestamp ), 'rev_deleted' => $this->mDeleted, - 'rev_len' => strlen($this->mText), + 'rev_len' => mb_strlen($this->mText), ), $fname );