jenkins-bot has submitted this change and it was merged.
Change subject: Updated extension registration to new system
......................................................................
Updated extension registration to new system
Added extension.json file and added shim to main entry point.
Bug: T87903
Change-Id: Ib2f1c5f93b243ec79e25b580b3ba933a22d796ea
---
A ContributionTracking.hooks.php
M ContributionTracking.php
A extension.json
3 files changed, 161 insertions(+), 70 deletions(-)
Approvals:
Awight: Checked; Looks good to me, approved
jenkins-bot: Verified
diff --git a/ContributionTracking.hooks.php b/ContributionTracking.hooks.php
new file mode 100644
index 0000000..f90a28e
--- /dev/null
+++ b/ContributionTracking.hooks.php
@@ -0,0 +1,73 @@
+<?php
+
+class ContributionTrackingHooks {
+ public static function extensionFunction() {
+ global $wgDBserver, $wgDBname, $wgDBuser, $wgDBpassword,
+ $wgContributionTrackingDBserver,
$wgContributionTrackingDBname,
+ $wgContributionTrackingDBuser,
$wgContributionTrackingDBpassword;
+
+ $wgContributionTrackingDBserver =
$wgContributionTrackingDBserver ?: $wgDBserver;
+ $wgContributionTrackingDBname = $wgContributionTrackingDBname
?: $wgDBname;
+ $wgContributionTrackingDBuser = $wgContributionTrackingDBuser
?: $wgDBuser;
+ $wgContributionTrackingDBpassword =
$wgContributionTrackingDBpassword ?: $wgDBpassword;
+ }
+
+ public static function onLoadExtensionSchemaUpdates( DatabaseUpdater
$updater ) {
+ $dir = __DIR__ . '/';
+ if ( $updater === null ) {
+ global $wgExtNewTables, $wgExtNewFields;
+
+ $wgExtNewTables[] = array( 'contribution_tracking',
$dir . 'ContributionTracking.sql' );
+ $wgExtNewTables[] = array(
'contribution_tracking_owa_ref', $dir . 'ContributionTracking_OWA_ref.sql' );
+
+ $wgExtNewFields[] = array(
+ 'contribution_tracking',
+ 'owa_session',
+ $dir . 'patch-owa.sql',
+ );
+ } else {
+ global $wgContributionTrackingDBname;
+
+ if( $updater->getDB()->getDBname() ===
$wgContributionTrackingDBname ) {
+ $updater->addExtensionTable(
'contribution_tracking', $dir . 'ContributionTracking.sql' );
+ $updater->addExtensionTable(
'contribution_tracking_owa_ref', $dir . 'ContributionTracking_OWA_ref.sql' );
+ $updater->addExtensionUpdate( array(
'addField', 'contribution_tracking', 'owa_session',
+ $dir . 'patches/patch-owa.sql', true )
);
+ $updater->addExtensionUpdate( array(
'addField', 'contribution_tracking', 'utm_key',
+ $dir . 'patches/patch-owa.sql', true )
);
+
+ if ( $updater->getDB()->getType() !== 'sqlite'
) {
+ // Not sure how to do this in the other
configurations, but I guess
+ // "manually" might be the answer.
+ $updater->addExtensionUpdate( array(
'modifyField', 'contribution_tracking', 'anonymous',
+ $dir .
'patches/make-null.patch.sql', true ) );
+ }
+ if ( $updater->getDB()->getType() !==
'postgres' ) {
+ $updater->addExtensionUpdate( array(
'addTable', 'contribution_tracking',
+ $dir .
'ContributionTracking.pg.sql', true ) );
+ }
+ } else { //We are configured not to use the main
mediawiki db.
+ //Unless the updater is modified not to run
+ //'LoadExtensionSchemaUpdates' hooks in its
constructor (or do so
+ //conditionally), we're going to have to do
these manually.
+ $ctDB =
ContributionTrackingProcessor::contributionTrackingConnection();
+ if ( !$ctDB->tableExists(
'contribution_tracking' ) ){
+ $ctDB->sourceFile( $dir .
'ContributionTracking.sql' );
+ }
+ if ( !$ctDB->tableExists(
'contribution_tracking_owa_ref' ) ){
+ $ctDB->sourceFile( $dir .
'ContributionTracking_OWA_ref.sql' );
+ }
+ if ( !$ctDB->fieldExists(
'contribution_tracking', 'owa_session' ) ){
+ $ctDB->sourceFile( $dir .
'patches/patch-owa.sql' );
+ }
+ if ( !$ctDB->fieldExists(
'contribution_tracking', 'utm_key' ) ){
+ $ctDB->sourceFile( $dir .
'patches/patch-utm_key.sql' );
+ }
+ if ( !$ctDB->fieldExists(
'contribution_tracking', 'country' ) ){
+ $ctDB->sourceFile( $dir .
'patches/20120924.new_columns.sql' );
+ }
+ }
+ }
+ return true;
+ }
+}
diff --git a/ContributionTracking.php b/ContributionTracking.php
index 4d420d5..106b644 100644
--- a/ContributionTracking.php
+++ b/ContributionTracking.php
@@ -1,13 +1,19 @@
<?php
-
-# Alert the user that this is not a valid entry point to MediaWiki if they try
to access the special pages file directly.
-if ( !defined( 'MEDIAWIKI' ) ) {
- echo <<<EOT
-To install my extension, put the following line in LocalSettings.php:
-require_once( "\$IP/extensions/ContributionTracking/ContributionTracking.php"
);
-EOT;
- exit( 1 );
+if ( function_exists( 'wfLoadExtension' ) ) {
+ wfLoadExtension( 'ContributionTracking' );
+ // Keep i18n globals so mergeMessageFileList.php doesn't break
+ $wgMessagesDirs['ContributionTracking'] = __DIR__ . '/i18n';
+ $wgExtensionMessagesFiles['ContributionTracking'] = __DIR__ .
'/ContributionTracking.alias.php';
+ /* wfWarn(
+ 'Deprecated PHP entry point used for ContributionTracking
extension. Please use wfLoadExtension instead, ' .
+ 'see https://www.mediawiki.org/wiki/Extension_registration for
more details.'
+ ); */
+ return;
}
+
+/**
+ * Setup for pre-1.25 wikis. Make sure this is kept in sync with extension.json
+ */
$wgExtensionCredits['specialpage'][] = array(
'path' => __FILE__,
@@ -21,6 +27,7 @@
$wgMessagesDirs['ContributionTracking'] = __DIR__ . '/i18n';
$wgExtensionMessagesFiles['ContributionTrackingAlias'] = $dir .
'ContributionTracking.alias.php';
+$wgAutoloadClasses['ContributionTrackingHooks'] = $dir .
'ContributionTracking.hooks.php';
$wgAutoloadClasses['ContributionTracking'] = $dir .
'ContributionTracking_body.php';
$wgSpecialPages['ContributionTracking'] = 'ContributionTracking';
@@ -38,7 +45,7 @@
$wgAutoloadClasses['ContributionTrackingProcessor'] = $dir .
'ContributionTracking.processor.php';
//this only works if contribution tracking is inside a mediawiki DB, which
typically it isn't.
-$wgHooks['LoadExtensionSchemaUpdates'][] = 'efContributionTrackingLoadUpdates';
+$wgHooks['LoadExtensionSchemaUpdates'][] =
'ContributionTrackingHooks::onLoadExtensionSchemaUpdates';
// Resource modules
$ctResourceTemplate = array(
@@ -100,64 +107,3 @@
// api modules
$wgAPIModules['contributiontracking'] = 'ApiContributionTracking';
-
-/**
- * @param $updater DatabaseUpdater
- * @return bool
- */
-function efContributionTrackingLoadUpdates( $updater = null ){
-
- $dir = dirname( __FILE__ ) . '/';
- if ( $updater === null ) {
- global $wgExtNewTables, $wgExtNewFields;
-
- $wgExtNewTables[] = array( 'contribution_tracking', $dir .
'ContributionTracking.sql' );
- $wgExtNewTables[] = array( 'contribution_tracking_owa_ref',
$dir . 'ContributionTracking_OWA_ref.sql' );
-
- $wgExtNewFields[] = array(
- 'contribution_tracking',
- 'owa_session',
- $dir . 'patch-owa.sql',
- );
- } else {
- global $wgContributionTrackingDBname;
-
- if( $updater->getDB()->getDBname() ===
$wgContributionTrackingDBname ) {
- $updater->addExtensionTable( 'contribution_tracking',
$dir . 'ContributionTracking.sql' );
- $updater->addExtensionTable(
'contribution_tracking_owa_ref', $dir . 'ContributionTracking_OWA_ref.sql' );
- $updater->addExtensionUpdate( array( 'addField',
'contribution_tracking', 'owa_session',
- $dir . 'patches/patch-owa.sql', true ) );
- $updater->addExtensionUpdate( array( 'addField',
'contribution_tracking', 'utm_key',
- $dir . 'patches/patch-owa.sql', true ) );
-
- if ( $updater->getDB()->getType() !== 'sqlite' ) {
- // Not sure how to do this in the other
configurations, but I guess
- // "manually" might be the answer.
- $updater->addExtensionUpdate( array(
'modifyField', 'contribution_tracking', 'anonymous',
- $dir . 'patches/make-null.patch.sql',
true ) );
- }
- } else { //We are configured not to use the main mediawiki db.
- //Unless the updater is modified not to run
- //'LoadExtensionSchemaUpdates' hooks in its constructor
(or do so
- //conditionally), we're going to have to do these
manually.
- $ctDB =
ContributionTrackingProcessor::contributionTrackingConnection();
- if ( !$ctDB->tableExists( 'contribution_tracking' ) ){
- $ctDB->sourceFile( $dir .
'ContributionTracking.sql' );
- }
- if ( !$ctDB->tableExists(
'contribution_tracking_owa_ref' ) ){
- $ctDB->sourceFile( $dir .
'ContributionTracking_OWA_ref.sql' );
- }
- if ( !$ctDB->fieldExists( 'contribution_tracking',
'owa_session' ) ){
- $ctDB->sourceFile( $dir .
'patches/patch-owa.sql' );
- }
- if ( !$ctDB->fieldExists( 'contribution_tracking',
'utm_key' ) ){
- $ctDB->sourceFile( $dir .
'patches/patch-utm_key.sql' );
- }
- if ( !$ctDB->fieldExists( 'contribution_tracking',
'country' ) ){
- $ctDB->sourceFile( $dir .
'patches/20120924.new_columns.sql' );
- }
- }
- }
- return true;
-
-}
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..e909c4f
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,72 @@
+{
+ "name": "ContributionTracking",
+ "author": "David Strauss",
+ "url": "https://www.mediawiki.org/wiki/Extension:ContributionTracking",
+ "descriptionmsg": "contributiontracking-desc",
+ "type": "specialpage",
+ "APIModules": {
+ "contributiontracking": "ApiContributionTracking"
+ },
+ "AutoloadClasses": {
+ "ContributionTracking": "ContributionTracking_body.php",
+ "ContributionTrackingHooks": "ContributionTracking.hooks.php",
+ "ContributionTrackingTester": "ContributionTracking_Tester.php",
+ "SpecialFundraiserMaintenance":
"special/SpecialFundraiserMaintenance.php",
+ "ApiContributionTracking": "ApiContributionTracking.php",
+ "ContributionTrackingProcessor":
"ContributionTracking.processor.php"
+ },
+ "AvailableRights": [
+ "ViewContributionTrackingTester"
+ ],
+ "config": {
+ "ContributionTrackingFundraiserMaintenance": false,
+ "ContributionTrackingFundraiserMaintenanceUnsched": false,
+ "ContributionTrackingPayPalBusiness": "[email protected]",
+ "ContributionTrackingPayPalIPN":
"https://civicrm.wikimedia.org/fundcore_gateway/paypal",
+ "ContributionTrackingPayPalRecurringIPN":
"https://civicrm.wikimedia.org/fundcore_gateway/paypal",
+ "ContributionTrackingRPPLength": "0",
+ "ContributionTrackingReturnToURLDefault":
"http://wikimediafoundation.org/wiki/Thank_You"
+ },
+ "ExtensionFunctions": [
+ "ContributionTrackingHooks::extensionFunction"
+ ],
+ "ExtensionMessagesFiles": {
+ "ContributionTrackingAlias": "ContributionTracking.alias.php"
+ },
+ "GroupPermissions": {
+ "sysop": {
+ "ViewContributionTrackingTester": true
+ }
+ },
+ "Hooks": {
+ "LoadExtensionSchemaUpdates": [
+
"ContributionTrackingHooks::onLoadExtensionSchemaUpdates"
+ ]
+ },
+ "MessagesDirs": {
+ "ContributionTracking": [
+ "i18n"
+ ]
+ },
+ "ResourceModules": {
+ "jquery.contributionTracking": {
+ "scripts": "jquery.contributionTracking.js"
+ },
+ "contributionTracking.fundraiserMaintenance": {
+ "styles": [
+ "skinOverride.css"
+ ],
+ "scripts": [],
+ "position": "top"
+ }
+ },
+ "ResourceFileModulePaths": {
+ "localBasePath": "modules",
+ "remoteExtPath": "ContributionTracking/modules"
+ },
+ "SpecialPages": {
+ "ContributionTracking": "ContributionTracking",
+ "ContributionTrackingTester": "ContributionTrackingTester",
+ "FundraiserMaintenance": "SpecialFundraiserMaintenance"
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/213315
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib2f1c5f93b243ec79e25b580b3ba933a22d796ea
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/ContributionTracking
Gerrit-Branch: master
Gerrit-Owner: Parent5446 <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Paladox <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits