need to use mb_strlen, not strlen, for article length
authorRiver Tarnell <river@users.mediawiki.org>
Thu, 8 Mar 2007 03:53:32 +0000 (03:53 +0000)
committerRiver Tarnell <river@users.mediawiki.org>
Thu, 8 Mar 2007 03:53:32 +0000 (03:53 +0000)
provide stub mb_strlen for installations missing mb

includes/GlobalFunctions.php
includes/Revision.php

index b009a4b..61b930d 100644 (file)
@@ -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+
index 3dcb471..9432f0c 100644 (file)
@@ -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
                );