Fetch the extended metadata for every image, and if the NonFree key
(provided by CommonsMetadata) is present, rank down the image.
The check is run on LinksUpdate so changes to image copyright
templates won't have effect until the page is reparsed.
Unlike other weights, the work of extracting the weight factor from
the file/page is wholly done on LinksUpdate, instead of doing most
of it on parse and storing as ParserOutput extension metadata.
This is to avoid getting the article page parsing and the file
description page parsing conflicting with each other.
Bug: T124225
Change-Id: I21111ecbc80ded864806a2a93002f3254c3c68a9
User::getOption() already handles that, and this code bypassed the hook
in User::getDefaultOptions().
Change-Id: I41f9df177988dffd62de0060cb691a97161729e4
This patch only moves existing code around, but does not change any
implementation detail.
I found it very suprising that all code called by these two hook handlers
is 100% exclusive to these hook handlers. There is zero interaction
between these hook handlers code and all other code. Why is it in the
same file then? And why is it all static? It doesn't have to be. I
had to change literally nothing, except cutting and pasting, removing
all "static" and replacing all "self::..." with "$this->...". That's
all.
Change-Id: I7fdc582db425d3b95f7d02934b439eb9c102e712
This patch only moves existing code around, but does not change any
implementation detail.
I found it very suprising that all code called by this hook handler
is 100% exclusive to this hook handler. There is zero interaction
between this hook handlers code and all other code. Why is it in the
same file then? And why is it all static? It doesn't have to be. I
had to change literally nothing, except cutting and pasting, removing
all "static" and replacing all "self::..." with "$this->...". That's
all.
Change-Id: I5ffe6fdf4e57135e6f3b32636c80f22be758607c
This adds a few very basic tests to this component. I started doing this
while working on T112865 but later realized I do not need to touch this
extension. However, I started setting up tests and wanted to submit them.
Bug: T112865
Change-Id: I9d00b2baed8da97ffb6af94a6e3b8b63621b876a
Titles that correspond to foreign files aren't included in the set of
titles returned by ApiPageSet#getGoodTitles. However, since
ApiQueryPageImages#execute finds files with wfFindFile, these "missing"
titles can be included.
Add the ApiQueryPageImages#getTitles helper function, which returns the
set of "good" titles union the set of missing titles in the File
namespace.
Also, register the PHPUnit tests directory in the UnitTestsList hook
handler.
The original version of this patch was reverted due to a (stupid) bug
wherein a fatal error was triggered because there was no check for there
being no missing titles in the File namespace [0] and, consequently, an
invalid operand was being passed to the array union operator. This bug
is fixed as well as proven to work with a simple set of test cases.
[0] https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FPageImages.git/47137e7ee671c89667d620bc04ac7649b1d9af96/ApiQueryPageImages.php#L31
Bug: T98791
Bug: T114417
Change-Id: I923e88dde3a8ced4921b4192d90b4f3dc4b19e7b
Fatal error: Invalid operand type was used: cannot perform this operation with arrays
This reverts commit 47137e7ee6.
Bug: T114417
Change-Id: I89a2bfd69775a698f3000f48ea85465e193fb095
Titles that correspond to foreign files aren't included in the set of
titles returned by ApiPageSet#getGoodTitles. However, since
ApiQueryPageImages#execute finds files with wfFindFile, these "missing"
titles can be included.
Add the ApiQueryPageImages#getTitles helper function, which returns the
set of "good" titles union the set of missing titles in the File
namespace.
Bug: T98791
Change-Id: I6ef9a925c749ed6c830c0ff9bb824753df65740a