Arlolra has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/188411

Change subject: Convert Parsoid extension to use extension registration
......................................................................

Convert Parsoid extension to use extension registration

 * Removes the setup class to get convertExtensionToRegistration.php to
   run.

 * extension.json validates

 * Using $GLOBALS['wgDBname'] for "Notice: Undefined variable: wgDBname"

 * Adds Marc and Arlo to the credits.

Bug: T87956
Change-Id: I4ed79f23f408afdbff89fc8d4b7e90bec1de6ffd
---
M Parsoid.php
A extension.json
2 files changed, 165 insertions(+), 131 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid 
refs/changes/11/188411/1

diff --git a/Parsoid.php b/Parsoid.php
index 768502a..bed9651 100644
--- a/Parsoid.php
+++ b/Parsoid.php
@@ -1,145 +1,104 @@
 <?php
 
-/**
- * Basic cache invalidation for Parsoid
- */
+// Needs to be called within MediaWiki; not standalone
 if ( !defined( 'MEDIAWIKI' ) ) {
-       echo "Parsoid extension\n";
-       exit( 1 );
+       echo "Parsoid extension.\n";
+       die( -1 );
 }
+
+$wgExtensionCredits['other'][] = array(
+       'path' => __FILE__,
+       'name' => 'Parsoid',
+       'author' => array(
+               'Gabriel Wicke',
+               'Subramanya Sastry',
+               'Mark Holmquist',
+               'Adam Wight',
+               'C. Scott Ananian',
+               'Marc Ordinas i Llopis',
+               'Arlo Breault',
+       ),
+       'version' => '0.2.0',
+       'url' => 'https://www.mediawiki.org/wiki/Extension:Parsoid',
+       'descriptionmsg' => 'parsoid-desc',
+       'license-name' => 'GPL-2.0+',
+);
+
+$dir = __DIR__;
+
+# Set up class autoloading
+$wgAutoloadClasses['ParsoidHooks'] = "$dir/Parsoid.hooks.php";
+$wgAutoloadClasses['ParsoidCacheUpdateJob'] = "$dir/ParsoidCacheUpdateJob.php";
+$wgAutoloadClasses['CurlMultiClient'] = "$dir/CurlMultiClient.php";
+
+# Add the parsoid job types
+$wgJobClasses['ParsoidCacheUpdateJobOnEdit'] = 'ParsoidCacheUpdateJob';
+$wgJobClasses['ParsoidCacheUpdateJobOnDependencyChange'] = 
'ParsoidCacheUpdateJob';
+# Old type for transition
+# @TODO: remove when old jobs are drained
+$wgJobClasses['ParsoidCacheUpdateJob'] = 'ParsoidCacheUpdateJob';
+
+# Register localizations.
+$wgMessagesDirs['Parsoid'] = $dir . '/i18n';
+$wgExtensionMessagesFiles['Parsoid'] = $dir . '/Parsoid.i18n.php';
+
+# Name modules
+$wgResourceModules += array(
+       'ext.parsoid.styles' => array(
+               'localBasePath' => $dir . '/modules',
+               'remoteExtPath' => 'Parsoid/modules',
+               'styles' => 'parsoid.styles.css',
+               'targets' => array( 'desktop', 'mobile' ),
+       ),
+);
+
+
+// Set up default config values. Override after requiring the extension.
 
 /**
- * Class containing basic setup functions.
+ * An array of Varnish caches in front of Parsoid to keep up to date.
+ *
+ * Formats:
+ * 'http://localhost'
+ * 'http://localhost:80'
+ * 'https://127.0.0.1:8080'
  */
