Index: trunk/phase3/includes/LinkBatch.php |
— | — | @@ -82,6 +82,8 @@ |
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Add a ResultWrapper containing IDs and titles to a LinkCache object |
| 86 | + * Title are initialized here and they will go to the static title cache |
| 87 | + * field of the Title class. |
86 | 88 | */ |
87 | 89 | function addResultToCache( $cache, $res ) { |
88 | 90 | if ( !$res ) { |
— | — | @@ -93,7 +95,7 @@ |
94 | 96 | $ids = array(); |
95 | 97 | $remaining = $this->data; |
96 | 98 | while ( $row = $res->fetchObject() ) { |
97 | | - $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
| 99 | + $title = Title::newFromRow( $row ); |
98 | 100 | $cache->addGoodLinkObj( $row->page_id, $title ); |
99 | 101 | $ids[$title->getPrefixedDBkey()] = $row->page_id; |
100 | 102 | unset( $remaining[$row->page_namespace][$row->page_title] ); |
— | — | @@ -128,7 +130,7 @@ |
129 | 131 | wfProfileOut( __METHOD__ ); |
130 | 132 | return false; |
131 | 133 | } |
132 | | - $sql = "SELECT page_id, page_namespace, page_title FROM $page WHERE $set"; |
| 134 | + $sql = "SELECT page_id, page_namespace, page_title, page_len, page_is_redirect FROM $page WHERE $set"; |
133 | 135 | |
134 | 136 | // Do query |
135 | 137 | $res = new ResultWrapper( $dbr, $dbr->query( $sql, __METHOD__ ) ); |
Index: trunk/phase3/includes/Linker.php |
— | — | @@ -79,20 +79,16 @@ |
80 | 80 | /** |
81 | 81 | * Return the CSS colour of a known link |
82 | 82 | * |
83 | | - * @param mixed $s |
| 83 | + * @param Title $t |
84 | 84 | * @param integer $threshold user defined threshold |
85 | 85 | * @return string CSS class |
86 | 86 | */ |
87 | | - function getLinkColour( $s, $threshold ) { |
88 | | - if( $s === false ) { |
89 | | - return ''; |
90 | | - } |
91 | | - |
| 87 | + function getLinkColour( $t, $threshold ) { |
92 | 88 | $colour = ''; |
93 | | - if ( !empty( $s->page_is_redirect ) ) { |
| 89 | + if ( $t->isRedirect() ) { |
94 | 90 | # Page is a redirect |
95 | 91 | $colour = 'mw-redirect'; |
96 | | - } elseif ( $threshold > 0 && $s->page_len < $threshold && MWNamespace::isContent( $s->page_namespace ) ) { |
| 92 | + } elseif ( $threshold > 0 && $t->getLength() < $threshold && MWNamespace::isContent( $t->getNamespace() ) ) { |
97 | 93 | # Page is a stub |
98 | 94 | $colour = 'stub'; |
99 | 95 | } |
— | — | @@ -256,15 +252,8 @@ |
257 | 253 | } else { |
258 | 254 | $colour = ''; |
259 | 255 | if ( $nt->isContentPage() ) { |
260 | | - # FIXME: This is stupid, we should combine this query with |
261 | | - # the Title::getArticleID() query above. |
262 | 256 | $threshold = $wgUser->getOption('stubthreshold'); |
263 | | - $dbr = wfGetDB( DB_SLAVE ); |
264 | | - $s = $dbr->selectRow( |
265 | | - array( 'page' ), |
266 | | - array( 'page_len', 'page_is_redirect', 'page_namespace' ), |
267 | | - array( 'page_id' => $aid ), __METHOD__ ) ; |
268 | | - $colour = $this->getLinkColour( $s, $threshold ); |
| 257 | + $colour = $this->getLinkColour( $nt, $threshold ); |
269 | 258 | } |
270 | 259 | $retVal = $this->makeColouredLinkObj( $nt, $colour, $text, $query, $trail, $prefix ); |
271 | 260 | } |
Index: trunk/phase3/includes/Parser.php |
— | — | @@ -4003,10 +4003,7 @@ |
4004 | 4004 | # Not in the link cache, add it to the query |
4005 | 4005 | if ( !isset( $current ) ) { |
4006 | 4006 | $current = $ns; |
4007 | | - $query = "SELECT page_id, page_namespace, page_title, page_is_redirect"; |
4008 | | - if ( $threshold > 0 ) { |
4009 | | - $query .= ', page_len'; |
4010 | | - } |
| 4007 | + $query = "SELECT page_id, page_namespace, page_title, page_is_redirect, page_len"; |
4011 | 4008 | $query .= " FROM $page WHERE (page_namespace=$ns AND page_title IN("; |
4012 | 4009 | } elseif ( $current != $ns ) { |
4013 | 4010 | $current = $ns; |
— | — | @@ -4029,7 +4026,7 @@ |
4030 | 4027 | # Fetch data and form into an associative array |
4031 | 4028 | # non-existent = broken |
4032 | 4029 | while ( $s = $dbr->fetchObject($res) ) { |
4033 | | - $title = Title::makeTitle( $s->page_namespace, $s->page_title ); |
| 4030 | + $title = Title::newFromRow( $s ); |
4034 | 4031 | $pdbk = $title->getPrefixedDBkey(); |
4035 | 4032 | $linkCache->addGoodLinkObj( $s->page_id, $title ); |
4036 | 4033 | $this->mOutput->addLink( $title, $s->page_id ); |
— | — | @@ -4094,10 +4091,7 @@ |
4095 | 4092 | // construct query |
4096 | 4093 | $titleClause = $linkBatch->constructSet('page', $dbr); |
4097 | 4094 | |
4098 | | - $variantQuery = "SELECT page_id, page_namespace, page_title, page_is_redirect"; |
4099 | | - if ( $threshold > 0 ) { |
4100 | | - $variantQuery .= ', page_len'; |
4101 | | - } |
| 4095 | + $variantQuery = "SELECT page_id, page_namespace, page_title, page_is_redirect, page_len"; |
4102 | 4096 | |
4103 | 4097 | $variantQuery .= " FROM $page WHERE $titleClause"; |
4104 | 4098 | if ( $options & RLH_FOR_UPDATE ) { |
— | — | @@ -4109,7 +4103,7 @@ |
4110 | 4104 | // for each found variants, figure out link holders and replace |
4111 | 4105 | while ( $s = $dbr->fetchObject($varRes) ) { |
4112 | 4106 | |
4113 | | - $variantTitle = Title::makeTitle( $s->page_namespace, $s->page_title ); |
| 4107 | + $variantTitle = Title::newFromRow( $s ); |
4114 | 4108 | $varPdbk = $variantTitle->getPrefixedDBkey(); |
4115 | 4109 | $vardbk = $variantTitle->getDBkey(); |
4116 | 4110 | |
Index: trunk/phase3/includes/SpecialContributions.php |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | |
13 | 13 | function __construct( $target, $namespace = false, $year = false, $month = false ) { |
14 | 14 | parent::__construct(); |
15 | | - foreach( explode( ' ', 'uctop diff newarticle rollbacklink diff hist minoreditletter' ) as $msg ) { |
| 15 | + foreach( explode( ' ', 'uctop diff newarticle rollbacklink diff hist newpageletter minoreditletter' ) as $msg ) { |
16 | 16 | $this->messages[$msg] = wfMsgExt( $msg, array( 'escape') ); |
17 | 17 | } |
18 | 18 | $this->target = $target; |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | 'fields' => array( |
44 | 44 | 'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'rev_id', 'rev_page', |
45 | 45 | 'rev_text_id', 'rev_timestamp', 'rev_comment', 'rev_minor_edit', 'rev_user', |
46 | | - 'rev_user_text', 'rev_deleted' |
| 46 | + 'rev_user_text', 'rev_parent_id', 'rev_deleted' |
47 | 47 | ), |
48 | 48 | 'conds' => $conds, |
49 | 49 | 'options' => array( 'USE INDEX' => $index ) |
— | — | @@ -165,6 +165,12 @@ |
166 | 166 | if( $rev->isDeleted( Revision::DELETED_TEXT ) ) { |
167 | 167 | $d = '<span class="history-deleted">' . $d . '</span>'; |
168 | 168 | } |
| 169 | + |
| 170 | + if( $rev->getParentId() === 0 ) { |
| 171 | + $nflag = '<span class="newpage">' . $this->messages['newpageletter'] . '</span>'; |
| 172 | + } else { |
| 173 | + $nflag = ''; |
| 174 | + } |
169 | 175 | |
170 | 176 | if( $row->rev_minor_edit ) { |
171 | 177 | $mflag = '<span class="minor">' . $this->messages['minoreditletter'] . '</span> '; |
— | — | @@ -172,7 +178,7 @@ |
173 | 179 | $mflag = ''; |
174 | 180 | } |
175 | 181 | |
176 | | - $ret = "{$d} {$histlink} {$difftext} {$mflag} {$link}{$userlink}{$comment} {$topmarktext}"; |
| 182 | + $ret = "{$d} {$histlink} {$difftext} {$nflag}{$mflag} {$link}{$userlink}{$comment} {$topmarktext}"; |
177 | 183 | if( $rev->isDeleted( Revision::DELETED_TEXT ) ) { |
178 | 184 | $ret .= ' ' . wfMsgHtml( 'deletedrev' ); |
179 | 185 | } |
Index: trunk/phase3/includes/WatchlistEditor.php |
— | — | @@ -205,14 +205,15 @@ |
206 | 206 | $dbr = wfGetDB( DB_MASTER ); |
207 | 207 | $uid = intval( $user->getId() ); |
208 | 208 | list( $watchlist, $page ) = $dbr->tableNamesN( 'watchlist', 'page' ); |
209 | | - $sql = "SELECT wl_namespace, wl_title, page_id, page_is_redirect |
| 209 | + $sql = "SELECT wl_namespace, wl_title, page_id, page_len, page_is_redirect, |
| 210 | + page_namespace, page_title |
210 | 211 | FROM {$watchlist} LEFT JOIN {$page} ON ( wl_namespace = page_namespace |
211 | 212 | AND wl_title = page_title ) WHERE wl_user = {$uid}"; |
212 | 213 | $res = $dbr->query( $sql, __METHOD__ ); |
213 | 214 | if( $res && $dbr->numRows( $res ) > 0 ) { |
214 | 215 | $cache = LinkCache::singleton(); |
215 | 216 | while( $row = $dbr->fetchObject( $res ) ) { |
216 | | - $title = Title::makeTitleSafe( $row->wl_namespace, $row->wl_title ); |
| 217 | + $title = Title::newFromRow( $row ); |
217 | 218 | if( $title instanceof Title ) { |
218 | 219 | // Update the link cache while we're at it |
219 | 220 | if( $row->page_id ) { |
Index: trunk/phase3/includes/filerepo/File.php |
— | — | @@ -844,14 +844,15 @@ |
845 | 845 | |
846 | 846 | list( $page, $imagelinks ) = $db->tableNamesN( 'page', 'imagelinks' ); |
847 | 847 | $encName = $db->addQuotes( $this->getName() ); |
848 | | - $sql = "SELECT page_namespace,page_title,page_id FROM $page,$imagelinks WHERE page_id=il_from AND il_to=$encName $options"; |
| 848 | + $sql = "SELECT page_namespace,page_title,page_id,page_len,page_is_redirect, |
| 849 | + FROM $page,$imagelinks WHERE page_id=il_from AND il_to=$encName $options"; |
849 | 850 | $res = $db->query( $sql, __METHOD__ ); |
850 | 851 | |
851 | 852 | $retVal = array(); |
852 | 853 | if ( $db->numRows( $res ) ) { |
853 | 854 | while ( $row = $db->fetchObject( $res ) ) { |
854 | | - if ( $titleObj = Title::makeTitle( $row->page_namespace, $row->page_title ) ) { |
855 | | - $linkCache->addGoodLinkObj( $row->page_id, $titleObj ); |
| 855 | + if ( $titleObj = Title::newFromRow( $row ) ) { |
| 856 | + $linkCache->addGoodLinkObj( $row->page_id, $titleObj, $row->page_len, $row->page_is_redirect ); |
856 | 857 | $retVal[] = $titleObj; |
857 | 858 | } |
858 | 859 | } |
Index: trunk/phase3/includes/Parser_OldPP.php |
— | — | @@ -4120,9 +4120,7 @@ |
4121 | 4121 | # Not in the link cache, add it to the query |
4122 | 4122 | if ( !isset( $current ) ) { |
4123 | 4123 | $current = $ns; |
4124 | | - $query = "SELECT page_id, page_namespace, page_title"; |
4125 | | - if ( $threshold > 0 ) { |
4126 | | - $query .= ', page_len, page_is_redirect'; |
| 4124 | + $query = "SELECT page_id, page_namespace, page_title, page_len, page_is_redirect"; |
4127 | 4125 | } |
4128 | 4126 | $query .= " FROM $page WHERE (page_namespace=$ns AND page_title IN("; |
4129 | 4127 | } elseif ( $current != $ns ) { |
— | — | @@ -4148,7 +4146,7 @@ |
4149 | 4147 | # 1 = known |
4150 | 4148 | # 2 = stub |
4151 | 4149 | while ( $s = $dbr->fetchObject($res) ) { |
4152 | | - $title = Title::makeTitle( $s->page_namespace, $s->page_title ); |
| 4150 | + $title = Title::newFromRow( $s ); |
4153 | 4151 | $pdbk = $title->getPrefixedDBkey(); |
4154 | 4152 | $linkCache->addGoodLinkObj( $s->page_id, $title ); |
4155 | 4153 | $this->mOutput->addLink( $title, $s->page_id ); |
— | — | @@ -4163,7 +4161,7 @@ |
4164 | 4162 | wfProfileOut( $fname.'-check' ); |
4165 | 4163 | |
4166 | 4164 | # Do a second query for different language variants of links and categories |
4167 | | - if($wgContLang->hasVariants()){ |
| 4165 | + if( $wgContLang->hasVariants() ){ |
4168 | 4166 | $linkBatch = new LinkBatch(); |
4169 | 4167 | $variantMap = array(); // maps $pdbkey_Variant => $keys (of link holders) |
4170 | 4168 | $categoryMap = array(); // maps $category_variant => $category (dbkeys) |
— | — | @@ -4210,13 +4208,11 @@ |
4211 | 4209 | } |
4212 | 4210 | |
4213 | 4211 | |
4214 | | - if(!$linkBatch->isEmpty()){ |
| 4212 | + if ( !$linkBatch->isEmpty() ){ |
4215 | 4213 | // construct query |
4216 | 4214 | $titleClause = $linkBatch->constructSet('page', $dbr); |
4217 | 4215 | |
4218 | | - $variantQuery = "SELECT page_id, page_namespace, page_title"; |
4219 | | - if ( $threshold > 0 ) { |
4220 | | - $variantQuery .= ', page_len, page_is_redirect'; |
| 4216 | + $variantQuery = "SELECT page_id, page_namespace, page_title, page_len, page_is_redirect"; |
4221 | 4217 | } |
4222 | 4218 | |
4223 | 4219 | $variantQuery .= " FROM $page WHERE $titleClause"; |
— | — | @@ -4229,7 +4225,7 @@ |
4230 | 4226 | // for each found variants, figure out link holders and replace |
4231 | 4227 | while ( $s = $dbr->fetchObject($varRes) ) { |
4232 | 4228 | |
4233 | | - $variantTitle = Title::makeTitle( $s->page_namespace, $s->page_title ); |
| 4229 | + $variantTitle = Title::newFromRow( $s ); |
4234 | 4230 | $varPdbk = $variantTitle->getPrefixedDBkey(); |
4235 | 4231 | $vardbk = $variantTitle->getDBkey(); |
4236 | 4232 | |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -63,6 +63,8 @@ |
64 | 64 | var $mDefaultNamespace; # Namespace index when there is no namespace |
65 | 65 | # Zero except in {{transclusion}} tags |
66 | 66 | var $mWatched; # Is $wgUser watching this page? NULL if unfilled, accessed through userIsWatching() |
| 67 | + var $mLength; # The page length, 0 for special pages |
| 68 | + var $mRedirect; # Is the article at this title a redirect? |
67 | 69 | /**#@-*/ |
68 | 70 | |
69 | 71 | |
— | — | @@ -83,6 +85,8 @@ |
84 | 86 | $this->mWatched = NULL; |
85 | 87 | $this->mLatestID = false; |
86 | 88 | $this->mOldRestrictions = false; |
| 89 | + $this->mLength = -1; |
| 90 | + $this->mRedirect = null; |
87 | 91 | } |
88 | 92 | |
89 | 93 | /** |
— | — | @@ -220,6 +224,20 @@ |
221 | 225 | } |
222 | 226 | return $titles; |
223 | 227 | } |
| 228 | + |
| 229 | + /** |
| 230 | + * Make a Title object from a DB row |
| 231 | + * @param Row $row (needs at least page_title,page_namespace) |
| 232 | + */ |
| 233 | + public static function newFromRow( $row ) { |
| 234 | + $t = self::makeTitle( $row->page_namespace, $row->page_title ); |
| 235 | + $t->mArticleID = isset($row->page_id) ? $row->page_id : -1; |
| 236 | + $t->mLength = isset($row->page_len) ? $row->page_len : -1; |
| 237 | + $t->mRedirect = isset($row->page_is_redirect) ? $row->page_is_redirect : -1; |
| 238 | + $t->mLatest = isset($row->page_latest) ? $row->page_latest : 0; |
| 239 | + |
| 240 | + return $t; |
| 241 | + } |
224 | 242 | |
225 | 243 | /** |
226 | 244 | * Create a new Title from a namespace index and a DB key. |
— | — | @@ -1463,8 +1481,49 @@ |
1464 | 1482 | public function isTalkPage() { |
1465 | 1483 | return MWNamespace::isTalk( $this->getNamespace() ); |
1466 | 1484 | } |
| 1485 | + |
| 1486 | + /** |
| 1487 | + * Is this an article that is a redirect page? |
| 1488 | + * @return bool |
| 1489 | + */ |
| 1490 | + public function isRedirect() { |
| 1491 | + if( $this->mRedirect !== null ) |
| 1492 | + return $this->mRedirect; |
| 1493 | + # Zero for special pages |
| 1494 | + if( $this->mArticleID <= 0 ) |
| 1495 | + return 0; |
1467 | 1496 | |
| 1497 | + $dbr = wfGetDB( DB_SLAVE ); |
| 1498 | + $redir = $dbr->selectField( 'page', 'page_is_redirect', |
| 1499 | + array( 'page_id' => $this->mArticleID ), |
| 1500 | + __METHOD__ ); |
| 1501 | + |
| 1502 | + $this->mRedirect = $redir ? true : false; |
| 1503 | + |
| 1504 | + return $this->mRedirect; |
| 1505 | + } |
| 1506 | + |
1468 | 1507 | /** |
| 1508 | + * What is the length of this page (-1 for special pages)? |
| 1509 | + * @return bool |
| 1510 | + */ |
| 1511 | + public function getLength() { |
| 1512 | + if( $this->mLength != -1 || $this->mArticleID == 0 ) |
| 1513 | + return $this->mLength; |
| 1514 | + # Zero for special pages |
| 1515 | + if( $this->mArticleID <= 0 ) |
| 1516 | + return -1; |
| 1517 | + |
| 1518 | + $dbr = wfGetDB( DB_SLAVE ); |
| 1519 | + $len = $dbr->selectField( 'page', 'page_len', |
| 1520 | + array( 'page_id' => $this->mArticleID ), |
| 1521 | + __METHOD__ ); |
| 1522 | + $this->mLength = intval($len); |
| 1523 | + |
| 1524 | + return $this->mLength; |
| 1525 | + } |
| 1526 | + |
| 1527 | + /** |
1469 | 1528 | * Is this a subpage? |
1470 | 1529 | * @return bool |
1471 | 1530 | */ |
— | — | @@ -2173,7 +2232,7 @@ |
2174 | 2233 | } |
2175 | 2234 | |
2176 | 2235 | $res = $db->select( array( 'page', $table ), |
2177 | | - array( 'page_namespace', 'page_title', 'page_id' ), |
| 2236 | + array( 'page_namespace', 'page_title', 'page_id', 'page_len', 'page_is_redirect' ), |
2178 | 2237 | array( |
2179 | 2238 | "{$prefix}_from=page_id", |
2180 | 2239 | "{$prefix}_namespace" => $this->getNamespace(), |
— | — | @@ -2185,7 +2244,7 @@ |
2186 | 2245 | if ( $db->numRows( $res ) ) { |
2187 | 2246 | while ( $row = $db->fetchObject( $res ) ) { |
2188 | 2247 | if ( $titleObj = Title::makeTitle( $row->page_namespace, $row->page_title ) ) { |
2189 | | - $linkCache->addGoodLinkObj( $row->page_id, $titleObj ); |
| 2248 | + $linkCache->addGoodLinkObj( $row->page_id, $titleObj, $row->page_len, $row->page_is_redir ); |
2190 | 2249 | $retVal[] = $titleObj; |
2191 | 2250 | } |
2192 | 2251 | } |