aboutsummaryrefslogtreecommitdiffstats
path: root/thumb.php
Commit message (Collapse)AuthorAgeFilesLines
* Use namespaced classes (1)Umherirrender2024-06-161-0/+1
| | | | | | | Changes to the use statements done automatically via script Addition of missing use statement done manually Change-Id: Ic4d4dd61de5ab896fb6173eb579c81f164a1e4a3
* Introduce entry point classes for media files.daniel2024-03-301-694/+11
| | | | | | | | | | | | | 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
* Namespace includes/contextJames D. Forrester2024-02-081-0/+1
| | | | | Bug: T353458 Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
* Replace more instances of unchecked MWExceptionDaimona Eaytoy2024-01-231-4/+0
| | | | | | | | Most (all?) of the remaining usages are caught somewhere and will be migrated later. Bug: T328220 Change-Id: I5c36693a5361dd75b4f1e7a0bab5ad48626ed75c
* PoolCounter: Namespace classesAmir Sarabadani2023-12-201-0/+1
| | | | | | | | Two of the classes in this directory have already namespaced to MediaWiki\PoolCounter. Bug: T353458 Change-Id: Ie41f8d935f7623bb40040a5eb78f99c6d7b7b75e
* thumb: Fix "PHP Deprecated: strlen(): Passing null to parameter"Paladox2023-12-181-3/+3
| | | | Change-Id: I7b31f42c15f9404df865a16936091adc455bb675
* Introduce StatusFormatterdaniel2023-10-271-2/+8
| | | | | | | | | | | | | | | This takes us one step closer to deprecating Status, so we can isolate StatusValue from presentation logic. FormatterFactory is introduced as a mechanism for getting instance of formatters that need access to the user interface language and other request dependent information. Usage is demonstrated in thumb.php, SpecialCreateAccount, and SearchHandler. The examples indicates that there is no work do be done around ErrorPageError and LocalizedHttpException. Change-Id: I7fe5fee24cadf934e578c36856cc5d45fb9d0981
* Use Authority in thumb.phpdaniel2023-10-061-7/+11
| | | | | | | | | | | | | | | | | | | | | Replace usage of deprecated User::pingLimiter. Tested locally: * verified the relevant code paths are hit, using xdebug * renderfile limit is applied when rendering standard sizes * renderfile-nonstandard limit is applied when rendering non-standard sizes * rendering standard thumbnail size is not affected by 'renderfile-nonstandard' limit * rendering works when limits are not hit Test after merge: Test that thumb.php works on the beta cluster. But that actually seems to be broken already: <https://commons.wikimedia.beta.wmflabs.org/w/thumb.php?f=Nummer3.jpg&width=222> Monitor after deployment: Keep an eye on the Grafana board that tracks rate limit checks and outcomes: <https://grafana.wikimedia.org/d/8oA6CWr4z/mw-rate-limiting-overview> Change-Id: I74c966cde20396381f18c60ec8622a91c8aa7ea6
* Reorg: Move WebRequest to includes\RequestAmir Sarabadani2023-09-111-0/+1
| | | | | | | This has been approved as part of RFC T166010 Bug: T321882 Change-Id: I6bbdbbe6ea48cc1f50bc568bb8780fc7c5361a6f
* Reorg: Move Status to MediaWiki\Status\Amir Sarabadani2023-08-251-1/+2
| | | | | | | | | | This class is used heavily basically everywhere, moving it to Utils wouldn't make much sense. Also with this change, we can move StatusValue to MediaWiki\Status as well. Bug: T321882 Depends-On: I5f89ecf27ce1471a74f31c6018806461781213c3 Change-Id: I04c1dcf5129df437589149f0f3e284974d7c98fa
* Just another 80 or so PHPStorm inspection fixes (#4)Tim Starling2023-03-251-1/+1
| | | | | | | | | | | | | * Unnecessary regex modifier. I agree with this inspection which flags /s modifiers on regexes that don't use a dot. * Property declared dynamically. * Unused local variable. But it's acceptable for an unused local variable to take the return value of a method under test, when it is being tested for its side-effects. And it's acceptable for an unused local variable to document unused list expansion elements, or the nature of array keys in a foreach. Change-Id: I067b5b45dd1138c00e7269b66d3d1385f202fe7f
* Merge "Fix some typos"jenkins-bot2023-03-231-1/+1
|\
| * Fix some typosMatěj Suchánek2023-03-211-1/+1
| | | | | | | | | | Bug: T201491 Change-Id: I5c9408c262f09c936525f35abfacfa92a193b791
* | profiler: Add ProfilingContext classAaron Schulz2023-03-231-0/+3
|/ | | | | | | | | | | | | | | | | | Use this class to track the entry point and handler used for requests, making it available for use in profiling, stats, and logging code. This makes it possible for periodic and/or shutdown profiling callbacks to know the basic action handler that applies to the request (if any). Metric names can easily include this string along with MW_ENTRY_POINT to create per-action profiling dashboards. This info cannot otherwise be acquired from things like excimer stack traces since the router and handler classes do not appear in the stack during PRESEND deferred updates and variations like ApiMain/SpecialPage "inclusion mode" would have to be detected somehow. Bug: T330810 Change-Id: Icca5a7a343faeeb18652994c96752acb61a61fd1
* Reorg: Namespace the Title classJames D. Forrester2023-03-021-0/+1
| | | | | | | | | | | | | | | | | | | This is moderately messy. Process was principally: * xargs rg --files-with-matches '^use Title;' | grep 'php$' | \ xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1' * rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \ xargs rg --files-with-matches 'Title\b' | \ xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1' * composer fix Then manual fix-ups for a few files that don't have any use statements. Bug: T166010 Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
* Merge "Replace deprecated PermissionManager::getGroupPermissions"jenkins-bot2022-12-141-5/+6
|\
| * Replace deprecated PermissionManager::getGroupPermissionsUmherirrender2022-11-131-5/+6
| | | | | | | | Change-Id: I271473cedb1d10b8a2b9529d4af0c42f04bfcd98
* | thumb.php: Replace deprecated MWHttpRequest::factoryUmherirrender2022-12-111-1/+1
|/ | | | | Bug: T324918 Change-Id: Ia40349ec97b10fe7d55e80a2c219afc9c253543a
* Reorg: Move HeaderCallback to Request directoryAmir Sarabadani2022-11-081-2/+2
| | | | | | | Cleaning root of includes/ Bug: T321882 Change-Id: I1844da95d4fd79824646fdf4b6063cb771ca3000
* Revert "Reorg: Move some of request related classes to MediaWiki/Request"Zabe2022-10-271-1/+0
| | | | | | | | | This reverts commit 2bdc0b2b7209441a42a784157633a8a01b321922. Reason for revert: T166010#8349431 Bug: T166010 Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
* Reorg: Move some of request related classes to MediaWiki/RequestAmir Sarabadani2022-10-261-0/+1
| | | | | | | | | | | | | Moving: - DerivativeRequest - FauxRequest - FauxRequestUpload - PathRouter - WebRequest - WebRequestUpload Bug: T166010 Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
* Use short array destructuring instead of list()Tim Starling2022-10-211-3/+3
| | | | | | | | Introduced in PHP 7.1. Because it's shorter and looks nice. I used regex replacement. Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
* Replace trivial usages of code in strings with concatenationThiemo Kreuz2022-08-261-1/+1
| | | | | | | This is really hard to read. What is code, what is string? These places are so simple, they really don't need the "{$var}" syntax. Change-Id: I589dedb8c0193eec4eef500bbb896b5b790b727b
* maintenance: Replace some usages of Wikimedia\(suppress|restore)Warnings()Reedy2022-02-241-2/+3
| | | | Change-Id: Id1a2d0dedd3326083b6a9727f1ab68ddd8f65df8
* Use static closures where safe to useUmherirrender2021-02-111-4/+4
| | | | | | | | | This is micro-optimization of closure code to avoid binding the closure to $this where it is not needed. Created by I25a17fb22b6b669e817317a0f45051ae9c608208 Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
* Revert "Enhance GroupPermissionsLookup and use it."Ppchelko2021-01-121-4/+2
| | | | | | | | This reverts commit 900c6663b05b6a33498a81c187ac027209dd6502. Reason for revert: breaks Parsoid CI. Instead of fixing the test in presence of the FlaggedRevs hook, I would rather convert DefaultPreferencesFactory to Authority and fix the tests once instead of doing it twice. Change-Id: Iaa440a9804c9ed97339e737162ef64ccf29ceb51
* Enhance GroupPermissionsLookup and use it.Petr Pchelko2021-01-111-2/+4
| | | | | | | | | | | | | | Added new methods: - ::getGroupsWithAnyPermissions - ::getGroupsWithAllPermissions - ::groupHasAnyPermission - ::groupHasAllPermission Replaced relevant calls to PermissionManager with calls to GroupPermissionsLookup. Bug: T254537 Change-Id: I0b9c3352c5bebc94e1649239fe0527144e7c2eb2
* thumb.php - wfExtractThumbParams can return nullDannyS7122020-12-171-1/+1
| | | | Change-Id: If0450a185966141b3ab59451b6136ac31de6d345
* Introduce new wgThumbPath configPaladox2020-10-281-7/+13
| | | | | | | | | | | | | | | | This fixes behaviour introduced by 507501d6ee29eb1b8df443192971fe2b6a6addb6. $relPath returned false. This "substr( $requestPath, 0, strlen( $basePath ) ) !== $basePath" returned true, thus returned false. $requestPath returned "/w/thumb_handler.php/7/7d/Cloudflare_dashboard_3.png/800px-Cloudflare_dashboard_3.png" $basePath returned "/metawiki/thumb/". Introducing wgThumbPath resolves this by allowing us to set it to "$wgScriptPath/thumb_handler.php". Bug: T266619 Change-Id: If9430b5b4b5db2670bb3e361b03795871aed65da
* docs: Improve entry point documentationTimo Tijhof2020-07-021-1/+2
| | | | | | | | | | | | * Unlink the word "Action" in api.php description, which was unhelpfully being autolinked to the index.php Action baseclass. * Add links in the first sentence to the primary classes involved in their handling so that the "Entry points" overview page includes these links (subsequent sentence/paragraphs require an additional click). Change-Id: Ibe882746ea7753d5d4c90a04f6974ea807122d1c
* In Web entry points, move file scope code into a main functionTim Starling2020-06-251-13/+17
| | | | | | | | | | Avoid leaking local variables into the global scope by accident, by moving the entry point code to a function. In index.php, document the intentional $mediaWiki global so that nobody removes it by accident. Change-Id: Ie1a181ae3ebdda90cd2321f0c1b50e31fb0d586e
* Stop using SCRIPT_NAME where possible, rely on statically configured routingTim Starling2020-04-011-16/+8
| | | | | | | | | | | | | | | | | | | | | | | It has become apparent that $_SERVER['SCRIPT_NAME'] may contain the same thing as REQUEST_URI, for example in WMF production. PATH_INFO is not set, so there is no way to split the URL into SCRIPT_NAME and PATH_INFO components apart from configuration. * Revert the fix for T34486, which added a route for SCRIPT_NAME to the PathRouter for the benefit of img_auth.php. In T235357, the route thus added contained $1, breaking everything. * Remove calls to WebRequest::getPathInfo() from everywhere other than index.php. Dynamic modification of $wgArticlePath in order to make PathRouter work was weird and broken anyway. All that is really needed is a suffix of REQUEST_URI, so I added a function which provides that. * Add $wgImgAuthPath, for use as a last resort workaround for T34486. * Avoid the use of $_SERVER['SCRIPT_NAME'] to detect the currently running script. * Deprecated wfGetScriptUrl(), a fairly simple wrapper for SCRIPT_NAME. Apparently no callers in core or extensions. Bug: T235357 Change-Id: If2b82759f3f4aecec79d6e2d88cd4330927fdeca
* Use MediaWikiServices::getRepoGroup in file related classesUmherirrender2020-03-141-7/+8
| | | | Change-Id: Iceec961de4f0cc689f7d3b981afac923b46c98f6
* docs: Add api.php to "API" doc groupTimo Tijhof2020-02-051-1/+1
| | | | | | | | | | | Follow-up bc1f601382, which added a group to load.php, but I forgot to add api.php to its group. Also, fix the pre-existing group that thumb.php and thumb_handler.php were a part of. It looks like the entire "Media" group was not defined anywhere, so it was ignored by Doxygen. This is now fixed. Change-Id: Iba487aac5883f66b81f2496a38a3c978d5e6600b
* docs: Improve "Entry points" documentation pageTimo Tijhof2020-02-041-1/+5
| | | | | | | | | | | | Turn this into a doc group, and let the descriptions come directly from the files in question. This makes the list easier to maintain, and alsom means that the overview page becomes discoverable whenever one is looking at the entry point file as well. Previously the doc page pointed to the entry points, but not the other way around. This is also fixed. Bug: T244294 Change-Id: I891c5a37e17592edc1136d7367949927121c8bc8
* thumb.php: Use 'thumbnail' channel to report errorsdaniel2020-01-161-2/+2
| | | | | | | | | | | | | | The 'thumb' channel was being ignored. Quoting Timo: Those two lines using thumb are the only two in the codebase that use that channel. The previous one being introduced in 2015 and never enabled in prod from what I can see. There is however a more common thumbnail channel enabled in prod. Bug: T225197 Change-Id: Icf25135baf3de09a8a734bb32b0364990b465a42
* Merge "thumb.php: don't try to send errors after data has been sent."jenkins-bot2020-01-141-0/+9
|\
| * thumb.php: don't try to send errors after data has been sent.daniel2020-01-071-0/+9
| | | | | | | | | | | | | | | | If an error ocurrs after output streaming has already started, don't try to report the error to the user. Just log it internally. Bug: T225197 Change-Id: I8fd02987844161cf2fcb6cbe5a08e211256c3d4d
* | Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNullJames D. Forrester2020-01-101-1/+1
|/ | | | Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
* Remove space from stringsPaladox2019-12-231-1/+1
| | | | Change-Id: Id81dab1d806f2b93b5bad47cfd2a9fa37dedcd02
* Don't redefine MW_ENTRY_POINT in thumb.php if already definedReedy2019-12-231-1/+5
| | | | | Bug: T241340 Change-Id: I95914267bf22910391a54ec524ed11bc076f83e3
* Avoid using "enqueue" mode for deferred updates in doPostOutputShutdownAaron Schulz2019-09-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Set appropriate headers and flush the output as needed to avoid blocking the client on post-send updates for the stock apache2 server scenario. Several cases have bits of header logic to avoid delay: a) basic GET/POST requests that succeed (e.g. HTTP 2XX) b) requests that fail with errors (e.g. HTTP 500) c) If-Modified-Since requests (e.g. HTTP 304) d) HEAD requests This last two still block on deferred updates, so schedulePostSendJobs() does not trigger on them as a form of mitigation. Slow deferred updates should only trigger on POST anyway (inline and redirect responses are OK), so this should not be much of a problem. Deprecate triggerJobs() and implement post-send job runs as a deferred. This makes it easy to check for the existence of post-send updates by calling DeferredUpdates::pendingUpdatesCount() after the pre-send stage. Also, avoid running jobs on requests that had exceptions. Relatedly, remove $mode option from restInPeace() and doPostOutputShutdown() Only one caller was using the non-default options. Bug: T206283 Change-Id: I2dd2b71f1ced0f4ef8b16ff41ffb23bb5b4c7028
* Fix a typo (folow -> follow)DannyS7122019-09-131-1/+1
| | | | | Bug: T201491 Change-Id: I1083f6f0e29b9f3e9c2d0dd2bdb9e1f524327c0a
* Merge "Add MW_REST_API and MW_ENTRY_POINT"jenkins-bot2019-09-091-0/+1
|\
| * Add MW_REST_API and MW_ENTRY_POINTTim Starling2019-09-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Define the global constant MW_REST_API in rest.php, by analogy with MW_API. Also generalize this by adding MW_ENTRY_POINT, which contains the entry script name, "cli" or "unknown". This allows tests such as if ( MW_ENTRY_POINT !== 'index' ) which is probably what is really intended by defined('MW_API') in many cases. Change-Id: I24099f4cdd170de17afd6e1bbad67c9b204071fc
* | Stop mangling $_GET and provide WebRequest::getQueryValuesOnly()Tim Starling2019-09-051-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | I doubt there was ever a good reason for mangling $_GET to add the title, this was just b/c for the sake of b/c. It was formerly used in core but that was so long ago that I doubt there was any usage in extensions at the time. Now there is one usage of $_GET['title'] in an unmaintained extension, but it was only added in 2017. Also I added WebRequest::getQueryValuesOnly() which is an interface to the unmodified $_GET. The motivation is allowing OAuth to work with the REST API, since OAuth needs an unmangled view of $_GET for signature generation. The Action API gets around the problem with a special hack in interpolateTitle(), disabling it for the Action API only. A review of callers of getQueryValues() suggests that many would benefit from using getQueryValuesOnly() instead. But I only changed it for callers in api.php and thumb.php since the effect of the change there is certainly beneficial, whereas callers under index.php may possibly be using the path parameters to construct self-links. Rest\RequestFromGlobals uses $_GET directly, which means that this change causes it to not return PathRouter matches as GET parameters anymore. Change-Id: Ic469577fae17c0b1ac69466df7bc9f03e61c74e3
* Remove deprecated User groups/permission static calls.Petr Pchelko2019-08-211-2/+2
| | | | | Bug: T220191 Change-Id: Ifa8afa90c432723b0bba0033a46b6a499c77e6fc
* Merge "Migrate remaining usages of Title::userCan() to PermissionManager"jenkins-bot2019-06-141-1/+5
|\
| * Migrate remaining usages of Title::userCan() to PermissionManagerMáté Szabó2019-06-031-1/+5
| | | | | | | | | | | | | | | | | | T208768 introduced the PermissionManager service that can now be used for page specific permission checks. This change replaces remaining calls to Title::userCan() with the new service in MediaWiki core. Bug: T220191 Change-Id: Ie45e0cb6aa49a8c66147b470946161fc18160fc1
* | Log headers sent errors more usefully in thumb.phpGergő Tisza2019-06-061-0/+4
|/ | | | | Bug: T225197 Change-Id: Ifcb02b3d5794061f27c005b32164ac014f926357