-class ParsoidSetup {
-       /**
-        * Set up Parsoid.
-        *
-        * @return void
-        */
-       public static function setup() {
-               global $wgAutoloadClasses, $wgJobClasses,
-                       $wgExtensionCredits, $wgExtensionMessagesFiles, 
$wgMessagesDirs,
-                       $wgResourceModules;
+$wgParsoidCacheServers = array( 'http://localhost' );
 
-               $dir = __DIR__;
+/**
+ * The wiki prefix sent to Parsoid. You can add these with
+ * parsoidConfig.setInterwiki in the Parsoid localsettings.js.
+ */
+$wgParsoidWikiPrefix = $GLOBALS['wgDBname'];
 
-               # Set up class autoloading
-               $wgAutoloadClasses['ParsoidHooks'] = "$dir/Parsoid.hooks.php";
-               $wgAutoloadClasses['ParsoidCacheUpdateJob'] = 
"$dir/ParsoidCacheUpdateJob.php";
-               $wgAutoloadClasses['CurlMultiClient'] = 
"$dir/CurlMultiClient.php";
+/**
+ * The maximum number of backlinks (templates and files) to update.
+ */
+$wgParsoidMaxBacklinksInvalidate = false;
 
-               # Add the parsoid job types
-               $wgJobClasses['ParsoidCacheUpdateJobOnEdit'] = 
'ParsoidCacheUpdateJob';
-               $wgJobClasses['ParsoidCacheUpdateJobOnDependencyChange'] = 
'ParsoidCacheUpdateJob';
-               # Old type for transition
-               # @TODO: remove when old jobs are drained
-               $wgJobClasses['ParsoidCacheUpdateJob'] = 
'ParsoidCacheUpdateJob';
+/**
+ * The maximum number of titles to process in a single
+ * ParsoidCacheUpdateJob
+ */
+$wgParsoidCacheUpdateTitlesPerJob = 50;
 
-               $wgExtensionCredits['other'][] = array(
-                       'path' => __FILE__,
-                       'name' => 'Parsoid',
-                       'author' => array(
-                               'Gabriel Wicke',
-                               'Subramanya Sastry',
-                               'Mark Holmquist',
-                               'Adam Wight',
-                               'C. Scott Ananian'
-                       ),
-                       'version' => '0.2.0',
-                       'url' => 
'https://www.mediawiki.org/wiki/Extension:Parsoid',
-                       'descriptionmsg' => 'parsoid-desc',
-                       'license-name' => 'GPL-2.0+',
-               );
-
-               # Register localizations.
-               $wgMessagesDirs['Parsoid'] = __DIR__ . '/i18n';
-               $wgExtensionMessagesFiles['Parsoid'] = $dir . 
'/Parsoid.i18n.php';
-
-               # Name modules
-               $wgResourceModules += array(
-                       'ext.parsoid.styles' => array(
-                               'localBasePath' => __DIR__ . '/modules',
-                               'remoteExtPath' => 'Parsoid/modules',
-                               'styles' => 'parsoid.styles.css',
-                               'targets' => array( 'desktop', 'mobile' ),
-                       ),
-               );
-
-               # Set up a default configuration
-               self::setupDefaultConfig();
-
-               # Now register our hooks.
-               self::registerHooks();
-       }
+/**
+ * The portion of update requests to skip for basic load shedding. A
+ * float between 0 (none are skipped) and 1 (all are skipped).
+ */
+$wgParsoidSkipRatio = 0.0;
 
 
-       /**
-        * Set up default config values. Override after requiring the extension.
-        *
-        * @return void
-        */
-       protected static function setupDefaultConfig() {
-               global $wgParsoidCacheServers, $wgParsoidSkipRatio, $wgDBname,
-                       $wgParsoidCacheUpdateTitlesPerJob, 
$wgParsoidMaxBacklinksInvalidate,
-                       $wgParsoidWikiPrefix;
+// Register Hooks
 
-               /**
-                * An array of Varnish caches in front of Parsoid to keep up to 
date.
-                *
-                * Formats:
-                * 'http://localhost'
-                * 'http://localhost:80'
-                * 'https://127.0.0.1:8080'
-                */
-               $wgParsoidCacheServers = array( 'http://localhost' );
-
-               /**
-                * The wiki prefix sent to Parsoid. You can add these with
-                * parsoidConfig.setInterwiki in the Parsoid localsettings.js.
-                */
-               $wgParsoidWikiPrefix = $wgDBname;
-
-               /**
-                * The maximum number of backlinks (templates and files) to 
update.
-                */
-               $wgParsoidMaxBacklinksInvalidate = false;
-
-               /**
-                * The maximum number of titles to process in a single
-                * ParsoidCacheUpdateJob
-                */
-               $wgParsoidCacheUpdateTitlesPerJob = 50;
-
-               /**
-                * The portion of update requests to skip for basic load 
shedding. A
-                * float between 0 (none are skipped) and 1 (all are skipped).
-                */
-               $wgParsoidSkipRatio = 0.0;
-       }
-
-
-       /**
-        * Register hook handlers.
-        *
-        * @return void
-        */
-       protected static function registerHooks() {
-               global $wgHooks;
-
-               # Article edit/create
-               $wgHooks['ArticleEditUpdates'][] = 
'ParsoidHooks::onArticleEditUpdates';
-               # Article delete/restore
-               $wgHooks['ArticleDeleteComplete'][] = 
'ParsoidHooks::onArticleDeleteComplete';
-               $wgHooks['ArticleUndelete'][] = 
'ParsoidHooks::onArticleUndelete';
-               # Revision delete/restore
-               $wgHooks['ArticleRevisionVisibilitySet'][] = 
'ParsoidHooks::onArticleRevisionVisibilitySet';
-               # Article move
-               $wgHooks['TitleMoveComplete'][] = 
'ParsoidHooks::onTitleMoveComplete';
-               # File upload
-               $wgHooks['FileUpload'][] = 'ParsoidHooks::onFileUpload';
-       }
-}
-
-# Load hooks that are always set
-ParsoidSetup::setup();
+# Article edit/create
+$wgHooks['ArticleEditUpdates'][] = 'ParsoidHooks::onArticleEditUpdates';
+# Article delete/restore
+$wgHooks['ArticleDeleteComplete'][] = 'ParsoidHooks::onArticleDeleteComplete';
+$wgHooks['ArticleUndelete'][] = 'ParsoidHooks::onArticleUndelete';
+# Revision delete/restore
+$wgHooks['ArticleRevisionVisibilitySet'][] = 
'ParsoidHooks::onArticleRevisionVisibilitySet';
+# Article move
+$wgHooks['TitleMoveComplete'][] = 'ParsoidHooks::onTitleMoveComplete';
+# File upload
+$wgHooks['FileUpload'][] = 'ParsoidHooks::onFileUpload';
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..d20cdf8
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,75 @@
+{
+       "name": "Parsoid",
+       "version": "0.2.0",
+       "author": [
+               "Gabriel Wicke",
+               "Subramanya Sastry",
+               "Mark Holmquist",
+               "Adam Wight",
+               "C. Scott Ananian",
+               "Marc Ordinas i Llopis",
+               "Arlo Breault"
+       ],
+       "url": "https://www.mediawiki.org/wiki/Extension:Parsoid";,
+       "descriptionmsg": "parsoid-desc",
+       "license-name": "GPL-2.0+",
+       "type": "other",
+       "JobClasses": {
+               "ParsoidCacheUpdateJobOnEdit": "ParsoidCacheUpdateJob",
+               "ParsoidCacheUpdateJobOnDependencyChange": 
"ParsoidCacheUpdateJob",
+               "ParsoidCacheUpdateJob": "ParsoidCacheUpdateJob"
+       },
+       "MessagesDirs": {
+               "Parsoid": [
+                       "i18n"
+               ]
+       },
+       "ExtensionMessagesFiles": {
+               "Parsoid": "Parsoid.i18n.php"
+       },
+       "AutoloadClasses": {
+               "ParsoidHooks": "Parsoid.hooks.php",
+               "ParsoidCacheUpdateJob": "ParsoidCacheUpdateJob.php",
+               "CurlMultiClient": "CurlMultiClient.php"
+       },
+       "ResourceModules": {
+               "ext.parsoid.styles": {
+                       "localBasePath": "modules",
+                       "remoteExtPath": "Parsoid/modules",
+                       "styles": "parsoid.styles.css",
+                       "targets": [
+                               "desktop",
+                               "mobile"
+                       ]
+               }
+       },
+       "Hooks": {
+               "ArticleEditUpdates": [
+                       "ParsoidHooks::onArticleEditUpdates"
+               ],
+               "ArticleDeleteComplete": [
+                       "ParsoidHooks::onArticleDeleteComplete"
+               ],
+               "ArticleUndelete": [
+                       "ParsoidHooks::onArticleUndelete"
+               ],
+               "ArticleRevisionVisibilitySet": [
+                       "ParsoidHooks::onArticleRevisionVisibilitySet"
+               ],
+               "TitleMoveComplete": [
+                       "ParsoidHooks::onTitleMoveComplete"
+               ],
+               "FileUpload": [
+                       "ParsoidHooks::onFileUpload"
+               ]
+       },
+       "config": {
+               "ParsoidCacheServers": [
+                       "http://localhost";
+               ],
+               "ParsoidWikiPrefix": "wikidb",
+               "ParsoidMaxBacklinksInvalidate": false,
+               "ParsoidCacheUpdateTitlesPerJob": 50,
+               "ParsoidSkipRatio": 0
+       }
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4ed79f23f408afdbff89fc8d4b7e90bec1de6ffd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>

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

Reply via email to