Use multibyte-aware truncation to avoid invalid UTF-8 in cl_sortkey_prefix
[lhc/web/wiklou.git] / includes / deferred / LinksUpdate.php
index 5c82f09..141888c 100644 (file)
@@ -141,14 +141,9 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate {
                }
 
                foreach ( $this->mCategories as &$sortkey ) {
-                       # If the sortkey is longer then 255 bytes,
-                       # it truncated by DB, and then doesn't get
-                       # matched when comparing existing vs current
-                       # categories, causing T27254.
-                       # Also. substr behaves weird when given "".
-                       if ( $sortkey !== '' ) {
-                               $sortkey = substr( $sortkey, 0, 255 );
-                       }
+                       # If the sortkey is longer then 255 bytes, it is truncated by DB, and then doesn't match
+                       # when comparing existing vs current categories, causing T27254.
+                       $sortkey = mb_strcut( $sortkey, 0, 255 );
                }
 
                $this->mRecursive = $recursive;
@@ -161,7 +156,7 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate {
        /**
         * Update link tables with outgoing links from an updated article
         *
-        * @note: this is managed by DeferredUpdates::execute(). Do not run this in a transaction.
+        * @note this is managed by DeferredUpdates::execute(). Do not run this in a transaction.
         */
        public function doUpdate() {
                if ( $this->ticket ) {