aboutsummaryrefslogtreecommitdiffstats
path: root/includes/media/BitmapHandler.php
Commit message (Collapse)AuthorAgeFilesLines
* Replace a number of uses of class aliases with the real thingsJames D. Forrester2025-03-261-0/+1
| | | | | | | Found via disabling phan's alias support for a run (and ignoring wgLang's hard-coded state of being a \Language, alas). Change-Id: I4753bcd84d72d6de111fc7ffc5841fa417bf7333
* mediaHandler: Respect image scaler configs for Webp and XCF filesFunc2024-06-021-1/+11
| | | | | | | | | | | ImageMagick should not be used if it's not installed. When a custom convert command is configured, it's the site admin's responsibility to make sure it works with Webp and XCF files. The php-imagick extension is just a wrapper for the ImageMagick library, and would also work for Webp and XCF files. Bug: T308386 Change-Id: I9fcf22b0c4b6d5d132e5a44530e3f255075f7fb4
* Replace complex preg_replace_callback with strtr/preg_replacethiemowmde2023-10-051-16/+6
| | | | | | | | | | | | The complexity is really not needed in these cases. strtr() does have the behavior we want: It does all replacements at the same time instead of sequentially. We are also adding test cases for the previously uncovered StringUtils::escapeRegexReplacement() we rely on in this patch. Bug: T308395 Change-Id: I6741303775d6d54f3ad0d50635a986ff992ae8f4
* media: code style improvementsDerk-Jan Hartman2023-03-091-16/+14
| | | | | | | | | | | | | - Avoid unnecesary else branching - Static vs non-static fixes - string, int and float casting instead of strval, intval, floatval (faster and more readable) - Strict comparisons (but not for all '' and 0 as might have implicit falsey behavior) - Few spelling mistakes - Remove TimestampException handling, caught by parent function Change-Id: I08725c8e391965529a2766dfaf5d8f6cf8a86db8
* media: Remove unneeded complexity in BitmapHandler command replacementDerk-Jan Hartman2023-02-101-14/+11
| | | | | Bug: T308394 Change-Id: I207b24473e761ac3fdd53d002ba8ce44f4d2dac3
* Replace some usages of MWExceptionDaimona Eaytoy2023-01-261-1/+1
| | | | | | | | These exceptions are not documented with @throws and they're really not meant to be caught. Bug: T86704 Change-Id: I07f32e42c6fd4bc8785bac91547858f15a9fc2a8
* Make use of ?:, ?? and ??= operators in mostly trivial casesthiemowmde2022-12-051-5/+1
| | | | | | | | | | The motivation is to make the code less confusing. I hope this is the case. ?? is an older PHP 7.0 feature. ??= was added in PHP 7.4, which we can finally use. Change-Id: Id807affa52bd1151a74c064623b41d950a389560
* Use short array destructuring instead of list()Tim Starling2022-10-211-5/+5
| | | | | | | | Introduced in PHP 7.1. Because it's shorter and looks nice. I used regex replacement. Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
* build: Update mediawiki/mediawiki-phan-config to 0.12.0Daimona Eaytoy2022-10-081-0/+1
| | | | | | | | This patch only adds and removes suppressions, which must be done in the same patch as the version bump. Bug: T298571 Change-Id: I4044d4d9ce82b3dae7ba0af85bf04f22cb1dd347
* Guard CustomConvertCommand against placeholders within valuesDerk-Jan Hartman2022-06-081-8/+22
| | | | | | | | | | | | | | Because the str_replaces were done sequentially, it was possible that the replacement values for the placeholders of the CustomConvertCommand would insert placeholder values of their own. Find all placeholders at once on the original value using preg_replace_callback and make sure each is replaced only once. Based on a suggestion by User:SacredSum Bug: T308394 Change-Id: Id672996454445dd200e57cf207c56e3268a3fcc8
* Use MainConfigNames instead of string literals, #4Aryeh Gregor2022-04-261-20/+24
| | | | | | | | | | | | | | | | | | | | | Now largely automated: VARS=$(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | \ tr "\n" '|' | sed "s/|$/\n/;s/'//g") sed -i -E "s/'($VARS)'/MainConfigNames::\1/g" \ $(grep -ERIl "'($VARS)'" includes/) Then git add -p with lots of error-prone manual checking. Then semi-manually add all the necessary "use" lines: vim $(grep -L 'use MediaWiki\\MainConfigNames;' \ $(git diff --cached --name-only --diff-filter=M HEAD^)) I didn't bother fixing lines that were over 100 characters unless they were over 120 and triggered phpcs. Bug: T305805 Change-Id: I74e0ab511abecb276717ad4276a124760a268147
* media: Improve documentation on Handler functionsUmherirrender2022-03-291-2/+2
| | | | | | Add missing @return and use false instead of bool where possible Change-Id: Ie85a40987422e32aa02c56969e103371ec2e5b5f
* phan: Upgrade mediawiki-phan-config to 0.11.1 and set minimum_target_php_versionJames D. Forrester2022-03-291-1/+2
| | | | | | | | | | | | | | | | MediaWiki still supports PHP 7.2+, but we want to mainly test in newer versions of PHP. Setting minimum_target_php_version to 7.2 this lets us run phan without phan trying to get us to make PHP 7.2-incompatible changes to 'appease' PHP 8.0 or whatever later changes. Some switches of generic 'resource' type-hinting to 'resource|object' to inform phan to ignore this (triggering PHPCS at the time, ah well), rather than trying to hint the specific novel PHP encapsulation classes to that have replaced them from PHP 8.0 onwards but don't yet exist, and fixes from where we were checking the results of implode and explode. Bug: T293924 Change-Id: I629e3fb3adfad73beb3d424a07e643c2e079d9bb
* Merge "media: Limit result array of explode() to minimum needed"jenkins-bot2022-03-181-1/+1
|\
| * media: Limit result array of explode() to minimum neededUmherirrender2022-03-011-1/+1
| | | | | | | | | | | | | | | | Limit the array for the input to the expected size (or one bigger). This avoids big arrays on bad input and allows to process with the expected values in the array. Change-Id: Iec1a85c29d928966c14cc0273b1a251dc0b6b738
* | Fix various documentation related to null types (part II)Umherirrender2022-03-081-1/+1
|/ | | | | | | | | The functions returning null or the class property is set explict null. Some function should not accept null or return null. Found by phan strict checks Change-Id: Ie50f23249282cdb18caa332f562a3945a58d86ff
* Add explicit casts between scalar typesUmherirrender2022-03-011-1/+1
| | | | | | | | | | | | | | | * Some functions accept only string, cast ints and floats to string * After preg_matches or explode() casts numbers to int to do maths * Cast unix timestamps to int to do maths * Cast return values from timestamp format function to int * Cast bitwise operator to bool when needed as bool * php internal functions like floor/round/ceil documented to return float, most cases the result is used as int, added casts Found by phan strict checks Change-Id: Icb2de32107f43817acc45fe296fb77acf65c1786
* Refactor global variables to use MediaWikiServices insteadTChin2022-01-101-39/+50
| | | | | | | | | | | | Automatically refactors wg prefixed globals to use MediaWikiServices config using Rector. Doesn't include files that set globals or files that fail CI. Rector Gist: https://gist.github.com/tchin25/7cc54f6d23aedef010b22e4dfbead228 * This patch uses a modified source code rector library for our specific use case and the rector will have different effects without it. A writeup for future reference is here: https://meta.wikimedia.org/wiki/User:TChin_(WMF)/Using_Rector_On_MediaWiki Change-Id: I1a691f01cd82e60bf41207d32501edb4b9835e37
* Improve callable docsUmherirrender2020-11-131-1/+1
| | | | Change-Id: I4cc9b2dbe285ad935a1dfd08effa673a39167483
* media: Remove checks for ancient ImageMagick versions in BitmapHandlerReedy2020-09-041-27/+11
| | | | | Bug: T261258 Change-Id: I66d36a2e97d82dea704a51cc6e219fff8bc1d69b
* Merge "Replace "@stable for subclassing" with "@stable to extend""jenkins-bot2020-07-131-1/+1
|\
| * Replace "@stable for subclassing" with "@stable to extend"daniel2020-07-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | For compliance with the new version of the table interface policy (T255803). This patch was created by an automated search & replace operation on the includes/ directory. Bug: T257789 Change-Id: Ie32c1b11b3d16ddfc0c83a757327d449ff80b2e4
* | Replace "@stable for overriding" with "@stable to override"daniel2020-07-131-9/+9
|/ | | | | | | | | | | For compliance with the new version of the table interface policy (T255803). This patch was created by an automated search & replace operation on the includes/ directory. Bug: T257789 Change-Id: I5ffbb91882ecce2019ab644839eab5e8fb8a1c5f
* Mark remaining eligible classes as stable for subclassingdaniel2020-07-101-0/+19
| | | | | | | | This classes were found by surveying concrete classes derved from base classes in core. Bug: T247862 Change-Id: I231752aaad26e2ab3f097301e449b31e723590f0
* Remove terminating line breaks from debug messagesTim Starling2020-06-031-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | A terminating line break has not been required in wfDebug() since 2014, however no migration was done. Some of these line breaks found their way into LoggerInterface::debug() calls, where they mess up the formatting of the debug log. So, remove terminating line breaks from wfDebug() and LoggerInterface::debug() calls. Also: * Fix the stripping of leading line breaks from the log header emitted by Setup.php. This feature, accidentally broken in 2014, allows requests to be distinguished in the log file. * Avoid using the global variable $self. * Move the logging of the client IP back to Setup.php. It was moved to WebRequest in the hopes that it would not always be needed, however $wgRequest->getIP() is now called unconditionally a few lines up in Setup.php. This means that it is put in its proper place after the "start request" message. * Wrap the log header code in a closure so that variables like $name do not leak into global scope. * In Linker.php, remove a few instances of an unnecessary second parameter to wfDebug(). Change-Id: I96651d3044a95b9d210b51cb8368edc76bebbb9e
* Fix some Squiz.Scope.MethodScope.MissingReedy2020-05-161-1/+1
| | | | Change-Id: Id0351e44482885ee90e047c1ae3a439e484104c6
* Fix return type hints in media related classesUmherirrender2019-06-181-3/+3
| | | | Change-Id: Id326fb2a54aac62cb27aa7045082924b5cd84940
* Make some array type hints more specificThiemo Kreuz2019-05-221-1/+1
| | | | Change-Id: Ia9ed6fa851316baa47e73d9a5988a863d15f298c
* Replace deprecated function wfEscapeShellArg with Shell::escape()Derick Alangi2019-04-071-9/+11
| | | | Change-Id: I4046d593d1450cfffc489ca2abadba1084a540e4
* Collapse some nested if statementsReedy2019-04-041-4/+2
| | | | Change-Id: I9a97325d738d09370d29d35d5254bc0dadc57ff4
* media: Mark public MediaHandler/ImageHandler methods as suchThiemo Kreuz2019-02-251-1/+1
| | | | | | | | | | | | | Note I'm intentionally not touching the entire file, but only methods I'm absolutely sure are already called from outside, e.g. from MediaHandlerFactory, and must be public because of this. I'm intentionally not doing anything with private or protected in this patch, as such changes are much more fragile. This is a direct follow up for the changes proposed in Iaa4f60d. Change-Id: Ida817b289ddd5e9a8c162cc1fa3335c639a0bbe5
* Get rid of call_user_func(_array)(), part 3Max Semenik2018-06-101-2/+2
| | | | | | Also cleaned up nearby code in a couple places. Change-Id: Ibf44ee7c0ceb739d7e79406e4ff39303c316e285
* Replace call_user_func_array(), part 2Max Semenik2018-06-071-1/+1
| | | | | | | | | | | | | | | Uses new PHP 5.6 syntax like ...parameter unpacking and calling anything looking like a callback to make the code more readable. There are much more occurrences but this commit is intentionally limited to an easily reviewable size. In one occurrence, a simple conditional instead of trickery was much more readable. This patch finishes all the easy stuf in the core, the remainder is either unobvious or would result in smaller readability gains. It will be carefully dealt with in further commits. Change-Id: I79a16c48bfb98b75e5b99f2f6f4fa07b3ae02c5b
* media: Rename files to match the name of the class they defineTimo Tijhof2018-04-281-0/+607
This will make jumping from file to file much easier in text editors when file name lookups will autocomplete naturally when looking for a class by name. Change-Id: I4b2e55a2e72674b619d5a592866c8a019a2b0224