jenkins-bot has submitted this change and it was merged.

Change subject: Converted Petition to new extension registration system
......................................................................


Converted Petition to new extension registration system

Moved most of Petition.php to the new extension.json
and added method for backward compatable implementation
of the extension. Moved update function to SpecialPetition.php

Bug: T87958
Change-Id: If85dd702c147a25a301a66fbfb090d5901c0e24f
---
M Petition.php
A PetitionHooks.php
A extension.json
3 files changed, 91 insertions(+), 55 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Petition.php b/Petition.php
index 9cc3640..600c331 100644
--- a/Petition.php
+++ b/Petition.php
@@ -1,56 +1,14 @@
 <?php
-// Petitions
-
-$wgExtensionCredits['other'][] = array(
-       'path'   => __FILE__,
-       'name'   => 'Petition',
-       'author' => array('Peter Coombe', 'Andrew Garrett'),
-       'url'    => 'https://www.mediawiki.org/wiki/Extension:Petition',
-       'descriptionmsg' => 'petition-desc',
-       'license-name' => 'GPL',
-);
-
-$wgResourceModules['ext.Petition'] = array(
-       'localBasePath' => __DIR__,
-       'remoteExtPath' => 'Petition',
-       'scripts'       => 'petition.js',
-       'styles'        => 'petition.css',
-       'dependencies'  => 'mediawiki.ui'
-);
-
-## Petition form
-$wgAutoloadClasses['SpecialPetition'] = __DIR__ . "/SpecialPetition.php";
-$wgSpecialPages['Petition'] = 'SpecialPetition';
-
-## Petition data download page
-$wgAutoloadClasses['SpecialPetitionData'] = __DIR__ . 
"/SpecialPetitionData.php";
-$wgSpecialPages['PetitionData'] = 'SpecialPetitionData';
-
-$wgMessagesDirs['Petition'] = __DIR__ . '/i18n';
-$wgExtensionMessagesFiles['PetitionDataAlias'] = __DIR__ . 
'/Petition.alias.php';
-
-$wgPetitionDatabase = false;
-
-$wgLogTypes[] = 'petition';
-$wgLogActionsHandlers['petition/sign'] = 'LogFormatter';
-
-$wgLogRestrictions['petition'] = 'view-petition-data';
-
-# Schema updates for update.php
-$wgHooks['LoadExtensionSchemaUpdates'][] = function( DatabaseUpdater $updater 
) {
-       $updater->addExtensionTable( 'petition_data', __DIR__ . '/table.sql', 
true );
-       return true;
-};
-
-$wgGroupPermissions['petitiondata']['view-petition-data'] = true;
-$wgAvailableRights[] = 'view-petition-data';
-
-/**
- * Options:
- *
- * $wgPetitionCountCacheTime
- *     time in seconds that the number of signatures count will be cached
- *     in memcached (if available). Default is 86400 i.e. 24 hours
- */
-
-$wgPetitionCountCacheTime = 86400;
+if ( function_exists( 'wfLoadExtension' ) ) {
+       wfLoadExtension( 'Petition' );
+       // Keep i18n globals so mergeMessageFileList.php doesn't break
+       $wgMessagesDirs['Petition'] = __DIR__ . '/i18n';
+       $wgExtensionMessagesFiles['PetitionAlias'] = __DIR__ . 
'/Petition.alias.php';
+       /*wfWarn(
+               'Deprecated PHP entry point used for Petition extension. Please 
use wfLoadExtension instead, ' .
+               'see https://www.mediawiki.org/wiki/Extension_registration for 
more details.'
+       );*/
+       return;
+} else {
+       die( 'This version of the Petition extension requires MediaWiki 1.25+' 
);
+}
\ No newline at end of file
diff --git a/PetitionHooks.php b/PetitionHooks.php
new file mode 100644
index 0000000..3510e57
--- /dev/null
+++ b/PetitionHooks.php
@@ -0,0 +1,12 @@
+<?php
+
+class PetitionHooks {
+
+       /**
+        * Adds database table to updater
+        */
+       public static function getUpdates( DatabaseUpdater $updater ) {
+               $updater->addExtensionTable( 'petition_data', __DIR__ . 
'/table.sql', true );
+               return true;
+       }
+}
\ No newline at end of file
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..f80392b
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,66 @@
+{
+       "name": "Petition",
+       "author": [
+               "Peter Coombe",
+               "Andrew Garrett"
+       ],
+       "url": "https://www.mediawiki.org/wiki/Extension:Petition";,
+       "descriptionmsg": "petition-desc",
+       "license-name": "GPL",
+       "type": "other",
+       "GroupPermissions": {
+               "petitiondata": {
+                       "view-petition-data": true
+               }
+       },
+       "AvailableRights": [
+               "view-petition-data"
+       ],
+       "SpecialPages": {
+               "Petition": "SpecialPetition",
+               "PetitionData": "SpecialPetitionData"
+       },
+       "LogTypes": [
+               "petition"
+       ],
+       "LogRestrictions": {
+               "petition": "view-petition-data"
+       },
+       "LogActionsHandlers": {
+               "petition/sign": "LogFormatter"
+       },
+       "MessagesDirs": {
+               "Petition": [
+                       "i18n"
+               ]
+       },
+       "ExtensionMessagesFiles": {
+               "PetitionDataAlias": "Petition.alias.php"
+       },
+       "AutoloadClasses": {
+               "SpecialPetition": "SpecialPetition.php",
+               "SpecialPetitionData": "SpecialPetitionData.php",
+               "PetitionHooks": "PetitionHooks.php"
+       },
+       "ResourceModules": {
+               "ext.Petition": {
+                       "scripts": "petition.js",
+                       "styles": "petition.css",
+                       "dependencies": "mediawiki.ui"
+               }
+       },
+       "ResourceFileModulePaths": {
+               "localBasePath": "",
+               "remoteExtPath": "Petition"
+       },
+       "Hooks": {
+               "LoadExtensionSchemaUpdates": [
+                       "PetitionHooks::getUpdates"
+               ]
+       },
+       "config": {
+               "PetitionDatabase": false,
+               "PetitionCountCacheTime": 86400
+       },
+       "manifest_version": 1
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/258686
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If85dd702c147a25a301a66fbfb090d5901c0e24f
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/Petition
Gerrit-Branch: master
Gerrit-Owner: Mhutti1 <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Mhutti1 <[email protected]>
Gerrit-Reviewer: Paladox <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to