Commit graph

109 commits

Author SHA1 Message Date
Thiemo Mättig 6c53cac48e Refactor duplicate code in LinksUpdateHookHandlerTest
Change-Id: I9acaadf18e859758cd7bdcb7d260007402695060
2016-03-10 16:27:40 +01:00
Gergő Tisza 151a5d7248 Add sanity check test for LinksUpdateHookHandler::getMetadata
Change-Id: I840902c8397c8442def8239504ce1cfa8eafbb8e
2016-03-07 22:53:00 +00:00
Thiemo Mättig 4fee70fc1f Remove not needed "return true" from hook handlers
* Do not "return true" in hook handlers. I was told it's good practice
  to either return false on failure, or nothing/null.
* Remove "static" from method that does not need to be static.
* Make some type hints more specific.
* Add missing imports. I wonder how this can work without the imports.
  My PHPStorm complains.

Change-Id: Ia0e980ff99f0e004d700b22dd07ff17f04bed4ec
2016-03-07 12:07:06 +01:00
Thiemo Mättig d9df7178a0 Extract LinksUpdateHookHandler to separate file
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
2015-12-30 13:40:48 +01:00
Thiemo Mättig 369eda24b8 Add missing and fix wrong @license tags
Change-Id: I07f77735bb0050e2e59491d3c045b11705f3a08f
2015-11-16 15:59:34 +01:00
Thiemo Mättig 1f1c72bb2c Use mExtensionData instead of undeclared class property
Change-Id: I155e37fda412cd467da7b34c52b34661c7c20224
2015-10-26 12:09:52 +01:00
Thiemo Mättig 23cf541f1b Add inline documentation and newlines for readability
Change-Id: I3a5a4ef67836cbfe0277f511f8b23030d248141c
2015-10-26 11:41:13 +01:00
Thiemo Mättig ccbee562f3 Add basic PHPUnit tests
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
2015-10-08 10:39:59 +02:00
Sam Smith 56243a6c65 Include foreign files in ApiQueryPageImages
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
2015-10-05 13:24:00 +01:00