Done automatically using the master version of MW codesniffer and
running composer fix.
Bug: T192167
Change-Id: If6b40f515fde32ab5eff074a90e821c30c791827
The immediate use case is for testing, where some tests need to use the
PHP implementation even when wikidiff2 is installed.
Bug: T237049
Change-Id: I41dc4c0933429065d7638f518ec31f0a056afc41
This commit splits changes from Ic14f5debc53e55d6714 to reduce it to
only strictly needed things. It can be merged immediately.
Bug: T192167
Change-Id: I8c541a66ea13421dbe7fa51d197d5455cc4786eb
The main purpose of this class is to generate filenames during
tests. The reason it doesn't use fixed filenames is not because
it wants to be a fuzzy test, but because it wants to allow
running against a development wiki (outside CI) multiple
times where one test may've failed and unable to clean up after
itself, or where you may've done something manually and thus
a conflicting file exists in the local wiki from before
the DB was cloned for testing.
Using dictionary based random names is needlessly complex,
and has the additional downside of actually not avoiding
conflicts very well.
Replace all this by using a timestamp instead, which is much
more stable over time and basically will never conflict with
itself unless two tests were run on the same machine and started
in the same second (or if the clock went backwards/broken).
That seems unlikely enough to not need to support magically.
But to counter-act it a bit still, also add a 3-char random hex
in front of it. This also helps with file listings so that
when you run it three times, it's easier to see the files generated
by the same run close to each other (by not having subsequent
tests start with a mostly identical prefix).
Bug: T222416
Change-Id: Iec1d89324ff2fa53d1712796157adaf4ed34bdfe
Languages with variants no longer can override the parent's constructor
(which is now used for injecting services). Instead, they need to
override Language::newConverter().
Bug: T201405
Change-Id: I923400d61763cf1db88cb0c3f684c9c10e58032d
RandomImageGenerator::getRandomLines() is trying to select a random
subset of lines from a dictionary file, but the algorithm has a few bugs
that cause it to potentially leave entries in the returned array as null
and to be biased against the first few lines in the file.
This patch corrects the bugs to implement a Fisher–Yates (or Knuth)
shuffle,[1] run in reverse so that N does not need to be known ahead of
time and only maintaining the desired subset of the array in memory.
In local testing over many trials, it has produced output without nulls
100% of the time and the aggregate results do not have any obvious bias.
[1]: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
Bug: T222416
Change-Id: If136928bda2165198d3957a3536de85d465321fc
This reverts commit 5f06efb318, which
reverted 9335363789, which makes
the deprecated property AbstractBlock::mReason private.
After 9335363789, AbstractBlock::mReason is obsolete, since the block
reason is now stored as a CommentStoreComment, AbstractBlock::reason.
Change-Id: Ica0a74be90383689ca8e4cfe6d0fb25c9a5942c5
This reverts commit 9335363789.
Reason for revert: It's full of code accessing AbstractBlock::mReason
out there, see [1]. Also, it was never hard deprecated. While that may
be acceptable under some circumstances, it's definitely not OK to remove
code when there are consumers around. I'd have fixed it right now without
reverting if it were a single repo, but there's just too many.
[1] - https://codesearch.wmflabs.org/search/?q=-%3EmReason&i=nope&files=&repos=
Change-Id: I8669f502b50cff89e28dada0f65fe2b130ae9b37
AbstractBlock::setReason now accepts a string, Message or
CommentStoreComment. The CommentStoreComment is accessed via
AbstractBlock::getReasonComment.
AbstractBlock::getReason returns the reason as a string, with
the language and format consistent with how block reasons were
built before this commit. This method is deprecated, since it
makes assumptions about the language and format needed. The
deprecated mReason property is no longer public.
Doing this (and T227005) will remove the implicit dependency of
BlockManager::getUserBlock on language, which causes a recursion
error if the block is checked before the user has loaded. It also
provides a mechanism for getting the block reason in a language
specified by the caller. (This does not apply to DatabaseBlock
reasons entered via the Special:Block form, which were not and
are still not translatable.)
This commit also updates authentication classes to return the
translated reason.
Bug: T227007
Change-Id: Iec36876e930dff96a256aebbdc39cbfb331c244e
Add public, protected or private to function missing a visibility
Enable the tests folder for the phpcs sniff
Change-Id: Ibefce76ea9984c47e08c94889ea2eafca7565e2c
These are static methods that have to do with processing language names
and codes. I didn't include fallback behavior, because that would mean a
circular dependency with LocalisationCache.
In the new class, I renamed AS_AUTONYMS to AUTONYMS, and added a class
constant DEFINED for 'mw' to match the existing SUPPORTED and ALL. I
also renamed fetchLanguageName(s) to getLanguageName(s).
There is 100% test coverage for the code in the new class.
This was previously committed as 2e52f48c2e and reverted because it
depended on e4468a1d6b, which had to be reverted for performance
issues. There should be no changes other than rebasing.
Bug: T201405
Change-Id: Ifa346c8a92bf1eb57dc5e79458b32b7b26f1ee8a
The description had two errors:
* It talked about the presence of a specific value, but all it did
was checking a count.
* It was talking about the value *not* being there.
I just removed it. The possible error message from PHPUnit should be
good enough.
Change-Id: I7ea85dd37db8969bdd120f9600eeb6145e42eb1e
The benefit of using count() is that the test would still succeed if
the return vfalue is not an array, but an iterable object. It seems
this is not needed.
Change-Id: I23529f6990aebe0cce86e236a21820fe74993204
The test fills $wgUrlProtocols with 86000 entries, forging oversized
strings which ends up eventually truncated to 100 bytes. The aim is to
overflow $wgAPIMaxResultSize to trigger an apiwarn-truncatedresult
warning.
The test takes 230 ms on my machine and when generating code coverage
almost a minute.
A faster approach is just to lower the $wgAPIMaxResultSize limit to
trigger the warning.
Test plan:
$ php tests/phpunit/phpunit.php \
tests/phpunit/includes/api/ApiQuerySiteinfoTest.php \
--filter testContinuation
Bug: T234016
Change-Id: I3dc96d394d8b98dda8f151d14544b829c92f9b10
These help making the code much more readable and explorable. IDEs
now allow to ctrl+click most of the methods to jump to their source.
Change-Id: If1e55fa549de27be2549f245eca6938ecd5cfd82
assertSame() is guaranteed to not do any type conversion. This can be
critical when acciden tially comparing, for example, 0 to 0.0.
Change-Id: Iffcc9bda69573623ba14af655dcd697d0fcce525
For efficient bulk querying, this means that
ApiQueryBase::showHiddenUsersAddBlockInfo() needs to return everything
needed by DatabaseBlock::newFromRow().
Since we're rewriting it anyway, we may as well also move
ApiQueryBase::showHiddenUsersAddBlockInfo() out into a trait of its own.
Bug: T232021
Change-Id: I9c5b17a232ecbfbffefc7e40608cf5684ce8a644
Currently, users who are partially blocked are prevented from deleting
revisions. The system should check to see if the user can edit the page.
Bug: T228486
Change-Id: Id08dfab9b0ebe9721d3552564ee9f9d1e1a4805a