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

Change subject: Get Twig from composer
......................................................................


Get Twig from composer

Bug: T141911
Change-Id: I88d7c6be7d70b15ae9d92ac88a28dd521e3f71dc
---
M SpecialFundraiserUnsubscribe.php
A composer.json
M extension.json
M includes/MediaWikiTwig.php
4 files changed, 14 insertions(+), 21 deletions(-)

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



diff --git a/SpecialFundraiserUnsubscribe.php b/SpecialFundraiserUnsubscribe.php
index 73e0c6a..4905ab1 100644
--- a/SpecialFundraiserUnsubscribe.php
+++ b/SpecialFundraiserUnsubscribe.php
@@ -67,11 +67,7 @@
                global $wgFundraisingEmailUnsubscribeCancelUri;
                global $wgFundraisingEmailUnsubscribeHelpEmail;
 
-               $templateDir = __DIR__ . '/templates';
-
-               if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
-                   include_once( __DIR__ . '/vendor/autoload.php' );
-               }
+           require_once( __DIR__ . '/vendor/autoload.php' );
 
                // Initiate logging. Although we generate the ID every time, we 
will reset to a stashed ID
                // in loadSessionData() if it exists.
@@ -80,7 +76,7 @@
                Logger::setContext( $this->mID );
 
                // Prepare template environment
-               $mwt = new MediaWikiTwig( $wgTwigTemplatePath, 
$this->getContext() );
+               $mwt = new MediaWikiTwig( $templateDir, $this->getContext() );
 
                // Walk through the steps of the process. If we have a 'p' 
parameter we're just starting,
                // If we have data in the session, and the 'execute' parameter, 
we're finishing
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..db0038c
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,11 @@
+{
+       "name": "wikimedia/fundraiser-unsubscribe",
+       "description": "Wikimedia Foundation mailing list unsubscribe frontend",
+       "license": "GPL-2.0",
+       "support": {
+               "irc": "irc://irc.freenode.net/wikimedia-fundraising"
+       },
+       "require": {
+               "twig/twig": "~1.24"
+       }
+}
diff --git a/extension.json b/extension.json
index 5b1c53c..12d8835 100644
--- a/extension.json
+++ b/extension.json
@@ -83,10 +83,8 @@
                                "list-id": "l"
                        }
                },
-               "TwigPath": "/usr/lib/twig/",
                "TwigCachePath": "/tmp/twig",
-               "TwigCacheExpiry": 300,
-               "TwigTemplatePath": "templates"
+               "TwigCacheExpiry": 300
        },
        "manifest_version": 1
 }
diff --git a/includes/MediaWikiTwig.php b/includes/MediaWikiTwig.php
index 0d2c742..8e5bf20 100644
--- a/includes/MediaWikiTwig.php
+++ b/includes/MediaWikiTwig.php
@@ -22,18 +22,6 @@
  * @file
  */
 
-// This is required here so tha the extension code that extends a Twig class 
below doesn't make PHP
-// barf. Not the most graceful thing in the world. But neither is needing Twig 
in the first place.
-global $wgTwigPath;
-if ( !file_exists( $wgTwigPath . '/Autoloader.php' ) ) {
-       throw new MWException(
-               'The FundraiserUnsubscribe extension requires a valid path to 
the Twig Autoloader file.'
-       );
-} else {
-       require_once ( $wgTwigPath . '/Autoloader.php' );
-       Twig_Autoloader::register();
-}
-
 /**
  * Wrapper around the Twig templating engine that allows MW code to easily 
integrate HTML templates.
  * Those templates can also easily call MW templates and code in turn. This is 
not the safest thing

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I88d7c6be7d70b15ae9d92ac88a28dd521e3f71dc
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/FundraisingEmailUnsubscribe
Gerrit-Branch: master
Gerrit-Owner: Awight <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to