Commit graph

97 commits

Author SHA1 Message Date
jenkins-bot
9d8954a372 Merge "build: Upgrade phan to 0.9.0" 2019-12-09 16:15:27 +00:00
Daimona Eaytoy
ce0856b12f Fix more scalar types in docblocks
Change-Id: I574d4e261ab986e028c3ce26c4f0ec648b88a2ac
2019-12-08 17:59:08 +00:00
Daimona Eaytoy
598c4d7fcb build: Upgrade phan to 0.9.0
Scalar casts are still allowed (for now), because there's a huge amount
of false positives. Ditto for invalid array offsets.

Thoughts about the rest: luckily, many false positives with array offsets
have gone. Moreover, since *Internal issues are suppressed in the base
config, we can remove inline suppressions.

Unfortunately, there are a couple of new issues about array additions
with only false positives, because apparently they don't take
branches into account.

Change-Id: I5a3913c6e762f77bfdae55051a395fae95d1f841
2019-12-07 20:16:19 +00:00
jenkins-bot
e185eb21cf Merge "media: Log and fail gracefully on invalid EXIF coordinates" 2019-11-29 21:53:03 +00:00
Thiemo Kreuz
f6787ede2d media: Log and fail gracefully on invalid EXIF coordinates
The $coord value is a value extracted from the EXIF section of an
image file. We expect it to be a float, but there is no guarantee this
is the case. It could, for example, be an empty string.

I suggest this trivial fix. It does have the following effects:
* Instead of logging a PHP notice when floor() hits something that is
  not a number, I try to log something that's more useful for later,
  more in-depth debugging. Note this log call isn't necessarily meant
  to stay, but to find an even better fix for this issue.
* I return the string as it is. If it's "foo", the user will see "foo"
  instead of "0° 0′ 0″ N", which wasn't helpful.

Also note how wrong and misleading the PHPDoc block for this function
was.

Bug: T226751
Change-Id: I1ca98728de4113ee1ae4362bd3e62b425d589388
2019-11-29 14:08:01 +01:00
Umherirrender
c7ad21c25f Improve param docs
Change-Id: I746a69f6ed01c3ff000da125457df62b02d13b34
2019-11-28 19:08:59 +01:00
Daimona Eaytoy
e70b5b3309 Unsuppress other phan issues (part 4)
Bug: T231636
Depends-On: I58e67c2b38389df874438deada4239510d21654f
Change-Id: I6e5fba7bd273219b1206559420b5bdb78734aa84
2019-08-31 17:13:39 +00:00
Derk-Jan Hartman
7c68604e4c Recognize exif values for Apple iOS photo modes
CustomRendered value 2-8 are used by Apple to indicate the processing
modes used like HDR, Portrait and Panorama.

Bug: T231385
Change-Id: I767a81a8bebdf25c230b104d35236a4b38cbe4ed
2019-08-27 20:37:02 +00:00
Thiemo Kreuz
3a66680ec5 Simplify a few list() that only care about the first element
The nice thing about explode() is that the resulting array is
guaranteed to contain at least one element. The array can not be
empty.

In some of these cases it might be possible to use strstr() instead,
but that returns an empty string when the needle character is not
found. explode() returns the original string in this case.

Change-Id: I6ad1f3273defeaf36e2305fd871eaaf9d3c1e134
2019-05-17 16:54:47 +02:00
Aryeh Gregor
90d4f56fe4 Mass conversion of $wgContLang to service
Brought to you by vim macros.

Bug: T200246
Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
2018-08-11 22:44:29 -06:00
Fomafix
6866cfec37 Simplify PHP by using ?? and ?:
Also remove not necessary surrounding parentheses.

Change-Id: I0eb5c9c1bdfb09a800258379cdcefb5fd4d3d21c
2018-07-10 20:03:17 +00:00
Edward Chernenko
0a4a274b62 Fix PHP7 warning "non well formed numeric value encountered"
PHP 7.1 warns when non-numeric string is implicitly cast to integer.

Change-Id: Ia46ea793e9495548c7d421b3372f6deaeda163f5
2018-06-26 01:46:47 +03:00
Edward Chernenko
d88e924b6e Fix PHP warnings "preg_replace(): [...] invalid range in character class"
This was spotted when running tests on Travis (PHP 7.3 nighly, trusty).

Two expressions inside preg_replace() contained non-escaped "-" inside [],
where this "-" meant an actual "-" character.
The warning is because "-" has special meaning inside [] ("a-z" for range),
and things like [\w-.] are considered "invalid range".

Solution is to escape "-" like this: [\w\-.]

