Commit graph

78 commits

Author SHA1 Message Date
Reedy
39f0f919c5 Update suppressWarning()/restoreWarning() calls
Bug: T182273
Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
2018-02-10 08:50:12 +00:00
Thiemo Mättig
ef470ebf7f Remove @param comments that literally repeat what the code says
These comments do not add anything. I argue they are worse than having
no comments, because I have to read them first to understand they
actually don't explain anything. Removing them makes room for actual
improvements in the future (if needed).

Change-Id: Iee70aad681b3385e9af282d5581c10addbb91ac4
2018-01-10 14:14:26 +01:00
Reedy
c16af68fb6 Replace MimeMagic::singleton() calls
Change-Id: Ieed41b5d6b0f568fe2872e7754f2feae7868fe7a
2017-11-27 02:13:51 +00:00
Gilles Dubuc
635ac7aeed Clean up X-Content-Dimensions
Bug: T175689
Change-Id: I20d93afd85b4d35c67c60193fa3026cebde71b0e
2017-09-21 17:22:07 +00:00
Umherirrender
9b8b314992 Fix spacing for @param and indent of function comments
In phpcs.xml rename renamed sniffs and add the failing sniffs,
because now the whole sniff is no longer excluded.

Change-Id: If5b0bd16028761abc2c47ace9e97d37ad14bb36f
2017-08-15 14:33:29 +00:00
Umherirrender
718e63694d Add missing @param and @return documentation
Change-Id: I1d1098eec3933df6561cceef646576013ddc08c8
2017-08-11 22:17:01 +02:00
Umherirrender
5544cef16b Add missing type to @param documentation
Change-Id: I6b2c9c7af9a281fe457099cc3a336a60a25e74aa
2017-08-11 20:37:35 +02:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
Gilles Dubuc
c2ea52a545 Remove X-Content-Dimensions header
Reverts 84e4d75088, and parts of cdfe08439c and 4511f6fa9f.

Bug: T150741
Bug: T167034
Change-Id: I39cfcf2cb231b6dfef569968fba6f473da258916
2017-06-12 18:07:28 +00:00
Gilles Dubuc
84e4d75088 Use file width/height instead of metadata for getContentHeaders
This allows us to populate X-Content-Dimensions without touching the
existing metadata format. Which makes the migration of existing content a lot faster by
only having to run refreshFileHeaders.

Bug: T150741
Change-Id: I2c0f39b2b01f364c3fab997ccc2f874b7f101d8a
2017-05-23 19:18:58 +00:00
Gilles Dubuc
cdfe08439c Store original media dimensions as additional header
For storage repos that support headers (such as Swift), this will store the original
media dimensions as an extra custom header, X-Content-Dimensions.
The header is formatted to minimize its length when dealing with multipage
documents, by expressing the information as page ranges keyed by dimensions.

Example for a multipage documents with some pages of different sizes:
X-Content-Dimensions: 1903x899:1-9,11/1903x873:10

Example for a single page document:
X-Content-Dimensions: 800x600:1

Bug: T150741
Change-Id: Ic4c6a86557b3705cf75d074753e9ce2ee070a6df
2017-05-09 15:49:28 -07:00
James D. Forrester
9635dda73a includes: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
2017-02-21 18:13:24 +00:00
Fomafix
202f695f67 Update weblinks in comments from HTTP to HTTPS
Use HTTPS instead of HTTP where the HTTP link is a redirect to the HTTPS link.

Also update some defect links.

Change-Id: Ic3a5eac910d098ed5c2a21e9f47c9b6ee06b2643
2016-11-07 15:24:46 +01:00
Amir Sarabadani
9850c542c6 Clean up array() syntax in docs, part VII
Last part

Change-Id: I38f015e2122ef4fd2d2141718bd889794c29f06c
2016-09-27 06:53:25 +03:30
Aaron Schulz
ff5abb66b4 Migrate callers to new MWFileProps::getPropsFromPath() method
* FSFile should not be responsible for handling this much logic.
* Make more MediaHandler classes aware of the fact that an object
  other than File might be passed in. Use the FSFile instead of a
  useless empty stdClass object.
