Fixes for 1.39 (#90)

This commit is contained in:
CosmicAlpha 2022-12-06 17:19:24 -07:00 committed by GitHub
parent 20a96bde1d
commit 574e709a45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 45 deletions

View file

@ -14,7 +14,7 @@ jobs:
matrix:
include:
# Latest stable MediaWiki - PHP 7.4 (phan)
- mw: 'REL1_37'
- mw: 'REL1_39'
php: 7.4
php-docker: 74
experimental: false
@ -35,7 +35,7 @@ jobs:
stage: coverage
# Latest stable MediaWiki - PHP 7.4 (phpunit-unit)
- mw: 'REL1_37'
- mw: 'REL1_39'
php: 7.4
php-docker: 74
experimental: false
@ -49,7 +49,7 @@ jobs:
stage: phpunit-unit
# Latest stable MediaWiki - PHP 7.4 (phpunit)
- mw: 'REL1_37'
- mw: 'REL1_39'
php: 7.4
php-docker: 74
experimental: false
@ -63,7 +63,7 @@ jobs:
stage: phpunit
# Latest stable MediaWiki - PHP 7.4 (selenium)
- mw: 'REL1_37'
- mw: 'REL1_39'
php: 7.4
php-docker: 74
experimental: false
@ -77,7 +77,7 @@ jobs:
stage: selenium
# Latest stable MediaWiki - PHP 7.4 (qunit)
- mw: 'REL1_37'
- mw: 'REL1_39'
php: 7.4
php-docker: 74
experimental: false
@ -91,14 +91,14 @@ jobs:
stage: qunit
# Latest stable MediaWiki - PHP 7.4 (npm-test)
- mw: 'REL1_38'
- mw: 'REL1_39'
php: 7.4
php-docker: 74
experimental: false
stage: npm-test
# Latest stable MediaWiki - PHP 7.4 (composer-test)
- mw: 'REL1_38'
- mw: 'REL1_39'
php: 7.4
php-docker: 74
experimental: false

View file

@ -1,5 +1,5 @@
# PortableInfobox
Port of FANDOM's https://github.com/Wikia/app/tree/dev/extensions/wikia/PortableInfobox extension to MediaWiki 1.37.0+
Port of FANDOM's https://github.com/Wikia/app/tree/dev/extensions/wikia/PortableInfobox extension to MediaWiki 1.39.0+ (1.37-1.38 are available in release branches)
## Installation
Grab the latest release from [GitHub](https://github.com/Universal-Omega/PortableInfobox) and unpack it into `extensions\PortableInfobox` directory in your MediaWiki installation or clone this repository, by using these commands:

View file

@ -11,7 +11,7 @@
"type": "parserhook",
"license-name": "GPL-3.0-or-later",
"requires": {
"MediaWiki": ">= 1.37.0",
"MediaWiki": ">= 1.39.0",
"platform": {
"php": ">= 7.3"
}

View file

@ -176,23 +176,11 @@ class PortableInfoboxParserTagController {
}
private static function parserOutputGetPageProperty( \ParserOutput $parserOutput, string $name ) {
if ( method_exists( \ParserOutput::class, 'getPageProperty' ) ) {
// @phan-suppress-next-line PhanUndeclaredMethod since 1.38
return $parserOutput->getPageProperty( $name );
} else {
// @phan-suppress-next-line PhanDeprecatedFunction deprecated since 1.38
return $parserOutput->getProperty( $name );
}
return $parserOutput->getPageProperty( $name );
}
private static function parserOutputSetPageProperty( \ParserOutput $parserOutput, string $name, $value ) {
if ( method_exists( \ParserOutput::class, 'setPageProperty' ) ) {
// @phan-suppress-next-line PhanUndeclaredMethod since 1.38
$parserOutput->setPageProperty( $name, $value );
} else {
// @phan-suppress-next-line PhanDeprecatedFunction deprecated since 1.38
$parserOutput->setProperty( $name, $value );
}
$parserOutput->setPageProperty( $name, $value );
}
private function handleError( $message ) {

View file

@ -33,7 +33,7 @@ class AllInfoboxesQueryPage extends PageQueryPage {
]
];
$dbr = $this->getDBLoadBalancer()->getConnectionRef( DB_REPLICA );
$dbr = $this->getDBLoadBalancer()->getConnection( DB_REPLICA );
$subpagesBlacklist = $this->getConfig()->get( 'AllInfoboxesSubpagesBlacklist' );
foreach ( $subpagesBlacklist as $subpage ) {

View file

@ -2,6 +2,8 @@
namespace PortableInfobox\Helpers;
use MediaWiki\MediaWikiServices;
class PagePropsProxy {
protected $atomicStarted;
@ -12,7 +14,8 @@ class PagePropsProxy {
}
public function get( $id, $property ) {
$dbr = wfGetDB( DB_REPLICA );
$dbLoadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer();
$dbr = $dbLoadBalancer->getConnection( DB_REPLICA );
$propValue = $dbr->selectField(
'page_props',
'pp_value',
@ -26,7 +29,8 @@ class PagePropsProxy {
}
public function set( $id, array $props ) {
$dbw = wfGetDB( DB_PRIMARY );
$dbLoadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer();
$dbw = $dbLoadBalancer->getConnection( DB_PRIMARY );
if ( !$this->atomicStarted ) {
$dbw->startAtomic( __METHOD__ );
@ -59,7 +63,10 @@ class PagePropsProxy {
public function write() {
if ( $this->atomicStarted && $this->manualWrite ) {
wfGetDB( DB_PRIMARY )->endAtomic( __CLASS__ . '::set' );
$dbLoadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer();
$dbLoadBalancer->getConnection( DB_PRIMARY )
->endAtomic( __CLASS__ . '::set' );
$this->atomicStarted = false;
}
}

View file

@ -74,13 +74,7 @@ class PortableInfoboxParsingHelper {
}
private static function parserOutputGetPageProperty( \ParserOutput $parserOutput, string $name ) {
if ( method_exists( \ParserOutput::class, 'getPageProperty' ) ) {
// @phan-suppress-next-line PhanUndeclaredMethod since 1.38
return $parserOutput->getPageProperty( $name );
} else {
// @phan-suppress-next-line PhanDeprecatedFunction deprecated since 1.38
return $parserOutput->getProperty( $name );
}
return $parserOutput->getPageProperty( $name );
}
/**

View file

@ -94,22 +94,14 @@ class MediaWikiParserService implements ExternalParser {
// Pass PI images to PageImages extension if available (Popups and og:image)
if ( method_exists(
ParserFileProcessingHookHandlers::class, 'onParserMakeImageParams'
) ) {
$params = [];
// @phan-suppress-next-line PhanUndeclaredStaticMethod
ParserFileProcessingHookHandlers::onParserMakeImageParams(
$title, $file, $params, $this->parser
);
} elseif ( method_exists(
ParserFileProcessingHookHandlers::class, 'onParserModifyImageHTML'
) ) {
// 1.38+
$handler = new ParserFileProcessingHookHandlers();
$params = [];
$html = '';
// @phan-suppress-next-line PhanUndeclaredStaticMethod
ParserFileProcessingHookHandlers::onParserModifyImageHTML(
$handler->onParserModifyImageHTML(
$this->parser, $file, $params, $html
);
}