Index: trunk/phase3/maintenance/archives/patch-categorylinks-better-collation2.sql |
— | — | @@ -0,0 +1,12 @@ |
| 2 | +-- |
| 3 | +-- patch-categorylinks-better-collation2.sql |
| 4 | +-- |
| 5 | +-- Bugs 164, 1211, 23682. This patch exists for trunk users who already |
| 6 | +-- applied the first patch in its original version. The first patch was |
| 7 | +-- updated to incorporate the changes as well, so as not to do two alters on a |
| 8 | +-- large table unnecessarily for people upgrading from 1.16, so this will be |
| 9 | +-- skipped if unneeded. |
| 10 | +ALTER TABLE /*$wgDBprefix*/categorylinks |
| 11 | + CHANGE COLUMN cl_sortkey cl_sortkey varbinary(255) NOT NULL default '', |
| 12 | + CHANGE COLUMN cl_collation cl_collation varbinary(32) NOT NULL default ''; |
| 13 | +INSERT IGNORE INTO /*$wgDBprefix*/updatelog (ul_key) VALUES ('cl_fields_update'); |
Property changes on: trunk/phase3/maintenance/archives/patch-categorylinks-better-collation2.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 14 | + native |
Index: trunk/phase3/maintenance/archives/patch-categorylinks-better-collation.sql |
— | — | @@ -1,11 +1,15 @@ |
2 | 2 | -- |
3 | 3 | -- patch-categorylinks-better-collation.sql |
4 | 4 | -- |
| 5 | +-- Bugs 164, 1211, 23682. This is the second version of this patch; the |
| 6 | +-- changes are also incorporated into patch-categorylinks-better-collation2.sql, |
| 7 | +-- for the benefit of trunk users who applied the original. |
5 | 8 | ALTER TABLE /*$wgDBprefix*/categorylinks |
| 9 | + CHANGE COLUMN cl_sortkey cl_sortkey varbinary(255) NOT NULL default '', |
6 | 10 | ADD COLUMN cl_sortkey_prefix varchar(255) binary NOT NULL default '', |
7 | | - ADD COLUMN cl_collation tinyint NOT NULL default 0, |
| 11 | + ADD COLUMN cl_collation varbinary(32) NOT NULL default '', |
8 | 12 | ADD COLUMN cl_type ENUM('page', 'subcat', 'file') NOT NULL default 'page', |
9 | 13 | ADD INDEX (cl_collation), |
10 | 14 | DROP INDEX cl_sortkey, |
11 | 15 | ADD INDEX cl_sortkey (cl_to, cl_type, cl_sortkey, cl_from); |
| 16 | +INSERT IGNORE INTO /*$wgDBprefix*/updatelog (ul_key) VALUES ('cl_fields_update'); |
Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -103,7 +103,6 @@ |
104 | 104 | } |
105 | 105 | |
106 | 106 | function archive( $name ) { |
107 | | - wfDeprecated( __FUNCTION__ ); |
108 | 107 | return DatabaseBase::patchPath( $name ); |
109 | 108 | } |
110 | 109 | |
— | — | @@ -833,12 +832,23 @@ |
834 | 833 | $task->execute(); |
835 | 834 | } |
836 | 835 | |
| 836 | +function do_cl_fields_update() { |
| 837 | + if ( update_row_exists( 'cl_fields_update' ) ) { |
| 838 | + wfOut( "...categorylinks up-to-date.\n" ); |
| 839 | + return; |
| 840 | + } |
| 841 | + wfOut( 'Updating categorylinks (again)...' ); |
| 842 | + global $wgDatabase; |
| 843 | + $wgDatabase->sourceFile( archive( 'patch-categorylinks-better-collation2.sql' ) ); |
| 844 | + wfOut( "done.\n" ); |
| 845 | +} |
| 846 | + |
837 | 847 | function do_collation_update() { |
838 | | - global $wgDatabase, $wgCollationVersion; |
| 848 | + global $wgDatabase, $wgCategoryCollation; |
839 | 849 | if ( $wgDatabase->selectField( |
840 | 850 | 'categorylinks', |
841 | 851 | 'COUNT(*)', |
842 | | - 'cl_collation != ' . $wgDatabase->addQuotes( $wgCollationVersion ), |
| 852 | + 'cl_collation != ' . $wgDatabase->addQuotes( $wgCategoryCollation ), |
843 | 853 | __FUNCTION__ |
844 | 854 | ) == 0 ) { |
845 | 855 | wfOut( "...collations up-to-date.\n" ); |
Index: trunk/phase3/maintenance/tables.sql |
— | — | @@ -493,12 +493,7 @@ |
494 | 494 | -- A binary string obtained by applying a sortkey generation algorithm |
495 | 495 | -- (Language::convertToSortkey()) to page_title, or cl_sortkey_prefix . "\0" |
496 | 496 | -- . page_title if cl_sortkey_prefix is nonempty. |
497 | | - -- |
498 | | - -- Truncate so that the cl_sortkey key fits in 1000 bytes (MyISAM 5 with |
499 | | - -- server_character_set=utf8). FIXME: this truncation probably makes no |
500 | | - -- sense anymore; we should be using varbinary for this, utf8 will break |
501 | | - -- everything. |
502 | | - cl_sortkey varchar(70) binary NOT NULL default '', |
| 497 | + cl_sortkey varbinary(255) NOT NULL default '', |
503 | 498 | |
504 | 499 | -- A prefix for the raw sortkey manually specified by the user, either via |
505 | 500 | -- [[Category:Foo|prefix]] or {{defaultsort:prefix}}. If nonempty, it's |
— | — | @@ -511,12 +506,12 @@ |
512 | 507 | -- sorting method by approximate addition time. |
513 | 508 | cl_timestamp timestamp NOT NULL, |
514 | 509 | |
515 | | - -- Stores $wgCollationVersion at the time cl_sortkey was generated. This can |
516 | | - -- be used to install new collation versions, tracking which rows are not yet |
517 | | - -- updated. 0 means no collation, this is a legacy row that needs to be |
| 510 | + -- Stores $wgCategoryCollation at the time cl_sortkey was generated. This |
| 511 | + -- can be used to install new collation versions, tracking which rows are not |
| 512 | + -- yet updated. '' means no collation, this is a legacy row that needs to be |
518 | 513 | -- updated by updateCollation.php. In the future, it might be possible to |
519 | 514 | -- specify different collations per category. |
520 | | - cl_collation tinyint NOT NULL default 0, |
| 515 | + cl_collation varbinary(32) NOT NULL default '', |
521 | 516 | |
522 | 517 | -- Stores whether cl_from is a category, file, or other page, so we can |
523 | 518 | -- paginate the three categories separately. This never has to be updated |
Index: trunk/phase3/maintenance/updateCollation.php |
— | — | @@ -15,10 +15,10 @@ |
16 | 16 | public function __construct() { |
17 | 17 | parent::__construct(); |
18 | 18 | |
19 | | - global $wgCollationVersion; |
| 19 | + global $wgCategoryCollation; |
20 | 20 | $this->mDescription = <<<TEXT |
21 | 21 | This script will find all rows in the categorylinks table whose collation is |
22 | | -out-of-date (cl_collation != $wgCollationVersion) and repopulate cl_sortkey |
| 22 | +out-of-date (cl_collation != '$wgCategoryCollation') and repopulate cl_sortkey |
23 | 23 | using the page title and cl_sortkey_prefix. If everything's collation is |
24 | 24 | up-to-date, it will do nothing. |
25 | 25 | TEXT; |
— | — | @@ -27,13 +27,13 @@ |
28 | 28 | } |
29 | 29 | |
30 | 30 | public function execute() { |
31 | | - global $wgCollationVersion, $wgContLang; |
| 31 | + global $wgCategoryCollation, $wgContLang; |
32 | 32 | |
33 | 33 | $dbw = wfGetDB( DB_MASTER ); |
34 | 34 | $count = $dbw->selectField( |
35 | 35 | 'categorylinks', |
36 | 36 | 'COUNT(*)', |
37 | | - 'cl_collation != ' . $dbw->addQuotes( $wgCollationVersion ), |
| 37 | + 'cl_collation != ' . $dbw->addQuotes( $wgCategoryCollation ), |
38 | 38 | __METHOD__ |
39 | 39 | ); |
40 | 40 | |
— | — | @@ -51,7 +51,7 @@ |
52 | 52 | 'cl_sortkey', 'page_namespace', 'page_title' |
53 | 53 | ), |
54 | 54 | array( |
55 | | - 'cl_collation != ' . $dbw->addQuotes( $wgCollationVersion ), |
| 55 | + 'cl_collation != ' . $dbw->addQuotes( $wgCategoryCollation ), |
56 | 56 | 'cl_from = page_id' |
57 | 57 | ), |
58 | 58 | __METHOD__, |
— | — | @@ -89,7 +89,7 @@ |
90 | 90 | 'cl_sortkey' => $wgContLang->convertToSortkey( |
91 | 91 | $title->getCategorySortkey( $prefix ) ), |
92 | 92 | 'cl_sortkey_prefix' => $prefix, |
93 | | - 'cl_collation' => $wgCollationVersion, |
| 93 | + 'cl_collation' => $wgCategoryCollation, |
94 | 94 | 'cl_type' => $type, |
95 | 95 | 'cl_timestamp = cl_timestamp', |
96 | 96 | ), |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -4449,10 +4449,13 @@ |
4450 | 4450 | /** |
4451 | 4451 | * A version indicator for collations that will be stored in cl_collation for |
4452 | 4452 | * all new rows. Used when the collation algorithm changes: a script checks |
4453 | | - * for all rows where cl_collation != $wgCollationVersion and regenerates |
| 4453 | + * for all rows where cl_collation != $wgCategoryCollation and regenerates |
4454 | 4454 | * cl_sortkey based on the page name and cl_sortkey_prefix. |
| 4455 | + * |
| 4456 | + * Currently only supports 'uppercase', which just uppercases the string. This |
| 4457 | + * is a dummy collation, to be replaced later by real ones. |
4455 | 4458 | */ |
4456 | | -$wgCollationVersion = 1; |
| 4459 | +$wgCategoryCollation = 'uppercase'; |
4457 | 4460 | |
4458 | 4461 | /** @} */ # End categories } |
4459 | 4462 | |
Index: trunk/phase3/includes/installer/MysqlUpdater.php |
— | — | @@ -165,6 +165,7 @@ |
166 | 166 | array( 'drop_index_if_exists', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ), |
167 | 167 | array( 'drop_index_if_exists', 'iwlinks', 'iwl_prefix_from_title', 'patch-kill-iwl_pft.sql' ), |
168 | 168 | array( 'addField', 'categorylinks', 'cl_collation', 'patch-categorylinks-better-collation.sql' ), |
| 169 | + array( 'do_cl_fields_update' ), |
169 | 170 | array( 'do_collation_update' ), |
170 | 171 | ); |
171 | 172 | } |
Index: trunk/phase3/includes/LinksUpdate.php |
— | — | @@ -426,7 +426,7 @@ |
427 | 427 | * @private |
428 | 428 | */ |
429 | 429 | function getCategoryInsertions( $existing = array() ) { |
430 | | - global $wgContLang, $wgCollationVersion; |
| 430 | + global $wgContLang, $wgCategoryCollation; |
431 | 431 | $diffs = array_diff_assoc( $this->mCategories, $existing ); |
432 | 432 | $arr = array(); |
433 | 433 | foreach ( $diffs as $name => $sortkey ) { |
— | — | @@ -465,7 +465,7 @@ |
466 | 466 | 'cl_sortkey' => $sortkey, |
467 | 467 | 'cl_timestamp' => $this->mDb->timestamp(), |
468 | 468 | 'cl_sortkey_prefix' => $prefix, |
469 | | - 'cl_collation' => $wgCollationVersion, |
| 469 | + 'cl_collation' => $wgCategoryCollation, |
470 | 470 | 'cl_type' => $type, |
471 | 471 | ); |
472 | 472 | } |