We renamed many classes to be namespaced, but the `@covers` and
`@coversDefaultClass` annotations weren't updated properly.
PHPUnit didn't support short cover annotations with `use` statements,
these didn't trigger any errors yet, because they are class alias.
This patch is populated by a modified version of PhpunitAnnotationsSniff.
Change-Id: I6c602290a30099239b17d2dc0d67b1488b4eaeeb
Just methods where adding "static" to the declaration was enough, I
didn't do anything with providers that used $this.
Initially by search and replace. There were many mistakes which I
found mostly by running the PHPStorm inspection which searches for
$this usage in a static method. Later I used the PHPStorm "make static"
action which avoids the more obvious mistakes.
Bug: T332865
Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
Follows-up 3255f37af1 (Ibcd2c5365a1f581e), which introduced support
for subpage slashes and querystrings. Due to the order of operations,
it split off the subpage (including query) before the check for the
query, which meant it was actually encoded as part of the subpage.
The original unit test did expose this issue but the bug was part of
the expected value.
For example:
<https://en.wikipedia.org/wiki/Special:Contributions/JohnDoe%3FtopOnly%3D1>
vs
<https://en.wikipedia.org/wiki/Special:Contributions/JohnDoe?topOnly=1>
of which only the latter is identical to
<https://en.wikipedia.org/?title=Special:Contributions/JohnDoe&topOnly=1>
While at it, also improve readability and future-proof stability by
making the conditional check and the substring operation share the
same result directly instead of computing it three times. This avoids
future refacting causing the three lines to go out of sync in a way
that e.g. the subsequent strpos operations might find false which
would lead to an unpredictable outcome. Phan isn't able to catch this
yet, but probably will in the future, namely that strpos() can return
false which isn't a valid param to substr().
Change-Id: Iec00a6ecbf7abf57b8944e32a6256ac9db4a653b
Also, make use of MainConfigNames constants where necessary like in
HashConfig map.
NOTE: Since `wgConf` is not a setting, keep using `setMwGlobals()`
in this case.
Change-Id: I8d0c718fd02043835fe122d675cce3d759b30330
The files in `tests/phpunit/includes/` directory are now all
covered. Will do sub-directories of `/includes/` next.
Change-Id: I8d5655ce267b6d32cf3c7ee40dc5d2992631b5a6
This reverts commit c9c6bab379.
Reason for revert: This broke VisualEditor editing.
Not sure why but will repost in different format.
(https://phabricator.wikimedia.org/F35030276)
Change-Id: I7f21a2c756d06f488766896086e5b3488a366c19
According to the function signature of WatchedItemStoreInterface
a PageIdentity must provided. Any other parameter is deprecated.
The test is updated as it's trying to watch a special page and it's
not possible to watch special pages.
Change-Id: Ia97e497fbae922e46a1098bca32ad3d8d62070fa
Follows-up I361fde0de7f4406bce6ed075ed397effa5be3359.
Per T253461, not mass-changing source code, but the use of the native
error silencing operator (@) is especially useful in tests because:
1. It requires any/all statements to be explicitly marked. The
suppressWarnings/restoreWarnings sections encourage developers to
be "lazy" and thus encapsulate more than needed if there are multiple
ones near each other, which would ignore potentially important
warnings in a test case, which is generally exactly the time when
it is really useful to get warnings etc.
2. It avoids leaking state, for example in LBFactoryTest the
assertFalse call would throw a PHPUnit assertion error (not meant
to be caught by the local catch), and thus won't reach
AtEase::restoreWarnings. This then causes later code to end up
in a mismatching state and creates a confusing error_reporting
state.
See .phpcs.xml, where the at operator is allowed for all test code.
Change-Id: I68d1725d685e0a7586468bc9de6dc29ceea31b8a
There is a common and reasonable need for longer lines in tests.
The nudge for shorter lines doesn't seem valuable here. The natural
breaks will likely still fall in 80-100 given the enforced practice
for non-test code, e.g. whether through habit, or 80-100 column markers
in text editors, or the finite width of diff and code review
interfaces.
Change-Id: I879479e13551789a67624ce66f0946d2f185e6ee
When revisions have the same timestamp the rollback could be confused
about the order of both revisions.
Add additional order by rev_id as used in
RevisionStore::getRelativeRevision to fix this situation
mysql is ordering by the primary key in case of same values of an index,
using the same order, but postgres fails in this situation.
Bug: T195807
Bug: T218400
Change-Id: Id40f8351992de0fb747f09821de4e8463c8986d2
The following User methods, deprecated in 1.36, have been removed:
- ::isLoggedIn,
- ::getFirstEditTimestamp,
- ::getLatestEditTimestamp
Bug: T277511
Change-Id: I338ee9313e08bda8b22b683281dad3b0e616fd18
CommentParser:
* Move comment formatting backend from Linker to a CommentParser service.
Allow link existence and file existence to be batched.
* Rename $local to $samePage since I think that is clearer.
* Rename $title to $selfLinkTarget since it was unclear what the title
was used for.
* Rename the "autocomment" concept to "section link" in public
interfaces, although the old term remains in CSS classes.
* Keep unsafe HTML pass-through in separate "unsafe" methods, for easier
static analysis and code review.
CommentFormatter:
* Add CommentFormatter and RowCommentFormatter services as a usable
frontend for comment batches, and to replace the Linker static methods.
* Provide fluent and parametric interfaces.
Linker:
* Remove Linker::makeCommentLink() without deprecation -- nothing calls
it and it is obviously an internal helper.
* Soft-deprecate Linker methods formatComment(), formatLinksInComment(),
commentBlock() and revComment().
Caller migration:
* CommentFormatter single: Linker, RollbackAction, ApiComparePages,
ApiParse
* CommentFormatter parametric batch: ImageHistoryPseudoPager
* CommentFormatter fluent batch: ApiQueryFilearchive
* RowCommentFormatter sequential: History feed, BlocklistPager,
ProtectedPagesPager, ApiQueryProtectedTitles
* RowCommentFormatter with index: ChangesFeed, ChangesList,
ApiQueryDeletedrevs, ApiQueryLogEvents, ApiQueryRecentChanges
* RevisionCommentBatch: HistoryPager, ContribsPager
Bug: T285917
Change-Id: Ia3fd50a4a13138ba5003d884962da24746d562d0
Tests added:
* formatLinksInComment test case for a missed branch
* makeCommentLink
* commentBlock
* revComment
Bug: T289998
Change-Id: I3ffe7ef5a385f8c29d0d3f205130ab5b6d35e37c
IP range needs to be explicitly tested for as it will not be
covered by both UserNameUtils::isIP and IPUtils::isValid calls.
Bug: T274526
Change-Id: Ib3498530e5ea9589117a7037ee836557f3800abc
Add a new tooltip message that displays the remaining watch period of a
page, if it is being watched temporarily. The tooltip message remains
the same if it is being watched indefinitely.
Bug: T250215
Change-Id: Ic9d1301427d477de71fb6f63fe77554a33684cd1
Create a small "curate"-related bundle of moderation and review
enhancements. The overlap between the two is not perfect, but the
scripts are small enough that it doesn't seem worth trying to
create separate bundles for.
Change-Id: Ibd00e0eddfafc57323b147e225ee668528dc1c1c
In Wikitext this will end up in [[Link]] being converted to a link.
In comments this is ignored prior to this patch.
Bug: T197958
Change-Id: I454d342a57c35c30af042349a04e3b86d778568f
Hard deprecation of passing Revision objects will follow soon,
but until that is ready core calls can be updated
There is some code cleanup that could be done around the calls, but
to simplify review no other changes are made.
Bug: T249561
Change-Id: Ifcfb3811650decffeaa87dc033c41fd1710b47a6
They naturally belong in RevisionLookup. They return Revision,
so should be replaced anyway.
Bug: T246284
Change-Id: Ie5c478e4667ca0e773186b9cb8a319cd09145112
This was done automatically by replacing every assertContains with
string *needle*. Then verifying the results.
Bug: T192167
Change-Id: Id8cbbf3b01e948f80046714183cc299f86be21fd
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
Aka: Streamline Linker::formatAutocomments() and add tests
This uses the "streamlining" for the code proposed by Thiemo
in I38edc1ad7720. I have squashed the two commits, so it now
has his code in Linker, but still has my tests as well as his.
Thiemo wrote on his patch:
This also changes the output in case there is no fragment to link to.
Before an empty `/* */` in a summary this would have created a link to
the page. I would like to argue this is not what a user expects.
Bug: T222628
Change-Id: I05408ede0e20dfd976f4057fc5baab461d2ef769
The problem was that new revisions were being added to the same page
since it is not deleted between each run.
Change-Id: I52e8db8e5ef3cde309c26f928fd44de4e6ec18e4
Follows-up b6e1e99bec, which switched the method from Title::makeTitleSafe
to TitleValue. The latter throws fatal on non-string $fragment.
Title::makeTitleSafe, on the other hand, uses makeName(), which casts
$fragment to a string, and ignores if it ends up as empty string
(boolean false becomes empty string and thus did "the right thing").
Bug: T222857
Change-Id: Iecc2140fabd31ef0f193740c7fab0fc698c38e51
Historically it seems that if Linker::userLink or friends were passed an
empty username (probably due to an incorrect database entry), they would
produce bogus output, e.g., an <a> with no contents or a link to the
invalid page "User_talk:" or similar.
In b6e1e99bec we replaced an occurrence of Title::makeTitle() (no
safety checks!) with creating a TitleValue, which asserts in its
constructor that the title text is not empty. This made such pages fail
an assertion and stop displaying at all.
Now there's a proper check for the error. Such cases will log a
production error and return "(no username available)".
Bug: T222529
Change-Id: Id65bdf9666b0d16e5553b8f38c7cf8fce2e37a25
This was the only comment I could find that uses two curly brackets
for some reason. There are a few more with one curly bracket.
Change-Id: Iaed631916064e6be4895edd4c7a3d7de491e16c2
Previously, a manually constructed autocomment in the form of
/* [[Some link]] */
would create a link to the the section, and then the "Some link" page.
After T165189 was implemented, the entire autocomment is now a link to
the section, so we're creating links inside of a link...which is
problematic. In most contexts (history and watchlist particularly), the
section link is more important than the title in the section heading, so
that's what we'll favor here.
It's worth noting that this situation is a manually created edge case.
Even if the section heading is a wikilink, the edit summary will
autofill a section autocomment without the double brackets.
We'll now render the double brackets ([[...]]) and not link them. This
is what the user literally typed, and matches the existing practice of
rendering templates in section headings with their literal syntax. And
as a bonus, it's still possible for user scripts such as wikEdDiff to
turn the rendered double brackets into a real link if users want.
Bug: T165189
Change-Id: Ib10679edd76c72a60d7e1c89fc8454166e34c463
A follow-up to 0a8e16d7cf thanks to Anomie's code review.
The section title is now inside <span dir="auto"> and <span
class="autocomment">, as before. $wgLang->getDirMark() between the arrow
and the text was restored.
Given the comment
/* External links */ removed bogus entries
the HTML before 0a8e16d7cf looked like:
<a href="#External_links">→</a><span dir="auto"><span
class="autocomment">External links: </span> removed bogus entries</span>
after this change, it will look like:
<span dir="auto"><span class="autocomment"><a
href="#External_links">→External links</a>: </span> removed bogus
entries</span>
The issue of having links be inside other links will be addressed in a
separate patch.
Bug: T165189
Change-Id: I31d87a87ccaf50de58fdd0621c46133b2881b490
Try to paste and preview this in the wikitext as well as the summary
line: [[:a]] [[ :a]]
The wikitext will show "a a", but the summary line will show "a :a".
This is only a display issue, all 4 links correctly link to the
article [[A]].
Change-Id: I08253a6d0b55b9aa3eace519bbdc1a456400bf84