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

Change subject: Simplify entry point
......................................................................


Simplify entry point

Change-Id: I7a79957347ef2cf2189cc51ef165b26035f5ecdb
---
M Diff.mw.php
M Diff.php
D Diff.standalone.php
3 files changed, 22 insertions(+), 60 deletions(-)

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



diff --git a/Diff.mw.php b/Diff.mw.php
index 90ed926..a4dff18 100644
--- a/Diff.mw.php
+++ b/Diff.mw.php
@@ -23,13 +23,6 @@
 
 $wgExtensionMessagesFiles['DiffExtension'] = __DIR__ . '/Diff.i18n.php';
 
-// Autoloading
-foreach ( include( __DIR__ . '/Diff.classes.php' ) as $class => $file ) {
-       if ( !array_key_exists( $class, $GLOBALS['wgAutoloadLocalClasses'] ) ) {
-               $wgAutoloadClasses[$class] = __DIR__ . '/' . $file;
-       }
-}
-
 /**
  * Hook to add PHPUnit test cases.
  * @see https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList
diff --git a/Diff.php b/Diff.php
index 33d4534..024510c 100644
--- a/Diff.php
+++ b/Diff.php
@@ -1,20 +1,6 @@
 <?php
 
 /**
- * Initialization file for the Diff extension.
- *
- * Documentation:                      
https://www.mediawiki.org/wiki/Extension:Diff
- * Support                                     
https://www.mediawiki.org/wiki/Extension_talk:Diff
- * Source code:                                
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/Diff.git
- *
- * @file
- * @ingroup Diff
- *
- * @licence GNU GPL v2+
- * @author Jeroen De Dauw < jeroended...@gmail.com >
- */
-
-/**
  * This documentation group collects source code files belonging to Diff.
  *
  * @defgroup Diff Diff
@@ -28,11 +14,29 @@
  * @ingroup Test
  */
 
+if ( defined( 'Diff_VERSION' ) ) {
+       // Do not initialize more then once.
+       return;
+}
+
 define( 'Diff_VERSION', '0.8 alpha' );
 
 // @codeCoverageIgnoreStart
-call_user_func( function() {
-       $extension = defined( 'MEDIAWIKI' ) ? 'mw' : 'standalone';
-       require_once __DIR__ . '/Diff.' . $extension . '.php';
+spl_autoload_register( function ( $className ) {
+       static $classes = false;
+
+       if ( $classes === false ) {
+               $classes = include( __DIR__ . '/' . 'Diff.classes.php' );
+       }
+
+       if ( array_key_exists( $className, $classes ) ) {
+               include_once __DIR__ . '/' . $classes[$className];
+       }
 } );
-// @codeCoverageIgnoreEnd
+
+if ( defined( 'MEDIAWIKI' ) ) {
+       call_user_func( function() {
+               require_once __DIR__ . '/Diff.mw.php';
+       } );
+}
+// @codeCoverageIgnoreEnd
\ No newline at end of file
diff --git a/Diff.standalone.php b/Diff.standalone.php
deleted file mode 100644
index d816255..0000000
--- a/Diff.standalone.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
-/**
- * Standalone setup for the diff library.
- * The library should be included via the main entry point, Diff.php.
- *
- * Documentation:                      
https://www.mediawiki.org/wiki/Extension:Diff
- * Support                                     
https://www.mediawiki.org/wiki/Extension_talk:Diff
- * Source code:                                
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/Diff.git
- *
- * @file
- * @ingroup Diff
- *
- * @licence GNU GPL v2+
- * @author Jeroen De Dauw < jeroended...@gmail.com >
- */
-
-if ( !defined( 'Diff_VERSION' ) ) {
-       die( 'Not an entry point for MediaWiki. Use Diff.php' );
-}
-
-// @codeCoverageIgnoreStart
-spl_autoload_register( function ( $className ) {
-       static $classes = false;
-
-       if ( $classes === false ) {
-               $classes = include( __DIR__ . '/' . 'Diff.classes.php' );
-       }
-
-       if ( array_key_exists( $className, $classes ) ) {
-               include_once __DIR__ . '/' . $classes[$className];
-       }
-} );
-// @codeCoverageIgnoreEnd
-

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7a79957347ef2cf2189cc51ef165b26035f5ecdb
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Diff
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Daniel Werner <daniel.wer...@wikimedia.de>
Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to