* Also added more fields to FSFile::placeholderProps to make it
  more complete.

Change-Id: I9fe764b2a7261af507c6555e6a57273cf7d00d36
2016-09-22 00:33:46 +00:00
Kunal Mehta
b4596edd00 Introduce MediaHandlerFactory to create MediaHandler objects
This will allow further refactoring of override logic in parser tests.

Ideally the factory class would not use $wgMediaHandlers directly, but
that ends up breaking too many tests for now.

Change-Id: I34a63ee7089ff26f86f3dd6f3cd1a37928bc4005
2016-08-03 16:47:41 -07:00
Kunal Mehta
7822d7089c MediaHandler: Fix @return for getHandler()
Change-Id: I9373501e0055d0cddcb6c5bf72f5496ed22133c3
2016-07-25 17:27:24 -07:00
Ricordisamoa
7972c460ed Add missing 'public' keywords to some MediaHandler methods
* getParamMap
* validateParam
* makeParamString
* parseParamString
* canRender
* mustRender
* isMultiPage

Change-Id: I0c00a61abf9be400dca5407370ca2c232d57ae17
2016-02-24 00:47:02 +01:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
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
2016-02-17 01:33:00 -08:00
Aaron Schulz
75f42aa8ea Convert DjVU cache to WANObjectCache
Also unified the total and per page dimensions cache

Change-Id: Ib6ad7c3cdfb4fe3a88d25240c3e362664a9b41fd
2015-10-28 04:47:18 +00:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
Amir E. Aharoni
7a2d08ee72 Fix LineLength in includes/media
Bug: T102614
Change-Id: Id46d9040e264cd2af1174938dde58ea7d9c0bb5e
2015-09-26 20:01:29 +03:00
Kunal Mehta
f6e5079a69 Use mediawiki/at-ease library for suppressing warnings
wfSuppressWarnings() and wfRestoreWarnings() were split out into a
separate library. All usages in core were replaced with the new
functions, and the wf* global functions are marked as deprecated.

Additionally, some uses of @ were replaced due to composer's autoloader
being loaded even earlier.

Ie1234f8c12693408de9b94bf6f84480a90bd4f8e adds the library to
mediawiki/vendor.

Bug: T100923
Change-Id: I5c35079a0a656180852be0ae6b1262d40f6534c4
2015-06-11 18:49:29 +00:00
Mark Holmquist
a398c0c933 Add framework for file warnings
See I674bf7f6c1b21ffc9870aa84382479af5f966561 for an example in the
PdfHandler extension.

Bug: T89765
Change-Id: I3c4b7af7284b5e16e458dd72de789e74db489895
2015-03-18 10:05:19 -05:00
umherirrender
dc1b084079 Pass context to FormatMetadata class on ImagePage
This avoids on image page:
ContextSource::getContext (FormatMetadata): called and $context is null.
Using RequestContext::getMain() for sanity

Change-Id: I92774e1a88f03d44967d1797c6c2b8a31c1b10fc
2015-01-30 20:31:54 +01:00
Aaron Schulz
e369f66d00 Replace wfRunHooks calls with direct Hooks::run calls
* This avoids the overhead of an extra function call

Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
2014-12-10 12:26:59 -08:00
Brian Wolff
757a70ae0a Split BitmapHandler into two classes.
BitmapHandler has a lot of generic-ish functionality that could
be re-usable by extension classes (Such as how it organizes
$scalerParams array, or various image magick escaping methods).
However it's combined with a lot of very format specific things,
such as the shell-out call to image magick.

Try to separate out the more generic stuff into
TransformationalImageHandler. In order to do this, I also made
canRotate, autoRotateEnabled, and getScalerType non-static. No
extensions in our repo appeared to be using these methods, and they
don't really make sense to be static (imo).

In particular, I think code duplication can be reduced in
PagedTiffHandler by extending this new class. See comments
on I1b9a77a4a56eeb65.

