Index: trunk/phase3/maintenance/archives/patch-cl_type.sql |
— | — | @@ -1,6 +0,0 @@ |
2 | | - |
3 | | -ALTER TABLE /*_*/categorylinks MODIFY cl_type varchar(6) NOT NULL default 'page'; |
Index: trunk/phase3/maintenance/tables.sql |
— | — | @@ -521,9 +521,7 @@ |
522 | 522 | -- paginate the three categories separately. This never has to be updated |
523 | 523 | -- after the page is created, since none of these page types can be moved to |
524 | 524 | -- any other. |
525 | | - -- This used to be ENUM('page', 'subcat', 'file') but was changed to a |
526 | | - -- varchar because of the weird semantics of < and > when used on enums |
527 | | - cl_type varchar(6) NOT NULL default 'page' |
| 525 | + cl_type ENUM('page', 'subcat', 'file') NOT NULL default 'page' |
528 | 526 | ) /*$wgDBTableOptions*/; |
529 | 527 | |
530 | 528 | CREATE UNIQUE INDEX /*i*/cl_from ON /*_*/categorylinks (cl_from,cl_to); |
Index: trunk/phase3/includes/installer/MysqlUpdater.php |
— | — | @@ -175,7 +175,6 @@ |
176 | 176 | array( 'dropIndex', 'archive', 'ar_page_revid', 'patch-archive_kill_ar_page_revid.sql' ), |
177 | 177 | array( 'addIndex', 'archive', 'ar_revid', 'patch-archive_ar_revid.sql' ), |
178 | 178 | array( 'doLangLinksLengthUpdate' ), |
179 | | - array( 'doClTypeVarcharUpdate' ), |
180 | 179 | ); |
181 | 180 | } |
182 | 181 | |
— | — | @@ -829,18 +828,4 @@ |
830 | 829 | $this->output( "...ll_lang is up-to-date.\n" ); |
831 | 830 | } |
832 | 831 | } |
833 | | - |
834 | | - protected function doClTypeVarcharUpdate() { |
835 | | - $categorylinks = $this->db->tableName( 'categorylinks' ); |
836 | | - $res = $this->db->query( "SHOW COLUMNS FROM $categorylinks LIKE 'cl_type'" ); |
837 | | - $row = $this->db->fetchObject( $res ); |
838 | | - |
839 | | - if ( $row && substr( $row->Type, 0, 4 ) == 'enum' ) { |
840 | | - $this->output( 'Changing cl_type from enum to varchar...' ); |
841 | | - $this->applyPatch( 'patch-cl_type.sql' ); |
842 | | - $this->output( "done.\n" ); |
843 | | - } else { |
844 | | - $this->output( "...cl_type is up-to-date.\n" ); |
845 | | - } |
846 | | - } |
847 | 832 | } |
Index: trunk/phase3/includes/api/ApiQueryCategoryMembers.php |
— | — | @@ -122,27 +122,39 @@ |
123 | 123 | $this->addOption( 'USE INDEX', 'cl_timestamp' ); |
124 | 124 | } else { |
125 | 125 | if ( $params['continue'] ) { |
126 | | - // type|from|sortkey |
127 | | - $cont = explode( '|', $params['continue'], 3 ); |
128 | | - if ( count( $cont ) != 3 ) { |
| 126 | + // from|sortkey |
| 127 | + $cont = explode( '|', $params['continue'], 2 ); |
| 128 | + if ( count( $cont ) != 2 ) { |
129 | 129 | $this->dieUsage( 'Invalid continue param. You should pass the original value returned '. |
130 | 130 | 'by the previous query', '_badcontinue' |
131 | 131 | ); |
132 | 132 | } |
133 | | - $escType = $this->getDB()->addQuotes( $cont[0] ); |
134 | | - $from = intval( $cont[1] ); |
135 | | - $escSortkey = $this->getDB()->addQuotes( $cont[2] ); |
136 | | - $op = $dir == 'newer' ? '>' : '<'; |
137 | | - $this->addWhere( "cl_type $op $escType OR " . |
138 | | - "(cl_type = $escType AND " . |
139 | | - "(cl_sortkey $op $escSortkey OR " . |
140 | | - "(cl_sortkey = $escSortkey AND " . |
141 | | - "cl_from $op= $from)))" |
142 | | - ); |
| 133 | + list ( $from, $contsortkey ) = $cont; |
| 134 | + if ( intval( $from ) == 0 ) { |
| 135 | + $this->dieUsage( 'Invalid continue param. You should pass the original value returned '. |
| 136 | + 'by the previous query', '_badcontinue' |
| 137 | + ); |
| 138 | + } |
| 139 | + $where_outer = array(); |
| 140 | + $where_inner = array(); |
| 141 | + $db = $this->getDB(); |
| 142 | + $op = ( $dir === 'newer' ? '>' : '<' ); |
| 143 | + $sortdir = ( $dir === 'newer' ? 'asc' : 'desc' ); |
| 144 | + $where_outer[] = 'cl_sortkey ' . $op . ' ' . |
| 145 | + $db->addQuotes( $contsortkey ); |
| 146 | + // OR |
| 147 | + $where_inner[] = 'cl_sortkey = ' . |
| 148 | + $db->addQuotes( $contsortkey ); |
| 149 | + // AND |
| 150 | + $where_inner[] = 'cl_from ' . $op . '= '. $from; |
| 151 | + |
| 152 | + $where_outer[] = $db->makeList( $where_inner, LIST_AND ); |
| 153 | + $this->addWhere( $db->makeList( $where_outer, LIST_OR ) ); |
| 154 | + $this->addOption( 'ORDER BY', |
| 155 | + 'cl_sortkey ' . $sortdir .', cl_from ' . $sortdir ); |
143 | 156 | |
144 | 157 | } else { |
145 | | - // The below produces ORDER BY cl_type, cl_sortkey, cl_from, possibly with DESC added to each of them |
146 | | - $this->addWhereRange( 'cl_type', $dir, null, null ); |
| 158 | + // The below produces ORDER BY cl_sortkey, cl_from, possibly with DESC added to each of them |
147 | 159 | $this->addWhereRange( 'cl_sortkey', |
148 | 160 | $dir, |
149 | 161 | $params['startsortkey'], |
— | — | @@ -171,7 +183,7 @@ |
172 | 184 | // because we don't have to worry about pipes in the sortkey that way |
173 | 185 | // (and type and from can't contain pipes anyway) |
174 | 186 | $this->setContinueEnumParameter( 'continue', |
175 | | - "{$row->cl_type}|{$row->cl_from}|{$row->cl_sortkey}" |
| 187 | + "{$row->cl_from}|{$row->cl_sortkey}" |
176 | 188 | ); |
177 | 189 | } |
178 | 190 | break; |
— | — | @@ -213,7 +225,7 @@ |
214 | 226 | $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->cl_timestamp ) ); |
215 | 227 | } else { |
216 | 228 | $this->setContinueEnumParameter( 'continue', |
217 | | - "{$row->cl_type}|{$row->cl_from}|{$row->cl_sortkey}" |
| 229 | + "{$row->cl_from}|{$row->cl_sortkey}" |
218 | 230 | ); |
219 | 231 | } |
220 | 232 | break; |