Restore MediaWiki 1.35 compatibility (#79)

Co-authored-by: rvogel <vogel@hallowelt.biz>
This commit is contained in:
Robert Vogel 2022-01-28 18:06:58 +01:00 committed by GitHub
parent db51e49ba5
commit f20ad2e16f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 7 deletions

View file

@ -1,6 +1,6 @@
{
"name": "DynamicPageList3",
"version": "3.3.7",
"version": "3.3.8",
"author": [
"Alexia E. Smith",
"[https://meta.miraheze.org/wiki/User:Universal_Omega Universal Omega]",
@ -11,7 +11,7 @@
"license-name": "GPL-3.0-or-later",
"type": "parserhook",
"requires": {
"MediaWiki": ">= 1.36.0"
"MediaWiki": ">= 1.35.0"
},
"GroupPermissions": {
"sysop": {

View file

@ -394,9 +394,16 @@ class UpdateArticle {
$permission_errors = MediaWikiServices::getInstance()->getPermissionManager()->getPermissionErrors( 'edit', $user, $titleX );
if ( count( $permission_errors ) == 0 ) {
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
$services = MediaWikiServices::getInstance();
// MW 1.36+
if ( method_exists( $services, 'getWikiPageFactory' ) ) {
$wikiPageFactory = $services->getWikiPageFactory();
$page = $wikiPageFactory->newFromTitle( $titleX );
}
else {
$page = \WikiPage::factory( $titleX );
}
$updater = $page->newPageUpdater( $user );
$content = $page->getContentHandler()->makeContent( $text, $titleX );
$updater->setContent( SlotRecord::MAIN, $content );

View file

@ -55,9 +55,15 @@ class CreateTemplate extends LoggedUpdateMaintenance {
// Make sure template does not already exist
if ( !$title->exists() ) {
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
$services = MediaWikiServices::getInstance();
// MW 1.36+
if ( method_exists( $services, 'getWikiPageFactory' ) ) {
$wikiPageFactory = $services->getWikiPageFactory();
$page = $wikiPageFactory->newFromTitle( $title );
}
else {
$page = \WikiPage::factory( $title );
}
$updater = $page->newPageUpdater( User::newSystemUser( 'DynamicPageList3 extension' ) );
$content = $page->getContentHandler()->makeContent( '<noinclude>This page was automatically created. It serves as an anchor page for all \'\'\'[[Special:WhatLinksHere/Template:Extension_DPL|invocations]]\'\'\' of [https://www.mediawiki.org/wiki/Special:MyLanguage/Extension:DynamicPageList3 Extension:DynamicPageList3].</noinclude>', $title );
$updater->setContent( SlotRecord::MAIN, $content );