Change-Id: Id3a8b25a598942572cb5791a95e86054d7784961
2014-09-14 22:10:37 +00:00
umherirrender
079d9ae83c Use /** for doc comments
/* is only a comment, which is not used when build the documentation

Change-Id: Id5f917928e3a253a90fd17b0d7aad7340f9393f5
2014-08-13 19:31:13 +00:00
rillke
c31fbf073e Unify the spelling of MIME in documentation
Writing MIME as written in Wikipedia and some documentation clean up.

Change-Id: I9dfc36d2bf55d72d9374c4075bd6d45eef0415a4
2014-08-07 23:38:45 +02:00
umherirrender
dd8921c9d9 Cleanup some docs (includes/[m-r])
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: I8ebfbcea0e2ae2670553822acedde49c1aa7e98d
2014-07-24 19:43:25 +02:00
Max Semenik
da300d4432 Fix DjVu tests isolation
Change-Id: I97177572fc025c5ab4361146253d7df9c487c291
2014-07-15 16:56:34 -07:00
jenkins-bot
b15bfd99a9 Merge "Generate thumbnails based on buckets" 2014-07-09 14:09:02 +00:00
Gilles Dubuc
7036e7b68d Generate thumbnails based on buckets
Instead of always generating thumbnails based on the original,
this adds the ability to generate thumbnails based on
references buckets. The buckets themselves have their
generation chained following the same process (smaller bucket
generated based on bigger bucket). In situations where no
suitable bucket is found, the original is used, like it used to.

This is entirely optional, as most non-WMF wikis would probably prefer
to keep generating all thumbnails based on originals.

The quality implications have been verified through a survey
aimed at Commons users and people actually preferred the chained version.
Presumably due to the multiple passes of sharpening which maintained
visual details better for small thumbnail sizes.

Change-Id: I285d56b2024c81365247338f85c1e0aa708cb21e
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/600
Bug: 67525
2014-07-08 20:03:38 +00:00
Brian Wolff
6f8342ed29 Some doc fixes to MediaHandler. No code changes
Change-Id: I2d79fce7aa55b9a0f2988c09a55594db4e8849f1
2014-06-20 00:45:07 +00:00
jenkins-bot
edbb233e25 Merge "Reduce some code duplication" 2014-05-30 17:48:45 +00:00
Gergő Tisza
93c0954750 Allow media handlers to mark files as expensive
Allows media handlers to signal that thumbnail generation
for this file is expensive and should be throttled more agressively.
For now this is only done for large TIFF files.

Bug: 65691
Change-Id: I01b34a1d46745649f179fdee435a8cfb19c5474e
2014-05-28 20:24:31 +00:00
Brian Wolff
d6b6f54caf Reduce some code duplication
MediaHandler::getLongDesc and getGeneralLongDesc have same
implementation, so forward one method to the other. Same for
short.

Also get rid of one unnecessary $wgLang global usage.

Change-Id: I688e27ce2b9cf950defa16ec6bce2e52c5959b03
2014-05-26 14:57:04 -03:00
Brian Wolff
4b0026c692 Fix doc comments on get[General](Short|Long)Desc
Follow up f3cc3980bc where somehow I managed to do this.

Change-Id: I25e5a01ddbecd1a991f6d121a7ac3f3598004b25
2014-05-24 16:10:46 -03:00
umherirrender
23bb3d1cb4 Follow-Ups to "Fixed some @params documentation"
Fix of inline comments of the following patch sets:
Follow-Up: I0056b4a8df243cfc0c5f25378de48f7a35170aca
Follow-Up: I7f605aa9e117b5fd80d9b1440864fe526d2b14a5
Follow-Up: I3622f216a2ca8ac1b5e51892be9f98665f65bc36
Follow-Up: I6627ba0e76d3577c40bf2473e0f78a5ad7368634
Follow-Up: Id75b5ecf648ca50f955b3bde3307c82c4366b102
Follow-Up: I4ca5231119f33039d91da3b57a41cd40719a576b

Change-Id: Id9bbe84b2820e9db44af5783411e955f55f643d4
2014-04-23 13:39:49 +02:00
umherirrender
8ad1c92441 Fixed some @params documentation (includes/*)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: I7f605aa9e117b5fd80d9b1440864fe526d2b14a5
2014-04-20 21:16:57 +02:00
Brian Wolff
8d0f7a0ec3 Add default implementation of getLength to base MediaHandler class
It was being called in File::getLength, but was only implemented
in a subclass, that's not even in core. Any method of a handler
class called from a method in File class should work on any
subclass of MediaHandler.

Change-Id: I94eda90ec3dd64b6ff2e3a5732aa539366cec521
2014-03-24 00:05:39 -03:00
umherirrender
2e871f7087 Fixed spacing
- Removed double spaces in arrays
- Added space after for
- Added spaces around string concat

Change-Id: Ifbcaf35f9bfef1f97226a38b5bd74c237f61c99e
2013-12-15 20:56:09 +01:00
Siebrand Mazeland
a521ef001e Make visibleMetadataField protected
Related patch sets:
* https://gerrit.wikimedia.org/r/#/c/99429/ Extension PagedTiffHandler

Change-Id: I0441fdf1ce1e06688f16c62e1993bb05911b45bc
2013-12-14 05:33:33 +00:00
Brian Wolff
751b9ebab8 Add method to get entire text layer. This could be useful for search
Change-Id: I22f5fc47aef3cf362cdf630980deea48fe531d45
2013-12-13 18:02:01 -05:00
Brian Wolff
d0c0bad56d Add UI to discover translated SVG files.
Currently we support rendering SVGs in multiple languages,
but there is no mechanism for users to discover what languages
a file is available in. Show this information on the image page.

At the moment, if unspecified we always default the language to
english (I believe to avoid mass cache splitting, especially
if most languages wouldn't have a translation of the file in
their language). This code was written in such a way so that
this assumption should be changable in the future if we so
desire.

Long term, Jarry has a super cool svg translation extension
which would take over some of this. However I still believe
we should have an interface for this in core, since we do
support the different language renderings in core.

Change-Id: I84506436514e09d71200aa2db3932aa001b55c71
2013-12-06 20:30:31 -04:00
Siebrand Mazeland
37bc4ec3dd Update documentation for media related classes
Change-Id: I7a9c8d59f88c68dc3835cb8a18f22a77cd7890fc
2013-12-06 23:03:06 +01:00
Antoine Musso
84c5ba6a1a media: limit size of stderr being logged
Whenever a rendering commands emit a ton of errors (spotted a case
generating 125MB), the call to trim() makes PHP copy the stderr which
might exhaust the remaining available memory.

The new constant MediaHandler::MAX_ERR_LOG_SIZE = 65535 is used to
substr() the error log before it get trimmed and logged.

bug: 57985
Change-Id: Ibd4cf0331529d323a68273163ac230b07a6c6108
2013-12-06 18:27:42 +01:00
Antoine Musso
96ddd951fb generalize BitmapHandler::logErrorForExternalProcess
BitmapHandler::logErrorForExternalProcess is a wrapper around
wfDebugLog( 'thumbnail' ). It got copy pasted from some other class at
one point.

This patch move the method up to general class MediaHandler and makes
other child class uses it.  The method will thus be available to
extensions such as TimedMediaHandler.

The reason I am doing that is that trim($err) generates a copy of $err
which causes a memory allocation fatal error whenever $err is larger
than the remaining memory allocatable.  The patch will let us fix the
bug by only altering one part of the code.

bug: 57985
Change-Id: I5657f07d6e2cca05d53f2a5c30ec23622c171343
2013-12-06 18:21:58 +01:00
Siebrand Mazeland
8ee54ec5d1 Declare visibility on class property of MediaHandler
Change-Id: I95785992372a0f189b4543345ec1c040a4a7f7e4
2013-12-05 14:25:25 +01:00