Change-Id: I41cc217081f00f54d957b6d8052ee209412f5ff6
2018-06-19 00:11:33 +00:00
Bartosz Dziewoński
4fd27f006f Use PHP 5.6 '**' operator instead of 'pow()' function
Change-Id: Ieb22e1dbfcffaa4e7b3dcfabbcc999e5dd59a4bf
2018-05-30 18:05:19 -07:00
Kunal Mehta
e0193327bd Fix MediaWiki.Commenting.LicenseComment.InvalidLicenseTag errors
Change-Id: I936c3f5fca1a0061f215e80469f5d882cb32ee29
2018-05-23 16:23:42 -07:00
Mark A. Hershberger
47a7977b15 Make FormatMetadata::flattenArrayReal() work for an associative array
Bug: T87572
Change-Id: I19490ebbbdc3613ae2116c6890ca470bb9f332db
2018-01-05 17:31:38 +00:00
Sébastien Santoro
241e741377 media: Ensure there ie enough data to extract software version
The Software EXIF / other metadata field was expected to contain
the software name followed by the version number.

There are occurences in Wikimedia production logs of errors showing
that's not always the case.

Bug: T178130
Change-Id: I4187a41b5fd8d7b5574ab50523668d8feb11bccc
2017-12-06 21:16:17 +00:00
Brad Jorsch
2c34fd6e0e Replace uses of each()
It's deprecated in PHP 7.2, may as well replace it now.

I note that, contrary to claims at
https://wiki.php.net/rfc/deprecations_php_7_2#each, none of our uses
were trivially replaceable with foreach.

* wfArrayDiff2_cmp() is processing two arrays by value in parallel.
* MagicWordArray::parseMatch() is doing something funky with the data
  structure returned by preg_match().
* HashRing was using it like "nextKey()", replaced with calls to key()
  and next().
* FormatMetadata and IndexPager were both using it as a shorter way to
  get both key() and current() for the first element in the array. I
  suppose a foreach(){ break; } would do the same, but that's confusing.

Bug: T174354
Change-Id: I36169a04c764fdf1bfd6603395111c6fe0aae5eb
2017-09-20 09:51:28 -04:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
jenkins-bot
171255101f Merge "Use file width/height instead of metadata for getContentHeaders" 2017-05-24 06:44:54 +00:00
Kunal Mehta
e37a7f257a media: Avoid deprecated wfMemcKey()
And ObjectCache::getMainWANInstance() while we're at it.

Change-Id: Ib22bd134c3faa56f8d8f111bb9ed99d826cbed40
2017-05-23 21:01:09 -07: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
Kunal Mehta
a57b64436c Use wikimedia/timestamp
Bug: T100924
Depends-On: I0a067367cda6885fa45631ed7c18799d653dc9bf
Change-Id: I69ba64e364df8af089c1c918cdf32f99454e693a
2017-02-28 21:15:38 -08:00
umherirrender
34fe90ac52 Remove empty lines at end of functions
It looks like there is something missing after the last statement
Also remove some other empty lines at begin of functions, ifs or loops
while at these files

Change-Id: Ib00b5cfd31ca4dcd0c32ce33754d3c80bae70641
2016-11-05 11:55:10 +01:00
Bartosz Dziewoński
d0243c22ba FormatMetadata: Do not format 'UserComment' as a number
It's a freeform text field.

Change-Id: Ic3150f48c2e38fa26728bc22017b992d8ddfd152
2016-10-31 13:51:12 +01:00
Kevin Israel
890c82f419 FormatMetadata: Use binary integer literals instead of bindec()
We can do this now that we have dropped support for PHP 5.3.

Change-Id: I1e78249e244105496e976bf01e35f4067410b2f0
2016-06-14 00:26:29 -04:00
Bartosz Dziewoński
fed31bdc92 FormatMetadata: Fix comment indentation and whitespace
Change-Id: I55d2e6fd160c84208fb323b4c1d31f3291ed12f2
2016-06-13 21:26:39 +02: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
Brian Wolff
c716958795 Support all values for exif PhotometricInterpretation
I just happened to notice that it wasn't displaying properly on
File:Great_falls_of_the_potomac_river_washington_dc.tif .
The original implementation only used values found in JPEG images,
extend it to all allowed values in tiff files.

See http://www.awaresystems.be/imaging/tiff/tifftags/photometricinterpretation.html
for what the values mean

Change-Id: I31b78d093668cec076b7f3599acee528229737f6
2015-11-04 13:44:37 -07: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
Legoktm
41c7da93e2 Revert "Add // @codingStandardsIgnoreFile to FormatMetadata"
For testing.

