Skip to content

Commit

Permalink
Restore MediaWiki 1.35 compatibility (Universal-Omega#79)
Browse files Browse the repository at this point in the history
Co-authored-by: rvogel <vogel@hallowelt.biz>
  • Loading branch information
osnard and rvogel authored Jan 28, 2022
1 parent db51e49 commit f20ad2e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions extension.json
Original file line number Diff line number Diff line change
@@ -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]",
Expand All @@ -11,7 +11,7 @@
"license-name": "GPL-3.0-or-later",
"type": "parserhook",
"requires": {
"MediaWiki": ">= 1.36.0"
"MediaWiki": ">= 1.35.0"
},
"GroupPermissions": {
"sysop": {
Expand Down
11 changes: 9 additions & 2 deletions includes/UpdateArticle.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,16 @@ private static function doUpdateArticle( $title, $text, $summary ) {
$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 );
}

$page = $wikiPageFactory->newFromTitle( $titleX );
$updater = $page->newPageUpdater( $user );
$content = $page->getContentHandler()->makeContent( $text, $titleX );
$updater->setContent( SlotRecord::MAIN, $content );
Expand Down
12 changes: 9 additions & 3 deletions maintenance/createTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,15 @@ protected function doDBUpdates() {

// Make sure template does not already exist
if ( !$title->exists() ) {
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();

$page = $wikiPageFactory->newFromTitle( $title );
$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 );
Expand Down

0 comments on commit f20ad2e

Please sign in to comment.