LinkBatch: Cast array keys to string when constructing TitleValue
authorBartosz Dziewoński <matma.rex@gmail.com>
Wed, 1 Jun 2016 20:12:59 +0000 (22:12 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Wed, 1 Jun 2016 20:12:59 +0000 (22:12 +0200)
If $dbkey consisted only of numbers (0-9), PHP converts it to an
integer when using it as array key, and then returns it as an integer
when iterating over the array. This is normally fine, but TitleValue
does strict type checking.

Follow-up to 682116760198a7420a809e0b9966ecdc63f1c67d.

Bug: T136615
Change-Id: I894800c3f5aec0c2d0c23f8adfa1b840495f3b16

includes/cache/LinkBatch.php

index 04d2524..f48e0a5 100644 (file)
@@ -168,7 +168,7 @@ class LinkBatch {
                // The remaining links in $data are bad links, register them as such
                foreach ( $remaining as $ns => $dbkeys ) {
                        foreach ( $dbkeys as $dbkey => $unused ) {
-                               $title = new TitleValue( (int)$ns, $dbkey );
+                               $title = new TitleValue( (int)$ns, (string)$dbkey );
                                $cache->addBadLinkObj( $title );
                                $pdbk = $titleFormatter->getPrefixedDBkey( $title );
                                $ids[$pdbk] = 0;