This reverts commit df706d2457.

Change-Id: If63199293ac3539030f3503fbcbd5e0f4aa2eece
2015-10-14 09:38:30 +00:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
Kunal Mehta
df706d2457 Add // @codingStandardsIgnoreFile to FormatMetadata
PHPCS can't handle the level of nesting in this file and the tokenizer
dies.

Change-Id: Ib660e034ad21202303dd443e573e54dd8ed05a43
2015-09-25 10:56:57 -07:00
Jackmcbarn
c4f69827bc Fix some PHPCS issues
Change-Id: I6289ce362f8dfde7baf2b665f082820898844973
2015-06-26 01:32:28 -04:00
umherirrender
70f3afd548 Remove unneeded empty lines at begin of if/else/foreach body
An if body must not begin with an empty line

Change-Id: I62b058be337fcc85a120fcd3dadce564db59a271
2015-06-19 20:05:45 +02:00
Alex Monk
e7c9096ecc HTTPS-ify links to Wikimedia's sites in MW core source
See https://blog.wikimedia.org/2015/06/12/securing-wikimedia-sites-with-https/

Ignoring SVN stuff because svn.wikimedia.org's SSL certificate has expired, and
ignoring wgSharedUploadPath because T25122 wants to get rid of it.

Also a couple of BZ -> phab changes

Change-Id: I02fd23ac6c30a4a4c718e57d4dedbc693dd653c0
2015-06-13 19:23:23 +01:00
Brad Jorsch
cd56c087a4 Protect API metadata keys from FormatMetadata::fetchExtendedMetadata()
Bug: T97469
Change-Id: If5d101231ca913621c88e6683f6ef07f6dae1ee8
2015-04-28 16:34:03 -04:00
Thiemo Mättig
e90513c5cd Drop unused FormatMetadata::flattenArray method
This is a pure helper method, not closely related to this class, and
currently unused.

Change-Id: I278058677ad407aae8cd2ba8fe34c12b1e86033f
2015-04-20 15:41:28 +02:00
Gergő Tisza
25e226b652 Ignore EXIF data in FormatMetadata::fetchExtendedMetadata()
fetchExtendedMetadata() gets extra data such as file templates
via the GetExtendedMetadata hook; keys which are absent in the
extended data default to their EXIF value.

This turned out to be a bad idea as EXIF data is too messy in
practice with various devices putting e.g. manufacturer name for
author name; completely ignoring EXIF data in the extmetadata API
is still the better option.

Bug: T73719
Change-Id: I77b1df67d08097504b3b1026c584063488e03b6e
2015-01-14 03:04:02 +00:00
Ricordisamoa
2ae155da52 Fix phpcs errors in includes/
Mostly Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines

Change-Id: I678b2f0902f11cd1dfa1611b9da24e7237df9122
2015-01-08 20:15:07 +01:00
Chad Horohoe
aa21e125a3 Remove obvious function-level profiling
Xhprof generates this data now. Custom profiling of various
sub-function units are kept.

Calls to profiler represented about 3% of page execution
time on Special:BlankPage (1.5% in/out); after this change
it's down to about 0.98% of page execution time.

Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
2015-01-07 11:14:24 -08: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
Gergő Tisza
b8d2ca8020 FormatMetadata::fetchExtendedMetadata: Ignore multiple EXIF/XMP values
Ignore all but the first value of multivalued metadata fields. Before
this, the function returned an array of values for such fields,
causing various errors.

Bug: 72652
Change-Id: I0fd22b78e4938eecc506d870e352b3b196ee3ace
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/973
2014-11-12 19:10:05 +00: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
umherirrender
0c1b1f8cfb Remove @private/@public/@void where visibility already set
When private is set php side on the function, no need to have it in the
param docs.

Change-Id: Ieaeac99c131b7360b1f324244d8be6f9ff854dd2
2014-07-04 22:41:05 +02:00
umherirrender
2df720d88b Remove deprecated class FormatExif
Deprecated and warnings since 1.18

Change-Id: I2461383bb2d3c5fc00ffb5f45bc8e931ed9acb58
2014-07-04 07:12:59 +00: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
Siebrand Mazeland
37bc4ec3dd Update documentation for media related classes
Change-Id: I7a9c8d59f88c68dc3835cb8a18f22a77cd7890fc
2013-12-06 23:03:06 +01:00
Siebrand Mazeland
a5519e4b4a Declare visibility on class property of FormatExif
Change-Id: Id5e7b3d29035946e44a0dd5939b9daec2e99aad0
2013-12-05 14:58:02 +01:00