Commit graph

794 commits

Author SHA1 Message Date
Fomafix
fbf939cdda Remove id selector for toctitle
In 1bf5a652 the id selector was changed to a class selector for toctitle.
The cached HTML has been expired now and the id selector is not necessary
anymore.

Also remove the id selector #toc.tochidden for print style. This is not
necessary because the tochidden gets only added to .toc and not to #toc.

Change-Id: I43cfffdb0807e8ed8f6b7b8732ba857b709bee80
2017-06-08 10:05:00 +02:00
Ed Sanders
1bf5a652d6 Use classes instead of IDs for TOC collapsing
One may way to have multiple TOC's on the page (e.g. in VisualEditor).

Change-Id: I19701c4037b653b2944e407752e50f444861f883
2017-04-10 17:00:03 +00:00
James D. Forrester
9f53096051 Linker: Render selflinks as href-less classed <a>s, not <strong>s
Self-links are still semantically links, and representing them as <strong>s
is inelegant and more important a real pain to work with, especially in
contexts where they may change state (like inside an editor).

Instead, render them as <a>, with no href to avoid user agent style over-
rides and with a class to style them as before, named 'mw-selflink' to go
with 'mw-redirect'. This allows much easier adjustment later. The old CSS
class 'selflink' is retained for backwards compatibility, but deprecated.

Bug: T160480
Change-Id: If058843924c3b30c116df2520aef93a004d98a5d
2017-03-29 23:12:17 +00:00
jenkins-bot
17eda64357 Merge "includes: Replace implicit Bugzilla bug numbers with Phab ones" 2017-02-28 00:51:57 +00:00
Eddie Greiner-Petter
83e616a152 Add CSS classes for userlinks on SpecialPages
On Special:Watchlist, Special:Contributions, Special:Recentchanges etc.
there are links to (talk | contribs | block) for the user who did the
contribution. Add CSS class for them. Introduce the following css
classes:
- mw-usertoollinks-contribs
- mw-usertoollinks-talk
- mw-usertoollinks-block
- mw-usertoollinks-mail

Bug: T156879
Change-Id: I85a3b0987a016ff25026f1c047214a31170b0452
2017-02-23 02:51:23 +01:00
James D. Forrester
9635dda73a includes: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
2017-02-21 18:13:24 +00:00
Fomafix
ce6f7faadd Remove trailing empty lines in PHP
Performed using
find . -name \*.php -exec sed -i -e :a -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba' {} \;

Change-Id: I5d0627f94c73690cf3a8a453539c22c760c2aa60
2017-01-16 22:06:43 +01:00
awu42
fa8ae38943 Removed deprecated Linker functions
Removed:
 - getInterwikiLinkAttributes (deprecated in 1.25)
 - getInternalLinkAttributes (deprecated in 1.25)
 - getInternalLinkAttributesObj (deprecated in 1.25)
 - getLinkAttributesInternal (deprecated in 1.25)
 - usages in includes/DummyLinker.php

Bug: T61113
Change-Id: I98182f4145dafdc6e60953f25a5f20575257a854
2017-01-07 15:33:33 +00:00
Amir Sarabadani
ae9e295c64 Do not normalise external links to special pages
Bug: T147685
Change-Id: I0ec004b3f7194696eaca9541d336b061602e36df
2016-10-09 02:22:52 +03:30
This, that and the other
3d1dbd4c48 Handle links with multiple pipes correctly in edit summaries
Bug: T99346
Change-Id: I459b0027c7703b2379e024d88fab74b17ebb11e9
2016-09-20 15:15:48 -07:00
jenkins-bot
e5999cc51d Merge "Linker: Deprecate formatSize()" 2016-09-15 20:18:46 +00:00
Kunal Mehta
b6ac6ab899 Linker: Deprecate formatSize()
This is a static function that uses global state through $wgLang, and
provides no benefit than calling Language::formatSize() directly aside
from escaping. But that should generally be handled closer to output
generation.

Change-Id: I35fdbaf2fcaa89f0d4442e1f63ec8ed29e0c339f
2016-09-10 00:14:20 -07:00
Kunal Mehta
b16f897a05 Move Linker::formatTemplates() to separate class, remove global usage
Linker::formatTemplates() was a static function that depended upon
global state like $wgLang (explicitly), $wgUser & $wgTitle (implicitly).
Moving it to a separate class allows us to clean it up a little bit and
use modern things like RequestContext and LinkRenderer.

Bug: T145177
Change-Id: Icdea8a2b299b4876feb3df3d66df3e4c104dd928
2016-09-08 22:56:57 -07:00
Aaron Schulz
950cf6016c Rename DB_SLAVE constant to DB_REPLICA
This is more consistent with LoadBalancer, modern, and inclusive
of master/master mysql, NDB cluster, and MariaDB galera cluster.

The old constant is an alias now.

Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
2016-09-05 22:55:53 -07: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
Kunal Mehta
35701f3972 Linker: Get rid of "shortcuts" in image linking functions
This code is already hard to read, and using abbreviations definitely
doesn't help.

Change-Id: I681630b66f95319a521ee2aec3be5b678122b73b
2016-08-25 00:33:06 -07:00
Kunal Mehta
e6d1b6715b Linker: Avoid Title in normaliseSpecialPage()
Now that SpecialPage::getTitleValueFor() exists, use it so that we can
avoid returning a Title object uncessarily.

Change-Id: I5bf605baf2ecad62e189421a2e5c556cc0b6f6ac
2016-08-24 23:50:45 -07:00
Kunal Mehta
2c4add9c74 Mark Linker::link() as @deprecated
...and add a link to the on-wiki LinkRenderer documentation to the
class. Actual wfDeprecated and replacements in all the uses to come in
follow-up patches.

Change-Id: I2fefb6c38153028d2cc68c13bc62434d3df69cd2
2016-07-26 07:19:46 -07:00
jenkins-bot
e305dd6ced Merge "Move Linker::getLinkColour() into LinkRenderer" 2016-07-18 16:16:07 +00: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
Krinkle
5391e328c2 Revert "RollbackAction: Implement AJAX interface and require POST"
This partially reverts commit 9af38c046c.

* The new JS modules continue to exist. While not used by default,
  the mediawiki.api.rollback may be used elsewhere by now.
  The mediawiki.page.rollback module may still be used on cached
  pages and should continue to work.

* The new API behaviour remains.

* To avoid breaking mid-air rollbacks again, the token remains
  the same (plain "rollback" salt). We're not re-introducing the
  web-specific salt again.

Bug: T136375
Change-Id: Iba17ce55ff9506e838bfc6e70ca280e5a20b77b6
2016-05-27 16:16:40 +00:00
Kunal Mehta
8b6ff740a1 Have Linker::getLinkColour() accept LinkTarget objects
Change-Id: I7d7318099a822f9ddd88c538274511e6d8a8f1bc
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
Gergő Tisza
8c190da823 Do not use $wgUser in Linker/LinkRenderer when sessions are disabled
When MW_NO_SESSION is set, getting the user options for $wgUser will
result in an error. Check for that in the service definition, and
reuse that check in Linker.

Also removed an unused use clause.

Bug: T136124
Change-Id: Id6448d12e8f4a8a94852980e5eb6ccb202066822
2016-05-25 19:58:13 +00:00
jenkins-bot
8b9584646b Merge "Add LinkRenderer (rewrite of Linker::link())" 2016-05-24 03:29:32 +00:00
jenkins-bot
f8cc99ea98 Merge "Avoid invidual LinkCache lookups in Linker::makeBrokenImageLinkObj()" 2016-05-24 03:29:28 +00:00
jenkins-bot
9a309c92e6 Merge "Remove 'noclasses' from Linker::linkKnown() defaults" 2016-05-24 03:07:01 +00:00
jenkins-bot
4bd688c442 Merge "RollbackAction: Implement AJAX interface and require POST" 2016-05-23 21:02:50 +00:00
Timo Tijhof
9af38c046c RollbackAction: Implement AJAX interface and require POST
Similar to WatchAction (converted in commit 77cdf1919).

* Make FormAction::getFormFields not abstract.
  In most cases this will just be an empty array.

* Convert RollbackAction from FormlessAction to FormAction and implement the
  required error handling scenarios (mostly moved out of from the old method, or
  duplicated from the WikiPage method where necessary).

* In most cases the in-between form is never used since a JavaScript handler
  takes over the link and uses the API over AJAX instead. In the no-js fallback
  (as well as for any existing tokenless rollback links) copy the GET parameters
  into the form for re-submission as POST (plus token, added by HTMLForm).

* Remove the distinction between WebUI and API tokens. This stronger token salt made it
  unnecessarily complex and was only there because it used GET until now. This streamlining of
  tokens matches what we already do for 'watch', 'edit', 'patrol' and other actions.

* Fix form submission bugs when 'from' query parameter is missing.

  - Ensure the required 'from' query parameter is present before showing a form.
    No need for the user to submit a form we know will fail.

  - Plain GET request to action=rollback (with no parameters) is now a 400 Bad Request
    instead of a form that would fail when submitted.

  - Submitting the form without 'form' field now correctly says why it failed.
    Previously it emitted a session error, which was a lie.

Bug: T88044
Change-Id: Ia457802fec2e90573c8e7d552bc1f3cee258f10b
2016-05-23 20:00:48 +01:00
Kunal Mehta
67e62c0b25 Add LinkRenderer (rewrite of Linker::link())
This is a rewrite of Linker::link() to a non-static, LinkTarget-based
interface. Users of plain Linker::link() with no options can use the
LinkRenderer instance provided by MediaWikiServices. Others that
have specific options should create and configure their own instance,
which can be used to create as many links as necessary.

The main entrypoints for making links are:
* ->makeLink( $target, $text, $attribs, $query );
* ->makeKnownLink( $target, $text, $attribs, $query );
* ->makeBrokenLink( $target, $text, $attribs, $query );

The order of the parameters are the same as Linker::link(), except
$options are now part of the LinkRenderer instance, and
known/broken status requires calling the function explicitly.
Additionally, instead of passing in raw $html for the link text, the
$text parameter will automatically be escaped unless it is specially
marked as safe HTML using the MediaWiki\Linker\HtmlArmor class.

The LinkBegin and LinkEnd hooks are now deprecated, but still function
for backwards-compatability. Clients should migrate to the nearly-
equivalent LinkRendererBegin and LinkRendererEnd hooks.
The main differences between the hooks are:
* Passing HtmlPageLinkRenderer object instead of deprecated DummyLinker
* Using LinkTarget instead of Title
* Begin hook can no longer change known/broken status of link. Use the
TitleIsAlwaysKnown hook for that.
* $options are no longer passed, they can be read (but shouldn't be
modified!) from the LinkRenderer object.

Bug: T469
Change-Id: I057cc86ae6404a080aa3c8e0e956ecbb10a897d5
2016-05-23 12:00:09 -07:00
umherirrender
72632115d6 Fix various phpcs error from last security patches
Found by tests:
https://integration.wikimedia.org/ci/job/mediawiki-core-phpcs-trusty/1069/console

Breaking merges

Change-Id: If01b94705cd7b939ac380053730b1b602c838a8e
2016-05-20 20:20:36 +02:00
Brian Wolff
13ece3550e Add rel="noreferrer noopener" when target attribute would open window
noreferrer is used as support for noopener is very limited.
This is to prevent the attack detailed at
https://mathiasbynens.github.io/rel-noopener/ where you can
navigate the parent window, even if the new window is a cross-origin.

Bug: T133507
Change-Id: I6e4ab938861e246ff44048077b94847e303f1859

Signed-off-by: Chad Horohoe <chadh@wikimedia.org>
2016-05-20 09:49:41 -07:00
Kunal Mehta
1f7d032f83 Avoid invidual LinkCache lookups in Linker::makeBrokenImageLinkObj()
Change-Id: I29ab072519937b770e75a40382d2f77cbabe098b
2016-05-19 19:09:05 -07:00
Kunal Mehta
c66b6a1e43 Remove 'noclasses' from Linker::linkKnown() defaults
The intention for Linker::linkKnown() was to be used when the caller had
already preloaded the target's existence ('known') and called
Linker::getLinkColour() directly ('noclasses'). However, nearly all
usage of linkKnown() only did the first part, and not the latter.

So do what people actually ended up using the function for, and remove
'noclasses' from the default parameters. As long as the target the link
is being created for is already in LinkCache, this shouldn't cause any
extra database queries.

Change-Id: Ia5a4c2f18ec780627146617a1498bd04fcfbb3ee
2016-05-19 19:07:58 -07:00
addshore
9b65baa1a0 Add a bunch of @since tags to Linker
Change-Id: I8bab046c33f370d63a29020154e5691b47881dec
2016-05-04 13:48:58 +01:00
jenkins-bot
f141d25d1a Merge "Have Linker::normaliseSpecialPage() accept LinkTarget objects" 2016-04-26 19:30:38 +00:00
Kunal Mehta
eec846227d Have Linker::normaliseSpecialPage() accept LinkTarget objects
Change-Id: I762eaaeaf292f014e0443bf3c8fcf621ae8ee254
2016-04-26 12:05:20 -07:00
jenkins-bot
47e2941bcd Merge "Namespace LinkTarget under MediaWiki\Linker" 2016-04-24 12:31:13 +00:00
jenkins-bot
7e90af0237 Merge "Have Linker::linkUrl() accept LinkTarget" 2016-04-22 11:46:16 +00:00
Kunal Mehta
c9d885f3b4 Namespace LinkTarget under MediaWiki\Linker
And add a GPL file header while we're at it.

Change-Id: I15a6f240124c879b21fb655ade1baaebf4f34ffd
2016-04-21 17:19:10 -07:00
Kunal Mehta
d19e5bec15 Have Linker::linkUrl() accept LinkTarget
This is a private function so it doesn't really make much of a
difference, but will allow further refactoring.

Change-Id: Idacad7b1bd4776c04659ed9af64540d6ce4b2f28
2016-04-21 17:19:10 -07:00
addshore
b215e34de8 Move DummyLinker to own file
Change-Id: I1808a6b77af2597b4dd2c9f1e0c8604c2bc8c801
2016-04-20 08:48:48 +01:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +00:00
This, that and the other
c99e3d537e Linker: Avoid passing false to Title::newFromText
This is needed because the call to substr() returns false when the string
is only 1 character long, which occurs when parsing degenerate links like
[[:]] and [[::|foo]].

The seemingly unnecessary test for $match[1] !== '' is for forwards
compatibility with PHP 7.

Bug: T121706
Change-Id: Icc19ee990d01958d64b938d298e9a7e1df7181b5
2016-03-02 23:10:28 +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
Brad Jorsch
783fb29fbf Use stub threshold from ParserOptions when parsing
Linker::linkAttribs() needs the stub threshold to determine the classes
in some cases. For the code path from Parser → LinkHolderArray → Linker,
we can pass down the correct threshold from ParserOptions instead of
pulling a potentially-different threshold from $wgUser.

Bug: T124367
Change-Id: I16b9d6c3044ae60d5a7fd340569c019ffc4b2a55
2016-02-08 19:04:50 +00:00
Alex Monk
3e329182d1 Revert "Remove unused functions from unroll of Article::__call"
This reverts commit 0204a28443.

Change-Id: Ia058c91f808eedae28946b9561c826fbf09b386e
2016-02-01 20:05:38 +00:00
umherirrender
0204a28443 Remove unused functions from unroll of Article::__call
With I779aa1c017abc9a17047fd5335f2d082148daa6f all public functions from
WikiPage were copied as delegator into Article.

Now remove the unused functions and add a release notes

Change-Id: I9cc79acedecb003048e1add568e8bba96ddbb41a
2016-01-30 22:22:31 +01:00
addshore
b6abce7edc Remove doc comment referencing removed method
This method was removed in:
cfaf26e501
so lets remove the reference to it so people don't
go looking for what is not there.

Change-Id: I229f033a3b4553e6eacc460faaf156ba2539d6d5
2016-01-27 10:07:28 +00:00
Brian Wolff
48c0dbc7a3 Make redlink tooltip be content language to stop cache pollution.
Redlink tooltips end up in parser cache!

This is not ideal, as ideally it would be in the page's language,
not the content language and it would be user language for things
outside of pages, but that's not easy to do the way the code is
structured, and this is much better than the alternative.

Other possibilities include:
* Splitting parser cache (Previously been reverted, and doesn't
seem worth it given the feature in question)
* Post-processing step after parsing (Really complicated. Doesn't
seem worth it)

Bug: T34686
Change-Id: Id632f8ef59d1c762aed1867a708c569cbff5f0dd
2016-01-19 21:51:58 +00:00