Skip to content

Commit

Permalink
Release v3.0.2 (#102)
Browse files Browse the repository at this point in the history
* Use PageStoreRecord::REQUIRED_FIELDS for fields (#99)

(cherry picked from commit 6c61256)

* Release v3.0.2
  • Loading branch information
lens0021 authored Jul 10, 2022
1 parent e349eca commit cc72ae9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 53 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Versions and bullets are arranged chronologically from latest to oldest.

## v3.0.2

- Fixed the errors happened with RelatedArticlesUseLinks.

## v3.0.1

- Localisations update from https://translatewiki.net.
Expand Down
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "UnifiedExtensionForFemiwiki",
"version": "3.0.1",
"version": "3.0.2",
"author": "[https://femiwiki.com/ Femiwiki Team]",
"url": "https://github.com/femiwiki/unifiedExtensionForFemiwiki",
"descriptionmsg": "unifiedextensionforfemiwiki-desc",
Expand Down
88 changes: 36 additions & 52 deletions includes/HookHandlers/RelatedArticles.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Config;
use ExtensionRegistry;
use MediaWiki\MediaWikiServices;
use MediaWiki\Page\PageStoreRecord;
use Title;
use Wikimedia\Rdbms\DBConnRef;
use Wikimedia\Rdbms\ILoadBalancer;
Expand Down Expand Up @@ -138,19 +139,7 @@ private function makeTitlesFromHereSQL( Title $title, DBConnRef $dbr, $targetNam
// Hide redirects
'rd_from' => null,
] )
->fields( [
'page_namespace',
'page_title',
'page_touched',
// Used by LinkCache::addGoodLinkObjFromRow()
'page_id',
'page_len',
'page_is_redirect',
'page_latest',
'page_content_model',
'page_lang',
'page_restrictions',
] )
->fields( self::getSelectFields() )
->getSQL();
}

Expand Down Expand Up @@ -184,19 +173,7 @@ private function makeRedirectedTitlesFromHereSQL( Title $title, DBConnRef $dbr,
// Only redirects
'rd_from != 0',
] )
->fields( [
'page_namespace' => 'target.page_namespace',
'page_title' => 'target.page_title',
'page_touched' => 'target.page_touched',
// Used by LinkCache::addGoodLinkObjFromRow()
'page_id' => 'target.page_id',
'page_len' => 'target.page_len',
'page_is_redirect' => 'target.page_is_redirect',
'page_latest' => 'target.page_latest',
'page_content_model' => 'target.page_content_model',
'page_lang' => 'target.page_lang',
'page_restrictions' => 'target.page_restrictions',
] )
->fields( self::getSelectFields( 'target' ) )
->getSQL();
}

Expand Down Expand Up @@ -226,19 +203,7 @@ private function makeTitlesToHereSQL( Title $title, DBConnRef $dbr, $targetNames
->conds( $targetNamespaces ? [
'page_namespace' => $targetNamespaces,
] : [] )
->fields( [
'page_namespace',
'page_title',
'page_touched',
// Used by LinkCache::addGoodLinkObjFromRow()
'page_id',
'page_len',
'page_is_redirect',
'page_latest',
'page_content_model',
'page_lang',
'page_restrictions',
] )
->fields( self::getSelectFields() )
->getSQL();
}

Expand Down Expand Up @@ -276,19 +241,38 @@ private function makeTitlesToRedirectsOfHereSQL( Title $title, DBConnRef $dbr, $
->conds( $targetNamespaces ? [
'redirect_from.page_namespace' => $targetNamespaces,
] : [] )
->fields( [
'page_namespace' => 'redirect_from.page_namespace',
'page_title' => 'redirect_from.page_title',
'page_touched' => 'redirect_from.page_touched',
// Used by LinkCache::addGoodLinkObjFromRow()
'page_id' => 'redirect_from.page_id',
'page_len' => 'redirect_from.page_len',
'page_is_redirect' => 'redirect_from.page_is_redirect',
'page_latest' => 'redirect_from.page_latest',
'page_content_model' => 'redirect_from.page_content_model',
'page_lang' => 'redirect_from.page_lang',
'page_restrictions' => 'redirect_from.page_restrictions',
] )
->fields( self::getSelectFields( 'redirect_from' ) )
->getSQL();
}

/**
* @param string|null $table
* @return array
*/
public static function getSelectFields( $table = null ) {
$pageLanguageUseDB = MediaWikiServices::getInstance()->getMainConfig()->get( 'PageLanguageUseDB' );

$fields = array_merge(
PageStoreRecord::REQUIRED_FIELDS,
[
'page_len',
'page_restrictions',
'page_content_model',
]
);

if ( $pageLanguageUseDB ) {
$fields[] = 'page_lang';
}

if ( $table ) {
$fieldMap = [];
foreach ( $fields as $f ) {
$fieldMap[$f] = "$table.$f";
}
return $fieldMap;
}

return $fields;
}
}

0 comments on commit cc72ae9

Please sign in to comment.