Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore MediaWiki 1.35 compatibility #79

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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