* @return bool|ResultWrapper
*/
public function doQuery() {
- global $wgContentHandlerUseDB, $wgPageLanguageUseDB;
-
if ( $this->isEmpty() ) {
return false;
}
// This is similar to LinkHolderArray::replaceInternal
$dbr = wfGetDB( DB_SLAVE );
$table = 'page';
- $fields = [ 'page_id', 'page_namespace', 'page_title', 'page_len',
- 'page_is_redirect', 'page_latest' ];
-
- if ( $wgContentHandlerUseDB ) {
- $fields[] = 'page_content_model';
- }
- if ( $wgPageLanguageUseDB ) {
- $fields[] = 'page_lang';
- }
+ $fields = array_merge(
+ LinkCache::getSelectFields(),
+ [ 'page_namespace', 'page_title' ]
+ );
$conds = $this->constructSet( 'page', $dbr );
return $this->addLinkObj( $nt );
}
+ /**
+ * Fields that LinkCache needs to select
+ *
+ * @since 1.28
+ * @return array
+ */
+ public static function getSelectFields() {
+ global $wgContentHandlerUseDB, $wgPageLanguageUseDB;
+
+ $fields = [ 'page_id', 'page_len', 'page_is_redirect', 'page_latest' ];
+ if ( $wgContentHandlerUseDB ) {
+ $fields[] = 'page_content_model';
+ }
+ if ( $wgPageLanguageUseDB ) {
+ $fields[] = 'page_lang';
+ }
+
+ return $fields;
+ }
+
/**
* Add a title to the link cache, return the page_id or zero if non-existent
*
* @return int Page ID or zero
*/
public function addLinkObj( LinkTarget $nt ) {
- global $wgContentHandlerUseDB, $wgPageLanguageUseDB;
-
$key = $this->titleFormatter->getPrefixedDBkey( $nt );
if ( $this->isBadLink( $key ) || $nt->isExternal() ) {
return 0;
// Some fields heavily used for linking...
$db = $this->mForUpdate ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
- $fields = [ 'page_id', 'page_len', 'page_is_redirect', 'page_latest' ];
- if ( $wgContentHandlerUseDB ) {
- $fields[] = 'page_content_model';
- }
- if ( $wgPageLanguageUseDB ) {
- $fields[] = 'page_lang';
- }
-
- $row = $db->selectRow( 'page', $fields,
+ $row = $db->selectRow( 'page', self::getSelectFields(),
[ 'page_namespace' => $nt->getNamespace(), 'page_title' => $nt->getDBkey() ],
__METHOD__
);
return;
}
- global $wgContLang, $wgContentHandlerUseDB, $wgPageLanguageUseDB;
+ global $wgContLang;
$colours = [];
$linkCache = LinkCache::singleton();
}
}
if ( !$lb->isEmpty() ) {
- $fields = [ 'page_id', 'page_namespace', 'page_title',
- 'page_is_redirect', 'page_len', 'page_latest' ];
-
- if ( $wgContentHandlerUseDB ) {
- $fields[] = 'page_content_model';
- }
- if ( $wgPageLanguageUseDB ) {
- $fields[] = 'page_lang';
- }
+ $fields = array_merge(
+ LinkCache::getSelectFields(),
+ [ 'page_namespace', 'page_title' ]
+ );
$res = $dbr->select(
'page',
* @param array $colours
*/
protected function doVariants( &$colours ) {
- global $wgContLang, $wgContentHandlerUseDB, $wgPageLanguageUseDB;
+ global $wgContLang;
$linkBatch = new LinkBatch();
$variantMap = []; // maps $pdbkey_Variant => $keys (of link holders)
$output = $this->parent->getOutput();
if ( !$linkBatch->isEmpty() ) {
// construct query
$dbr = wfGetDB( DB_SLAVE );
- $fields = [ 'page_id', 'page_namespace', 'page_title',
- 'page_is_redirect', 'page_len', 'page_latest' ];
-
- if ( $wgContentHandlerUseDB ) {
- $fields[] = 'page_content_model';
- }
- if ( $wgPageLanguageUseDB ) {
- $fields[] = 'page_lang';
- }
+ $fields = array_merge(
+ LinkCache::getSelectFields(),
+ [ 'page_namespace', 'page_title' ]
+ );
$varRes = $dbr->select( 'page',
$fields,