Commit graph

65 commits

Author SHA1 Message Date
James D. Forrester
2550c145bb Drop the LinkBegin and LinkEnd hooks, deprecated since 1.28
Bug: T259108
Change-Id: I05aa2decaba032a2f1ae5afa7eee860b5136a263
2020-07-29 11:25:49 +01:00
suecarmol
436d7fbf06 Display remaining watch period in watchstar
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
2020-07-18 01:45:51 +00:00
Timo Tijhof
45da13803d resources: Bundle ajax patrol and ajax rollback code
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
2020-05-28 07:22:07 +00:00
WMDE-Fisch
40aba4175b Make formatLinksInComment understand and link [[Text[[Link]]
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
2020-05-13 14:26:35 +02:00
DannyS712
4721717527 Replace uses and hard deprecate Article:: and WikiPage::getRevision
Bug: T250532
Bug: T239975
Change-Id: Ic8f2baa0ac805d5196a7107bdc7a1abb36eba139
2020-04-20 23:06:48 +00:00
DannyS712
af7f397ccc Pass RevisionRecord to Linker methods
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
2020-04-18 01:24:54 +00:00
Petr Pchelko
a749000d39 Deprecate Title and WikiPage getFirstRevision methods
They naturally belong in RevisionLookup. They return Revision,
so should be replaced anyway.

Bug: T246284
Change-Id: Ie5c478e4667ca0e773186b9cb8a319cd09145112
2020-03-24 11:56:08 -07:00
Daimona Eaytoy
f5529400cc Stop using assertContains with string haystack
This was done automatically by replacing every assertContains with
string *needle*. Then verifying the results.

Bug: T192167
Change-Id: Id8cbbf3b01e948f80046714183cc299f86be21fd
2019-12-15 00:22:44 +00:00
jenkins-bot
2bf3cd85e6 Merge "Linker: Kill HHVM and PHP5 special case" 2019-10-07 20:57:22 +00:00
Max Semenik
4345c1e38b LinkerTest: explicitly set $wgFragmentMode
Change-Id: If59c721474fe04a639582869efe9b66746b499f1
2019-10-06 12:22:13 -07:00
Max Semenik
8835ac44ad Linker: Kill HHVM and PHP5 special case
Add another test case to be extra sure™ it won't regress.

Change-Id: Ib35a469e70ee475ea88a1f99a733ffb4ac751a45
2019-10-06 12:19:32 -07:00
Thiemo Kreuz
32a429e8c4 tests: Prefer assertSame() when comparing the integer 0
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
2019-09-19 15:35:23 +00:00
daniel
e9e50ad014 Make userLink() not fail too hard on false and null.
This works around an issue in Flow, which sometimes passes false
for a user name.

Bug: T224095
Change-Id: I14dc52f7199012dc35605f3170b06eb1719165a7
2019-06-05 14:51:57 +02:00
jenkins-bot
b13123c3ac Merge "Cleanup LinkerTest leakage between provider entries" 2019-05-30 18:09:09 +00:00
daniel
0c4410a623 Fix empty auto-summaries triggering a fatal error.
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
2019-05-30 16:34:34 +02:00
Aaron Schulz
b589693af0 Cleanup LinkerTest leakage between provider entries
The problem was that new revisions were being added to the same page
since it is not deleted between each run.

Change-Id: I52e8db8e5ef3cde309c26f928fd44de4e6ec18e4
2019-05-30 04:42:01 +00:00
Timo Tijhof
63cf83e089 Linker: Fix fatal error for "/* */" in an edit summary
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
2019-05-19 11:20:34 +00:00
Aryeh Gregor
ddd1d4b920 Log warning and show error on empty username
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
2019-05-06 14:44:23 -05:00
Tim Eulitz
341320457c Show confirmation prompt on rollback links
Bug: T215020
Change-Id: Ic831888e30808a20a04397912498fe2ca04f80ba
2019-03-21 10:13:22 +00:00
Thiemo Kreuz
b0615e1249 Remove empty and unnecessary /* @{{ … */ comments
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
2019-03-15 14:59:19 +01:00
Kunal Mehta
1706d353ae Don't link wikilinks in section heading autocomments
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
2018-12-03 12:43:03 -08:00
Kunal Mehta
0c9cf24b05 Restore old HTML structure for history section links
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
2018-12-03 12:42:56 -08:00
Bjornskjald
0a8e16d7cf Make "→" link to page section on History page larger by adding section name to it
Bug: T165189
Change-Id: I1f845592bd3de342fda84b60fc412055973950fd
2018-11-24 03:22:16 +00:00
Thiemo Kreuz (WMDE)
2c58fbaa29 Linker: more consistent whitespace parsing in formatLinksInComment
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
2018-09-06 17:19:32 +00:00
Kunal Mehta
03e7ae45bc Remove deprecated Linker::getLinkColour()
Change-Id: I1818d9eb369c620cc436c13446a5362816e8362d
2018-06-13 01:30:04 -07:00
Kunal Mehta
d78d6e23cf linker: Hard-deprecate LinkBegin and LinkEnd hooks
Change-Id: Ia1d766d019a2711c96e7c41913055774eff9f777
2018-06-10 12:00:15 -07:00
Umherirrender
67d420b302 Move @group and @covers tags in tests close to class
For @group and @covers tags there should be no newline between the
comment and the class

Change-Id: I7277df13a332cf4d74ffdd8748e3fbdc259610dc
2018-01-28 13:30:07 +01:00
Umherirrender
255d76f2a1 build: Updating mediawiki/mediawiki-codesniffer to 15.0.0
Clean up use of @codingStandardsIgnore
- @codingStandardsIgnoreFile -> phpcs:ignoreFile
- @codingStandardsIgnoreLine -> phpcs:ignore
- @codingStandardsIgnoreStart -> phpcs:disable
- @codingStandardsIgnoreEnd -> phpcs:enable

For phpcs:disable always the necessary sniffs are provided.
Some start/end pairs are changed to line ignore

Change-Id: I92ef235849bcc349c69e53504e664a155dd162c8
2018-01-01 14:10:16 +01:00
jenkins-bot
f246973a44 Merge "Linker: Do not localize links to other wikis in comments" 2017-07-06 02:08:02 +00:00
Matěj Suchánek
922b85bad0 Linker: Do not localize links to other wikis in comments
The title, although it refers to a foreign page, is considered local
due to Title::isExternal() being false, hence it's namespace prefix
is localized.

We need to use the canonical namespace name instead.

Bug: T169221
Change-Id: I5e5f7d873b9497ca6c8853e7d8170a4f4f07c051
2017-07-05 18:56:27 -07:00
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
Umherirrender
be42e09aa8 build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0
The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment.
Will be fixed in next version, see T167168

Changed:
- Remove duplicate newline at end of file
- Add space between function and ( for closures
- and -> &&, or -> ||

Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311
2017-06-26 17:14:31 +00:00
Moriel Schottlender
1fff06ad2d bidi-isolate usernames in Linker::userLink
Usernames can be in any script/language and include weak and neutral
characters like parentheses and dashes - these flip and make things
look very weird when displayed in the opposite directionality.

This fix adds <bdi> tags to isolate the username when we output user
links. This will affect displays like user personal tools, history
and diff view.

Also, fixing LogFormatterTestCase::removeSomeHtml() that expected
a very rigid html input (and thus failed with the new <bdi> wrapping)
to use strip_tags() instead.

Change-Id: I2db5f4b7d3a00726461eb6b699fbdf0ecd47a1cb
2016-08-31 17:44:06 -07:00
jenkins-bot
e305dd6ced Merge "Move Linker::getLinkColour() into LinkRenderer" 2016-07-18 16:16:07 +00:00
Kunal Mehta
b74c4b2f95 Improve @covers tags for LinkerTest
These hooks are now called from LinkRenderer, so make sure it is
covering the right code.

Change-Id: Ifaa28d471f585dce9d968cc1173c7fdceb408239
2016-05-27 19:30:42 -07:00
Kunal Mehta
5119236d4d Move Linker::getLinkColour() into LinkRenderer
* Rename to getLinkClasses() since it's not really returning colours,
  but CSS classes.
* Dependency inject LinkCache into LinkRenderer
* Update all callers of Linker::getLinkColour(), and mark it as
  deprecated (no other uses in Gerrit)
* Update a bunch of tests for new dependency

Change-Id: Id178e2dcc60b833ce2dbad4920896b93cabba1bf
2016-05-27 09:18:09 -07:00
Kunal Mehta
5f8a771f7e Add tests for Linker::getLinkColour()
Change-Id: Ic1553e21def47f5c4923ba747146b36b0b3ffdfc
2016-05-26 14:47:45 -07:00
Kunal Mehta
a95e8e7262 LinkRenderer: Re-implement noclasses as makePreloadedLink function
'noclasses' makes more sense as a per-link option rather than an
instance member of the LinkRenderer instance, since it depends entirely
on whether the calling code has preloaded the link classes.

Introduce LinkRenderer::makePreloadedLink() which makes this clear and
requires passing in the classes as a separate parameter. As a side-
effect, due to the way LinkRenderer::mergeAttribs() is implemented, the
'class' attribute will always appear before the 'title' attribute in the
final output.

Change-Id: I0545aa9d7139794bc22f9d3d6d6eccde003b2982
2016-05-26 00:24:06 -07:00
Kunal Mehta
c9219c4f81 LinkerTest: Fix passing test description to $this->assertEquals()
It was being passed to Linker::userLink() by accident.

Change-Id: I13ba5014193e91a467511259a0c7c1659d8bc0e6
2016-05-17 20:30:02 +00:00
Brian Wolff
ee4d5c6eed Remove support for $wgWellFormedXml=false
tl;dr: Having unnessary complexity in security critical code is bad.

* Extra options add extra complexity and maintenance burden
** Thus we should only have one html output mode. well formed = false
     was already vetoed in T52040, so lets go with WellFormed=true.
* Options which are used by very few people tend to get tested less
* Escaping is an area of code where we should be very conservative
* Having escaping rules depend on making assumptions about which
    characters various browsers consider "whitespace" is scary
* $wgWellFormedXml=false has had a negative security impact in the
    past (Usually not directly its fault, but has made other bugs
    more exploitable)
* Saving a couple bytes (even less bytes after gzip taken into
    account) is really not worth it in this context (imho).

Change-Id: I5c922e0980d3f9eb39adb5bb5833e158afda42ed
2016-05-12 17:40:01 -04:00
Kunal Mehta
e66d8905f8 Add tests for 'LinkBegin' hook
Change-Id: I663c25377fb899ea97ef959efac82dc836a9940a
2016-05-11 16:17:54 -07:00
Kunal Mehta
1facfab51b Add tests for 'LinkEnd' hook functionality
Change-Id: I5bd353756c0631b3dd1c214f814040d82d7c361f
2016-05-11 10:18:51 -07:00
Reedy
83fb19cb13 Swap the rest of array() -> []
Change-Id: I76a7259ed952a0673a1941f08b39b545211fba07
2016-03-30 22:04:58 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Amir E. Aharoni
c50cbe48ab Fix remaining Generic.Files.LineLength failures
Except the ones for which there is no clear way to fix
because of T114213.

Bug: T102614
Change-Id: I94a1fc7c890c82a36f0b51e42d311585c275775c
2015-10-03 17:23:07 +00:00
Amir E. Aharoni
bfdd3369c2 Fix Generic.Files.LineLength phpcs check in files under phpunit/includes
Bug: T102614
Change-Id: Iee3df5f064f595ecebe8210cc936bc3d20a122c9
2015-10-03 17:13:29 +00:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
Amir E. Aharoni
76ae9acec3 Make line shorter to pass phpcs in LinkerTest.php
There are other linkes here ythat will require a different treatment.

Bug: T102614
Change-Id: Ia0c75d11a85a931d37941471f9c9bdc16fda28e1
2015-09-26 18:20:11 +00:00
daniel
ef1f4af079 Allow Linker::formatComment to link to another wiki per default.
This also adds tests against injection to LinkerTest.

Bug: T111676
Change-Id: I757f2b91f3b50d789d04e530049c34b4628253e3
2015-09-15 18:10:33 +02:00
Marius Hoch
dd740a65dc Don't double escape in Linker::formatLinksInComment
Affected both the linked text and the actual URL.

For an example please see the ukwiki link on:
https://www.mediawiki.org/wiki/Special:CentralAuth/Admin

Follow-Up: Ibdedf087f85046646450367cbf1811db578d8f4b
Change-Id: Ie73796dcde4e0a096a6baa86a53245e6fe2b48b5
2015-01-15 18:14:42 +00:00