| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Almost every other media type prefer physicalWidth over width param
except SVG because it wasn't really needed and svg has a dedicated
::makeParamString() function that doesn't call its parent.
This is making steps not work for SVG files.
Locally worked just fine and fixes the issue.
Bug: T360589
Change-Id: Ifcd1693262b64256e310e68d93fc08af5b6e83df
|
|
|
|
| |
Change-Id: Id175a83e71cc910eaee5d5890a9106872a3ca3b8
|
|
|
|
|
|
|
| |
Changes to the use statements done automatically via script
Addition of missing use statement done manually
Change-Id: Id9f3e775e143d1a17b6b96812a8230cfba14d9d3
|
|
|
|
|
|
|
|
| |
When symlink fails there is a E_WARNING,
for example about "Permission denied"
Mostly on windows
Change-Id: If450c3ade69cca7dc1130c60a5bb5ee7e669d289
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
| |
Introduce new classes for checked exceptions.
Bug: T328220
Change-Id: Idbcdc09647a857e359e41ecec98212a8937c5c2e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add wgSVGNativeRendering to allow clientside rendering of SVG files
Default is false. When enabled with true, will serve ALL SVG files
as is to the browser.
When set to the string 'partial' it will conditionally serve SVG
files based on criteria. Currently it will force PNG rasterization
for translated SVGs and for SVGs over wgSVGNativeRenderingSizeLimit
wgSVGNativeRenderingSizeLimit is a byte size limit to avoid larger
SVG files (potentially much bigger than a PNG) from being served
directly to browser.
Native SVG rendering does not provide PNG fallback. SVG support in
browsers has evolved far enough that this should rarely be a problem.
Bug: T208578
Change-Id: I9647fdd72f868c821eb20f67b239826f23655a1c
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit 42aa5f9481433b5574fc4ff6bd4ea832c24adba0.
Reason for revert: Caused T334753, the proposed fix may need more time for review. Let's revert for now, before the train cut.
Bug: T310453
Bug: T334753
Change-Id: I790604eef00491b7f2a921fb3423a2f727f6593b
|
|
|
|
|
| |
Bug: T310453
Change-Id: I45e495d2c4fc026bdfc54e3219ff7138789d25dd
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- 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
|
|
|
|
|
| |
Bug: T308395
Change-Id: Iba162479ffdae69817debfb57e553edbd9cda208
|
|
|
|
|
|
|
|
| |
This patch only adds and removes suppressions, which must be done in the
same patch as the version bump.
Bug: T298571
Change-Id: I4044d4d9ce82b3dae7ba0af85bf04f22cb1dd347
|
|
|
|
|
|
|
|
|
|
|
|
| |
The static function isWellFormedLanguageTag is related to BCP 47
language codes not to the internal language codes or language names.
The new function LanguageCode::isWellFormedLanguageTag uses type hints.
THe explicit type cast (bool) is not necessary anymore.
The old function Language::isWellFormedLanguageTag is now deprecated.
Change-Id: I6431dbd82ed6dfcc2a7c3495eca025506551db05
|
|
|
|
|
|
|
|
|
|
|
| |
This adds support for languages that the SVG uses but that MediaWiki
does not support. It might not be able to find the correct
languagename for that language code, specifically for als.
Add some paramString parsing testcases
Bug: T279874
Change-Id: Id8a62e2a9c5e1565f173b1bba466306741b62762
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The default for multilanguage SVGs is the content language. In order
to show element with no explicit language, you have to request the
'und' aka undetermined language.
Because this was not special cased, this was not accessible and would
always fallback to English.
Make the default language code a const.
Bug: T310235
Change-Id: I6941f46d176ddf3dc811b29d580b1c5b8856eb1c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
File::getMatchedLanguage does not produce any useful return with null,
because the implementation in SvgHandler::getMatchedLanguage returns
null as well, null never matched with anything using strcasecmp
Bypass the call if no language is requested and adjust the documentation
This also avoids passing null to internal functions,
which gets deprecated in newer php
Bug: T309426
Bug: T289926
Follow-Up: I1d8ec00a0040c7cbebe705012ca99f1e9f613e7f
Change-Id: I028b519de20dafad7a872c79343e76991ef544d0
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Symlinks are lightweight and ideal, but some systems may not allow
them.
Instead of failing outright, an attempt should be made to copy the
file and, only if that also fails, declare that the thumbnail creation
has failed.
Bug: T227157
Change-Id: I50765ab125d775b9ef77613776f8d58da459c496
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
|\ \ |
|
| | |
| | |
| | |
| | |
| | |
| | | |
Add missing @return and use false instead of bool where possible
Change-Id: Ie85a40987422e32aa02c56969e103371ec2e5b5f
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| | |
Make phan stricter about conditional variable declaration
Remaining false positive issues are suppressed.
The suppression and the setting change can only be done together
Bug: T259172
Change-Id: I1f200ac37df7448453688bf464a8250c97313e5d
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Make phan stricter about null types by setting null_casts_as_any_type to
false (the default in mediawiki-phan-config)
Remaining false positive issues are suppressed.
The suppression and the setting change can only be done together
Bug: T242536
Bug: T301991
Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
|
| |
| |
| |
| |
| |
| | |
Found by phan strict checks
Change-Id: If41d16b473baddd92cc4261cdc2bfbe65fedcb19
|
| |
| |
| |
| | |
Change-Id: I2eb133a9e32116cd155f59086245bc4d15ecbfcc
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The order of applying the different operations matters in Imagick. We
should set the background before adding the SVG, or the transparency
will get lost.
This is also mentioned in a comment of
https://www.php.net/manual/en/imagick.setbackgroundcolor.php
Fix thanks to User:TheAlmightyGuru
Bug: T301242
Change-Id: Idf8e4da6bfae149b3bd2be04a0ae490122173215
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Don't catch and discard exceptions from the RequestTimeout library,
except when the exception is properly handled and the code seems to be
trying to wrap things up.
In most cases the exception is rethrown. Ideally it should instead be
done by narrowing the catch, and this was feasible in a few cases. But
sometimes the exception being caught is an instance of the base class
(notably DateTime::__construct()). Often Exception is the root of the
hierarchy of exceptions being thrown and so is the obvious catch-all.
Notes on specific callers:
* In the case of ResourceLoader::respond(), exceptions were caught for API
correctness, but processing continued. I added an outer try block for
timeout handling so that termination would be more prompt.
* In LCStoreCDB the Exception being caught was Cdb\Exception not
\Exception. I added an alias to avoid confusion.
* In ImageGallery I added a special exception class.
* In Message::__toString() the rationale for catching disappears
in PHP 7.4.0+, so I added a PHP version check.
* In PoolCounterRedis, let the shutdown function do its thing, but
rethrow the exception for logging.
Change-Id: I4c3770b9efc76a1ce42ed9f59329c36de04d657c
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| |
| |
| | |
Bug: T254646
Change-Id: I2b120f0b9c9e1dc1a6c216bfefa3f2463efe1001
|
| |
| |
| |
| | |
Change-Id: Ieefa5bbfddb803ceb41196725c1f344f175c10c3
|
| |
| |
| |
| | |
Change-Id: Ic04d4dea86e61fb07b2a3b17acb6021fab6ae5ee
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Image metadata is usually a serialized string representing an array.
Passing the string around internally and having everything unserialize
it is an awkward convention.
Also, many image handlers were reading the file twice: once for
getMetadata() and again for getImageSize(). Often getMetadata()
would actually read the width and height and then throw it away.
So, in filerepo:
* Add File::getMetadataItem(), which promises to allow partial
loading of metadata per my proposal on T275268 in a future commit.
* Add File::getMetadataArray(), which returns the unserialized array.
Some file handlers were returning non-serializable strings from
getMetadata(), so I gave them a legacy array form ['_error' => ...]
* Changed MWFileProps to return the array form of metadata.
* Deprecate the weird File::getImageSize(). It was apparently not
called by anything, but was overridden by UnregisteredLocalFile.
* Wrap serialize/unserialize with File::getMetadataForDb() and
File::loadMetadataFromDb() in preparation for T275268.
In MediaHandler:
* Merged MediaHandler::getImageSize() and MediaHandler::getMetadata()
into getSizeAndMetadata(). Deprecated the old methods.
* Instead of isMetadataValid() we now have isFileMetadataValid(), which
only gets a File object, so it can decide what data it needs to load.
* Simplified getPageDimensions() by having it return false for non-paged
media. It was not called in that case, but was implemented anyway.
In specific handlers:
* Rename DjVuHandler::getUnserializedMetadata() and
extractTreesFromMetadata() for clarity. "Metadata" in these function
names meant an XML string.
* Updated DjVuImage::getImageSize() to provide image sizes in the new
style.
* In ExifBitmapHandler, getRotationForExif() now takes just the
Orientation tag, rather than a serialized string. Also renamed for
clarity.
* In GIFMetadataExtractor, return the width, height and bits per channel
instead of throwing them away. There was some conflation in
decodeBPP() which I picked apart. Refer to GIF89a section 18.
* In JpegMetadataExtractor, process the SOF0/SOF2 segment to extract
bits per channel, width, height and components (channel count). This
is essentially a port of PHP's getimagesize(), so should be bugwards
compatible.
* In PNGMetadataExtractor, return the width and height, which were
previously assigned to unused local variables. I verified the
implementation by referring to the specification.
* In SvgHandler, retain the version validation from unpackMetadata(),
but rename the function since it now takes an array as input.
In tests:
* In ExifBitmapTest, refactored some tests by using a provider.
* In GIFHandlerTest and PNGHandlerTest, I removed the tests in which
getMetadata() returns null, since it doesn't make sense when ported to
getMetadataArray(). I added tests for empty arrays instead.
* In tests, I retained serialization of input data since I figure it's
useful to confirm that existing database rows will continue to be read
correctly. I removed serialization of expected values, replacing them
with plain data.
* In tests, I replaced access to private class constants like
BROKEN_FILE with string literals, since stability is essential. If
the class constant changes, the test should fail.
Elsewhere:
* In maintenance/refreshImageMetadata.php, I removed the check for
shrinking image metadata, since it's not easy to implement and is
not future compatible. Image metadata is expected to shrink in
future.
Bug: T275268
Change-Id: I039785d5b6439d71dcc21dcb972177dba5c3a67d
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
|\ \ |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This includes fixing some mistakes, as well as removing
redundant text that doesn't add new information, either because
it literally repeats what the code already says, or is actually
duplicated.
Change-Id: I3a8dd8ce57192deda8916cc444c87d7ab1a36515
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
* Use false instead of bool in PHPDocs, because that's the only bool
value that's allowed.
* This patch also fixes DjVuHandler::getPageText() not returning
strings, but XML objects. This kind of "worked" because all consuming
code magically casts these to strings. But this is an actual violation
of the contract of the method. This is also why the test was doing this
weird (string) cast, instead of actually testing the type of the return
value.
Change-Id: I00db6b910f1de6d37a80543b8a5dd5ea3bab3c76
|
|/ /
| |
| |
| | |
Change-Id: I4e4d779230b8151500ed828c5a9554274c739811
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| |
| | |
Change-Id: I2bf5543b99dc2ae05f7de02940d120dee353adfe
|
| |
| |
| |
| | |
Change-Id: I80ec7aa44b1ea5e7b7d6193732b7da03d7f11960
|
| |
| |
| |
| | |
Change-Id: Iad3375b141b1d87c890baec6ecd16ed92f93e699
|
|\ \ |
|
| |/
| |
| |
| | |
Change-Id: Id326fb2a54aac62cb27aa7045082924b5cd84940
|
|/
|
|
|
|
|
| |
Use SVGReader->getMetadata() directly. Also rename the test,
because it covers the implementation and not the wrapper.
Change-Id: I61565c6aadc6d1c1e942b9bc4555ef4aeb09e5d8
|
|
|
|
| |
Change-Id: I4046d593d1450cfffc489ca2abadba1084a540e4
|
|
|
|
| |
Change-Id: I9a97325d738d09370d29d35d5254bc0dadc57ff4
|
|
|
|
|
|
|
|
|
| |
Proof this method is really not called from anywhere else, except the
ImageHandler class itself, and one subclass:
https://codesearch.wmflabs.org/search/?q=%5CSgetScriptParams&i=1
Change-Id: I57e75ce0cb7c9e52d545b8e8226610bcc6e06c44
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, they were always displayed in defult language unless
forced explicitly in wikitext, e.g. [[File:Foo.svg|lang=ru]].
This change adds a feature flag that would enable always trying to
display in page language.
* If enabled, Parser will pass a new parameter - 'pagelang' - to
the media handler.
* SvgHandler uses page language when determining what language to
render the image in.
* 'pagelang' can always be overridden by 'lang'.
* If no translation in page language is available, the default
language (English) will be used for thumbnail URLs, to prevent
cluttering media storage and HTTP caches with useless copies.
Performance: this requires accessing image's metadata during parsing.
My testing indicates there were no code path where this wasn't the
case already, so no performance hit is expected, however we should
still keep an eye on page save performance.
Bug: T205040
Change-Id: I348840ef405e1370cc0c17d69051bce30153c9c0
|