aboutsummaryrefslogtreecommitdiffstats
path: root/includes/media/TransformationalImageHandler.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
* Replace call_user_func with dynamic function callUmherirrender2025-02-131-1/+1
| | | | | | | | Use modern php syntax to call a callable. Reduce the stack trace to improve performance and better IDE and static analyzer support Change-Id: I9ef131032a662a3b8db69aa7079dbd51f88f575a
* Fix Thumbnail404EntryPointTest::testStreamOldFile failures with gdAaron Schulz2024-11-251-1/+1
| | | | | | | | | | Scaling two very small and similar images down to a tiny size can result in the same png depending on whether gd or image magick is used. The tests should not depend on these config differences. Add some more wfDebug() statements to File::transform() methods. Change-Id: I441cbec1a949d0ed6df6e83c793063c5377f9654
* Fix typo is commentsFomafix2024-11-141-4/+4
| | | | Change-Id: I1b7a9d85fbea10406def755da553ef7ba47e1858
* media: Replace deprecated MWExceptionDaimona Eaytoy2023-06-091-4/+2
| | | | | | | Introduce new classes for checked exceptions. Bug: T328220 Change-Id: Idbcdc09647a857e359e41ecec98212a8937c5c2e
* Replace internal Hooks::runnerUmherirrender2023-05-111-2/+4
| | | | | | | | | The Hooks class contains deprecated functions and the whole class is going to get removed, so remove the convenience function and inline the code. Bug: T335536 Change-Id: I8ef3468a64a0199996f26ef293543fcacdf2797f
* media: code style improvementsDerk-Jan Hartman2023-03-091-28/+32
| | | | | | | | | | | | | - 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
* Use MainConfigNames instead of string literals, #4Aryeh Gregor2022-04-261-3/+4
| | | | | | | | | | | | | | | | | | | | | 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
* Merge "media: Improve documentation on Handler functions"jenkins-bot2022-04-111-5/+5
|\
| * media: Improve documentation on Handler functionsUmherirrender2022-03-291-5/+5
| | | | | | | | | | | | Add missing @return and use false instead of bool where possible Change-Id: Ie85a40987422e32aa02c56969e103371ec2e5b5f
* | phan: Use @phan-assert on ImageHandler::normaliseParamsUmherirrender2022-04-021-1/+0
|/ | | | | | | | Allow phan to assume that some array keys are always set after call to normaliseParams to avoid phan suppression Follow-Up: I701f12ab94478c3b8e7fd82110ade74a8e6b04ef Change-Id: I8d14e49340d30c56642422cd88169019dd2c4286
* phan: Remove PhanTypePossiblyInvalidDimOffset suppressionUmherirrender2022-03-281-0/+3
| | | | | | | | | | | Make phan stricter about array keys Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T304887 Depends-On: I3105a5fd4826f8667b5232834defc5ec93be32a1 Depends-On: Ie9610a6e83731468311edb3ed17f80fc509de385 Change-Id: I701f12ab94478c3b8e7fd82110ade74a8e6b04ef
* phan: Disable scalar_implicit_cast settingUmherirrender2022-03-181-0/+1
| | | | | | | | | Make phan stricter about scalar types by setting scalar_implicit_cast to false (the default in mediawiki-phan-config) Bug: T242536 Bug: T301991 Change-Id: Ia2fe30b17804186571722e728578121c8b75d455
* Fix various real types related to scalar typesUmherirrender2022-03-101-1/+1
| | | | | | | | Swap null/false or use real strings if needed Found by phan strict checks Change-Id: Id82ea609f05a76c5cb8c661d5cf2b7922d6cfbc1
* 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 timestamp to thumbnail URLs on file pagesAntiCompositeNumber2022-01-251-1/+8
| | | | | | | | | | | | | | | | | | | When overwriting a file, the browser will sometimes display a cached old version of the file instead of the new version. This is because the URLs for the current version of a file (and thumbnails) are not versioned. This patch adds the timestamp as a query parameter to the end of the file URLs. Only the src and srcset URLs will have the timestamp, the links to the original and thumbnails are not versioned. The current version in the file history also gets the timestamp. Previous versions already have a timestamp in the URL. This timestamp is only used for client-side cache busting, it is not interpreted server-side. On WMF sites it will be stripped out by the caching layer anyway. Bug: T38380 Change-Id: Ia63bd96a02d1aa36265742c4307f5af2e675b3ec
* Refactor global variables to use MediaWikiServices insteadTChin2022-01-101-7/+9
| | | | | | | | | | | | 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
* Allow skipping $wgMaxImageArea checkKunal Mehta2021-09-231-0/+5
| | | | | | | | | | | | | | | | | If $wgMaxImageArea is false, MediaWiki will no longer check if the image fits within that area before trying to scale it. Extensions can still use the BitmapHandlerCheckImageArea hook to override it. This is primarily useful when using an external scaler like Wikimedia does with Thumbor, which decides whether it can scale images by using a timeout rather than based on size. Codesearch indicates that the only extension checking this setting is PagedTiffHandler, which will be updated in Iefa67321d07f7. Bug: T291014 Depends-On: Iefa67321d07f79d982388231e02e87e2f18aed40 Change-Id: Id10173bbddb32bc70e036f426369cfbea52cecf4
* build: Update mediawiki/mediawiki-phan-config to 0.11.0Umherirrender2021-09-071-0/+1
| | | | | | | Addition and remove of suppression needs to be done with the version update. Change-Id: I3288b3cefa744b507eadebb67b8ab08c86517c1c
* Use static closures where safe to useUmherirrender2021-02-111-1/+1
| | | | | | | | | 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
* Improve callable docsUmherirrender2020-11-131-1/+1
| | | | Change-Id: I4cc9b2dbe285ad935a1dfd08effa673a39167483
* 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-11/+11
|/ | | | | | | | | | | 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 media handling based classes as stable for subclassingdaniel2020-07-091-0/+13
| | | | | Bug: T247862 Change-Id: I1737e43e291e41514a78a285315fcce73686dcea
* Remove terminating line breaks from debug messagesTim Starling2020-06-031-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Hooks::run() call site migrationTim Starling2020-05-301-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Migrate all callers of Hooks::run() to use the new HookContainer/HookRunner system. General principles: * Use DI if it is already used. We're not changing the way state is managed in this patch. * HookContainer is always injected, not HookRunner. HookContainer is a service, it's a more generic interface, it is the only thing that provides isRegistered() which is needed in some cases, and a HookRunner can be efficiently constructed from it (confirmed by benchmark). Because HookContainer is needed for object construction, it is also needed by all factories. * "Ask your friendly local base class". Big hierarchies like SpecialPage and ApiBase have getHookContainer() and getHookRunner() methods in the base class, and classes that extend that base class are not expected to know or care where the base class gets its HookContainer from. * ProtectedHookAccessorTrait provides protected getHookContainer() and getHookRunner() methods, getting them from the global service container. The point of this is to ease migration to DI by ensuring that call sites ask their local friendly base class rather than getting a HookRunner from the service container directly. * Private $this->hookRunner. In some smaller classes where accessor methods did not seem warranted, there is a private HookRunner property which is accessed directly. Very rarely (two cases), there is a protected property, for consistency with code that conventionally assumes protected=private, but in cases where the class might actually be overridden, a protected accessor is preferred over a protected property. * The last resort: Hooks::runner(). Mostly for static, file-scope and global code. In a few cases it was used for objects with broken construction schemes, out of horror or laziness. Constructors with new required arguments: * AuthManager * BadFileLookup * BlockManager * ClassicInterwikiLookup * ContentHandlerFactory * ContentSecurityPolicy * DefaultOptionsManager * DerivedPageDataUpdater * FullSearchResultWidget * HtmlCacheUpdater * LanguageFactory * LanguageNameUtils * LinkRenderer * LinkRendererFactory * LocalisationCache * MagicWordFactory * MessageCache * NamespaceInfo * PageEditStash * PageHandlerFactory * PageUpdater * ParserFactory * PermissionManager * RevisionStore * RevisionStoreFactory * SearchEngineConfig * SearchEngineFactory * SearchFormWidget * SearchNearMatcher * SessionBackend * SpecialPageFactory * UserNameUtils * UserOptionsManager * WatchedItemQueryService * WatchedItemStore Constructors with new optional arguments: * DefaultPreferencesFactory * Language * LinkHolderArray * MovePage * Parser * ParserCache * PasswordReset * Router setHookContainer() now required after construction: * AuthenticationProvider * ResourceLoaderModule * SearchEngine Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
* Fix includes/media/ Squiz.Scope.MethodScope.MissingReedy2020-05-181-4/+4
| | | | Change-Id: I2bf5543b99dc2ae05f7de02940d120dee353adfe
* Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNullJames D. Forrester2020-01-101-2/+2
| | | | Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
* Fix "succesful" typopetarpetkovic2019-06-141-1/+1
| | | | Change-Id: I1f49ce9ce104263adc8763947dbd30634f18697d
* Replace deprecated function wfEscapeShellArg with Shell::escape()Derick Alangi2019-04-071-1/+2
| | | | Change-Id: I4046d593d1450cfffc489ca2abadba1084a540e4
* 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
* Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenientBartosz Dziewoński2018-05-301-1/+1
| | | | | | | | | | | | | | Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/ Replace with: '\1 ?? ' (Everywhere except includes/PHPVersionCheck.php) (Then, manually fix some line length and indentation issues) Then manually reviewed the replacements for cases where confusing operator precedence would result in incorrect results (fixing those in I478db046a1cc162c6767003ce45c9b56270f3372). Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
* Fix some broke cache key generationsAaron Schulz2017-11-191-1/+1
| | | | Change-Id: Ib724fe0cfa866351caee89d3451b6c4b7b6a4578
* Always put type information before variable name for @var tagsKunal Mehta2017-09-041-1/+1
| | | | | | | | | Like other tags, @var should have the type information before the variable name. <https://docs.phpdoc.org/references/phpdoc/tags/var.html> Change-Id: I9eca6957b1990fa8cc687103dc02ee38af5f9086
* Add missing & to @param documentation to match functon callUmherirrender2017-08-111-2/+2
| | | | Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
* Remove empty lines at begin of function, if, foreach, switchUmherirrender2017-07-011-1/+0
| | | | | | Organize phpcs.xml a bit Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
* media: Capture stderr when running 'convert --version'Antoine Musso2017-04-151-1/+1
| | | | | | | | | | | | | | | | | | | At Wikimedia, $wgImageMagickConvertCommand points to a shell wrapper that invokes ImageMagick convert with: firejail --profile=/etc/firejail/mediawiki-converters.profile firejail emits to stderr an information message: Reading profile /etc/firejail/mediawiki-converters.profile That ends up in HHVM stderr and is populated up to logstash as an error. MediaWiki does check imagemagick version by running `convert -version`, switch from wfShellExec() to wfShellExecWithStderr(). Bug: T158649 Change-Id: I78d1ef59533c605f59b42e10556bb595d6c2cc15
* Clean up remaining get_class() usesTimo Tijhof2017-03-071-1/+1
| | | | | | | | * get_class() -> __CLASS__ (same as self::class) * get_called_class() -> static::class * get_class($this) -> static::class Change-Id: I1888a1897ecf4548a2e5a67a942e5c080dd7e3d3
* Fix MediaTransformError message handlingBrad Jorsch2016-11-301-3/+3
| | | | | | | | | | | Give access to the raw Message instead of only to the HTML or text in the RequestContext language. Pass Message objects instead of strings from calling ->text() as the parameters of Messages so if the outer Message's language is changed things get parsed sensibly. Change-Id: Ibd6c1217b6fed839c888b66e02900f8e21ed3e6b
* TransformationalImageHandler: Fix use of __METHOD__ in closureBartosz Dziewoński2016-11-101-3/+4
| | | | Change-Id: Idff6303fac1f494ea59b88fd73245c63f2cf4a76
* Clean up some ObjectCache factory callersAaron Schulz2016-10-031-1/+2
| | | | | | | | * Use services container in more places. * Undeprecated getLocalServerInstance() since $fallback is not handled elsewhere. Change-Id: Id1fcd1c465d2d92653357523f4225f1c4d1ace2f
* Clean up array() syntax in docs, part VIIAmir Sarabadani2016-09-271-1/+1
| | | | | | Last part Change-Id: I38f015e2122ef4fd2d2141718bd889794c29f06c
* Fix and standardize Doxygen tagsRicordisamoa2016-04-301-3/+3
| | | | | | | | | | * Use "@param datatype $paramname description" format * String → string, Integer → int etc. * @return $string → @return string Change-Id: I860d222382cb4c5699d313b0600bd22503c8c385
* Many more function case mismatchesReedy2016-03-191-1/+1
| | | | Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
* Convert all array() syntax to []Kunal Mehta2016-02-171-11/+11
| | | | | | | | | | Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html Notes: * Disabled CallTimePassByReference due to false positives (T127163) Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
* Add support for image interlacing of Bitmap type imagesAndrew H2016-01-161-0/+1
| | | | | | | Add 'interlace' parameter and $wgMaxInterlacingSizes global. Bug: T120032 Change-Id: I40dee74060026513f1c2be8c22dfe41a0b4a18df
* Replace newAccelerator() with getLocalServerInstance()Aaron Schulz2015-11-021-1/+1
| | | | | | The name is clearer and more consistent, with simpler arguments. Change-Id: I7205a99ce033e8b086a52cd02c8a721e99c84b1e
* objectcache: Introduce IExpiringStore for convenient TTL constantsTimo Tijhof2015-10-281-4/+4
| | | | | | | Also consistently use self:: instead of BagOStuff:: for constants referenced within the BagOStuff class. Change-Id: I20fde9fa5cddcc9e92fa6a02b05dc7effa846742
* Convert getMagickVersion() to using APCAaron Schulz2015-10-261-21/+22
| | | | | | | Shelling out on my slow vagrant VM takes about ~3-4ms so it's probably not worth a fallback. Change-Id: Ifd5758264cc15f1ae07972e839a243f5f891503e