aboutsummaryrefslogtreecommitdiffstats
path: root/thumb_handler.php
diff options
context:
space:
mode:
authordaniel <dkinzler@wikimedia.org>2023-10-27 17:21:45 +0200
committerdaniel <dkinzler@wikimedia.org>2024-03-30 21:14:05 +0100
commit9638fa314a0089a32c366deddb42ea046932d50a (patch)
tree3de6a136d4ddd14a8e0f670e61f7cb1353f502e0 /thumb_handler.php
parent5c87a85f236a500d7a9e92b92775b568eec8c16d (diff)
downloadmediawikicore-9638fa314a0089a32c366deddb42ea046932d50a.tar.gz
mediawikicore-9638fa314a0089a32c366deddb42ea046932d50a.zip
Introduce entry point classes for media files.
This moves a code out of file scope into classes to make it testable. The code is left in the same structure as it was before, global functions have been converted into methods on the new ThumbnailEntryPoint and Thumbnail404EntryPoint classes. This test introduces comprehensive phpunit tests covering all functional code paths in ThumbnailEntryPoint. This is intended to support refactoring of this code. Change-Id: I459abc7b11d0ab4ee682a863c9525a945048296f
Diffstat (limited to 'thumb_handler.php')
-rw-r--r--thumb_handler.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/thumb_handler.php b/thumb_handler.php
index 2ae895645f29..d947f86430bb 100644
--- a/thumb_handler.php
+++ b/thumb_handler.php
@@ -8,6 +8,8 @@
* if it was a request to thumb.php with the relevant query parameters filled
* out. See also $wgGenerateThumbnailOnParse.
*
+ * @see thumb.php
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -28,9 +30,17 @@
* @ingroup Media
*/
-define( 'THUMB_HANDLER', true );
+use MediaWiki\EntryPointEnvironment;
+use MediaWiki\FileRepo\Thumbnail404EntryPoint;
+use MediaWiki\MediaWikiServices;
+
+define( 'MW_NO_OUTPUT_COMPRESSION', 1 );
define( 'MW_ENTRY_POINT', 'thumb_handler' );
-// Execute thumb.php, having set THUMB_HANDLER so that
-// it knows to extract params from a thumbnail file URL.
-require __DIR__ . '/thumb.php';
+require __DIR__ . '/includes/WebStart.php';
+
+( new Thumbnail404EntryPoint(
+ RequestContext::getMain(),
+ new EntryPointEnvironment(),
+ MediaWikiServices::getInstance()
+) )->run();