/**
* See docs/deferred.txt
*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
* @todo document (e.g. one-sentence top-level class description).
*/
class LinksUpdate {
$this->mInterlangs[$key] = $title;
}
- foreach ( $this->mCategories as $cat => &$sortkey ) {
+ 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 bug 25254.
- $sortkey = substr( $sortkey, 0, 255 );
+ # Also. substr behaves weird when given "".
+ if ( $sortkey !== '' ) {
+ $sortkey = substr( $sortkey, 0, 255 );
+ }
}
$this->mRecursive = $recursive;
$existing = $this->getExistingImages();
$imageDeletes = $this->getImageDeletions( $existing );
- $this->incrTableUpdate( 'imagelinks', 'il', $imageDeletes, $this->getImageInsertions( $existing ) );
+ $this->incrTableUpdate( 'imagelinks', 'il', $imageDeletes,
+ $this->getImageInsertions( $existing ) );
# Invalidate all image description pages which had links added or removed
$imageUpdates = $imageDeletes + array_diff_key( $this->mImages, $existing );
$categoryDeletes = $this->getCategoryDeletions( $existing );
- $this->incrTableUpdate( 'categorylinks', 'cl', $categoryDeletes, $this->getCategoryInsertions( $existing ) );
+ $this->incrTableUpdate( 'categorylinks', 'cl', $categoryDeletes,
+ $this->getCategoryInsertions( $existing ) );
# Invalidate all categories which were added, deleted or changed (set symmetric difference)
$categoryInserts = array_diff_assoc( $this->mCategories, $existing );
$propertiesDeletes = $this->getPropertyDeletions( $existing );
- $this->incrTableUpdate( 'page_props', 'pp', $propertiesDeletes, $this->getPropertyInsertions( $existing ) );
+ $this->incrTableUpdate( 'page_props', 'pp', $propertiesDeletes,
+ $this->getPropertyInsertions( $existing ) );
# Invalidate the necessary pages
$changed = $propertiesDeletes + array_diff_assoc( $this->mProperties, $existing );
function getLinkInsertions( $existing = array() ) {
$arr = array();
foreach( $this->mLinks as $ns => $dbkeys ) {
- $diffs = isset( $existing[$ns] ) ? array_diff_key( $dbkeys, $existing[$ns] ) : $dbkeys;
+ $diffs = isset( $existing[$ns] )
+ ? array_diff_key( $dbkeys, $existing[$ns] )
+ : $dbkeys;
foreach ( $diffs as $dbk => $id ) {
$arr[] = array(
'pl_from' => $this->mId,
global $wgContLang, $wgCategoryCollation;
$diffs = array_diff_assoc( $this->mCategories, $existing );
$arr = array();
- foreach ( $diffs as $name => $sortkey ) {
+ foreach ( $diffs as $name => $prefix ) {
$nt = Title::makeTitleSafe( NS_CATEGORY, $name );
$wgContLang->findVariantLink( $name, $nt, true );
$type = 'page';
}
- # TODO: This is kind of wrong, because someone might set a sort
- # key prefix that's the same as the default sortkey for the
- # title. This should be fixed by refactoring code to replace
- # $sortkey in this array by a prefix, but it's basically harmless
- # (Title::moveTo() has had the same issue for a long time).
- if ( $this->mTitle->getCategorySortkey() == $sortkey ) {
- $prefix = '';
- $sortkey = $wgContLang->convertToSortkey( $sortkey );
- } else {
- # Treat custom sortkeys as a prefix, so that if multiple
- # things are forced to sort as '*' or something, they'll
- # sort properly in the category rather than in page_id
- # order or such.
- $prefix = $sortkey;
- $sortkey = $wgContLang->convertToSortkey(
- $this->mTitle->getCategorySortkey( $prefix ) );
- }
+ # Treat custom sortkeys as a prefix, so that if multiple
+ # things are forced to sort as '*' or something, they'll
+ # sort properly in the category rather than in page_id
+ # order or such.
+ $sortkey = Collation::singleton()->getSortKey(
+ $this->mTitle->getCategorySortkey( $prefix ) );
$arr[] = array(
'cl_from' => $this->mId,
array( 'cl_from' => $this->mId ), __METHOD__, $this->mOptions );
$arr = array();
foreach ( $res as $row ) {
- if ( $row->cl_sortkey_prefix !== '' ) {
- $arr[$row->cl_to] = $row->cl_sortkey_prefix;
- } else {
- $arr[$row->cl_to] = $this->mTitle->getCategorySortkey();
- }
+ $arr[$row->cl_to] = $row->cl_sortkey_prefix;
}
return $arr;
}