Commit graph

858 commits

Author SHA1 Message Date
Max Semenik
7ad5282938 Don't percent-encode HTML5 IDs
During the TechCom meeting, it was decided this is the better way.

Bug: T152540

Change-Id: I6c3ec1c407225b4e925b7373bf52208e2f6b6c4a
2017-09-11 18:22:04 -07:00
Kunal Mehta
1fd75c78db Linker: Accept LinkTargets in makeCommentLink()
Change-Id: I47b421b38ec60aaf8b4b9f762084f42b44ef8026
2017-09-10 15:20:07 -07:00
Kunal Mehta
77b34ccdba Linker: Accept LinkTarget objects in link()
Even though this function is deprecated, it'll make the migration to
TitleValue easier.

Change-Id: Idb16dd2dd50a5273bff5e0537825dc5e91f00d86
2017-09-10 15:19:24 -07:00
Kunal Mehta
f629d095f0 Linker: Don't use Title::setFragment()
It's deprecated for public usage.

Change-Id: I916841f28351567dfa71f5a65c5cbc273ddbabd4
2017-09-10 15:15:38 -07:00
jenkins-bot
802c199d0b Merge "Move section ID fallbacks into headers themselves" 2017-08-31 21:02:12 +00:00
Umherirrender
718e63694d Add missing @param and @return documentation
Change-Id: I1d1098eec3933df6561cceef646576013ddc08c8
2017-08-11 22:17:01 +02:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
Max Semenik
4f2eed6877 Move section ID fallbacks into headers themselves
Per feeedback on T152540. Now there's an uniform way to get to
section's <h*> from element with the given ID.

Change-Id: I94b46707dadb1988d963344b02060dcaffdab7b4
2017-08-03 15:16:47 -07:00
Max Semenik
fd6e9ef2d4 Human-readable section ID support
It adds the ability to replace the current section ID escaping
schema (.C0.DE) with a HTML5-compliant escaping schema that is
displayed as Unicode in many modern browsers.

See the linked bug for discussion of various options that were
considered before the implementation. A few remarks:
* Because Sanitizer::escapeId() is used in a bunch of places without
  escaping, I'm deprecating it without altering its behavior.
* The bug described in comments for Parser::guessLegacySectionNameFromWikiText()
  is still there in some Edge versions that display mojibake.

Bug: T152540
Change-Id: Id304010a0342efbb7ef2d56c5b8b244f2e4fb2c5
2017-08-01 20:32:20 -07:00
Kunal Mehta
d1cf48a397 build: Update mediawiki/mediawiki-codesniffer to 0.10.1
And auto-fix all errors.

The `<exclude-pattern>` stanzas are now included in the default ruleset
and don't need to be repeated.

Change-Id: I928af549dc88ac2c6cb82058f64c7c7f3111598a
2017-07-22 18:24:09 -07: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
Bartosz Dziewoński
88b209ff2a Linker: Remove whiny FIXME comments
These are not actionable. Such is life, deal with it.

Change-Id: I81df045f54052b98cf798d3d42a3d730407d68ae
2017-06-22 19:51:11 +02:00
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
victorbarbu
6ea30d631d Allow parameters to be passed into skin tooltip messages
You can now pass parameters to toolbox links' tooltips,
by setting 'tooltip-params' key in a $nav_urls item of
SkinTemplate::buildNavUrls.

This functionality is used to add GENDER support to two
tooltip messages.

Bug: T123365
Change-Id: I45577d54bd78ba1e2ba10fb8f04367244495bfea
2016-01-12 14:39:15 +00:00
Florian
b382fb4c38 Remove Linker::makeImageLink2
Bug: T122754
Change-Id: Ie28dda59cdc450644f7330135b4d43e036d07bf1
2016-01-03 21:44:56 +01:00
Reedy
13815fc4ff Linker::makeLinkObj() was removed
Change-Id: Id0fe255fd65403d02498f5a98292c560d39dd95a
2016-01-03 00:08:43 +00:00
Reedy
85f9456b2d Linker::makeKnownLinkObj() was removed
Change-Id: I22b8445db8f52ffd6bc4a91d3441be9e5197a8a5
2016-01-02 23:41:47 +00:00
csteipp
d20243c06a Add warning comment on formatLinksInComment
Bug: T120324
Change-Id: If4423e14737a7e9d80661da27ad6f5463798a7d7
2015-12-03 16:12:41 -08:00
Timo Tijhof
b7f078c75e Remove redundant null-handling for Title::newFromText
* Linker: Follows-up 9ce5ca9886. null is already handled.

* PrefixSearch: Follows-up 337b1e2e. null is already handled.
  If other types are bassed, we want to find these.

* UploadBase: Follows-up 11f5ebec28. null is already handled.
  WebRequest::getVal($name) can only return string or null.

Change-Id: I3dc3b700cde735f5cd9d497f0867a2b4e3b61f46
2015-11-17 01:53:30 +00:00
umherirrender
9ce5ca9886 Avoid "$text must be a string" in Linker::formatLinksInComment
Just check the passed variable on caller side to avoid the warning.

Bug: T109977
Change-Id: I28fbf7408dee8f46675bd7514dc0a87b0924e153
2015-10-27 17:55:53 +01:00
umherirrender
cf1d31b604 clone is not a function
Remove parenthesis around clone magic word

Change-Id: I2e0e53303f7c73745bd1ab4bcf32e74943efc4de
2015-10-16 19:34:31 +02:00
umherirrender
977c810302 Remove empty line comments
Remove empty line comments as found by the
MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.EmptyComment sniff

Change-Id: I5d694f7a7d3bc97e16300ba03c60ad17f3c912a5
2015-10-14 09:46:44 +02:00
Amir E. Aharoni
1609d05c0d Linker.php: Make long lines shorter to pass phpcs
Bug: T102614
Change-Id: Ia014b8f89058fe9a4cf22ed63a0042ab1c66e97a
2015-09-26 17:06:57 +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
daniel
5852451177 Add support for fragments to WikiMap
WikiMap::makeForeignUrl should support fragement IDs in the
generated URL.

Change-Id: I612d5f465822b56356a78b3e72fb441a888668f1
2015-09-11 16:25:53 +02:00
S Page
2a0edf7d6e Delete "Currently unused" regarding generateTOC
includes/api/ApiHelp.php uses Linker:generateTOC.
This is a trivial comment-only change.

Change-Id: Ie566a94a67b5e583d20a23edcdac5a1e3ba3d542
2015-08-03 19:08:05 +00:00
Timo Tijhof
c318e3a265 Hygiene: Use strtr() instead of str_replace() for character swapping
strtr() is marginally faster as it runs through the string only
once. A better fit for one-for-one character translation.

The strtr() function also supports an associative array as second
parameter for entire string replacements. This, too, has the same
performance and predictable behaviour (starts with the longest key).
Whereas str_replace is for more aggressive needs where you want
multiple passes until there are no further matches.

The associative array form is arguably also easier to understand
and harder to mess up since the needle/replacement pairs are
explicitly connected instead of two separate arrays.

Also:
* Use getFormattedNsText instead of strtr( getNsText, .. ) which
  reduces duplication of this fact through a more semantic intent.

Change-Id: Ie23e4210a5b6908dd79eebc8a2b931d12fe31af6
2015-07-06 20:25:19 +00:00
Brad Jorsch
dc15ea106a ApiHelp: Make 'toc' parameter work
Bug: T98378
Change-Id: I0219689f621e325fc22f0eab6e4c000e1b2fa06f
2015-05-06 13:37:41 -04:00
Bartosz Dziewoński
5205405385 Emergency remove .mw-headline-anchor
Follows-up 6c7480e5f0, d2a6a73d2.

The should stop the § character from being indexed by Google et al.

Bug: T18691
Bug: T93000
Change-Id: Ie9e334e973e3ded270f1897a2c3816d9df739fc0
2015-03-17 22:31:45 +00:00
Amir E. Aharoni
3000e59762 Shorten long lines in Linker.php to make phpcs pass
Change-Id: Ia3376560dfd321252babc2ac3edd88764a16bce1
2015-03-03 22:00:32 +00:00
Bartosz Dziewoński
d2a6a73d29 Hide section anchor links from screen readers using aria-hidden
Hide from screen readers, as it is inside a heading (the programs use
headings to navigate, so the symbol is being read during navigation).
Pending T13555 being fixed.

See <https://phabricator.wikimedia.org/T18691#1076371> and
<https://phabricator.wikimedia.org/T18691#1076857> for reasoning.

Bug: T18691
Change-Id: I736cb7f52d5ce37eb7e8d3a3648ffd0bd40f2c83
2015-03-02 10:16:29 +01:00
jenkins-bot
6a3782ec14 Merge "Avoid double word-separator when using Linker::userToolLinks" 2015-02-20 08:21:46 +00:00
Vivek Ghaisas
6c7480e5f0 Add clickable link for section headers
Changed the Linker::makeHeadline function to additionally generate an
anchor that uses a section symbol. Created mediawiki.sectionAnchor
module to style the anchors and included it in SkinTemplate so that
other skins automatically get those styles.

Bug: T18691
Change-Id: I562e437ec0bd337c9db0406f5dcab504dfa37034
2015-02-19 22:53:57 +01:00
umherirrender
6dcb4408c7 Avoid double word-separator when using Linker::userToolLinks
The word-separator is already part of the return value of
Linker::userToolLinks which results in a double space when add an own
word-separator

Change-Id: Id9d3125b9cae4a92f489215dda0b32c487f3fb11
2015-02-12 18:54:18 +01:00
jenkins-bot
4d22e6ff4e Merge "Don't double escape in Linker::formatLinksInComment" 2015-02-04 07:16:20 +00:00
Niklas Laxström
acc2bcaf37 Escape unescaped messages shown in action=info
Change-Id: Id16d8c8dff73fdacad6c9a4ff7f2919945b7e893
2015-01-30 16:56:11 +00:00
Ricordisamoa
4ece7f53aa Revision: mark getRaw*() methods as deprecated
Revision->getRawUser()
=> Revision->getUser( Revision::RAW )

   Revision->getRawUserText()
=> Revision->getUserText( Revision::RAW )

   Revision->getRawComment()
=> Revision->getComment( Revision::RAW )

The body of Revision->getRawUserText() has been moved
into Revision->getUserText().
Every usage has been replaced.

Change-Id: Ic6fbfbc0507dcf88072fcb2a2e2364ae1436dce7
2015-01-18 06:57:56 +01: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
Marius Hoch
d14f6c0de3 Make Linker::formatLinksInComment format links to other wikis
Needed for CentralAuth.

Change-Id: Ibdedf087f85046646450367cbf1811db578d8f4b
2015-01-09 11:22:31 -08:00
Ricordisamoa
2ae155da52 Fix phpcs errors in includes/
Mostly Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines

Change-Id: I678b2f0902f11cd1dfa1611b9da24e7237df9122
2015-01-08 20:15:07 +01:00
Aaron Schulz
4ff8136807 Removed remaining profile calls
Change-Id: I31c81c78715048004fc8fca0f27d09c1fa71c118
2015-01-08 02:49:33 -08:00
Chad Horohoe
aa21e125a3 Remove obvious function-level profiling
Xhprof generates this data now. Custom profiling of various
sub-function units are kept.

Calls to profiler represented about 3% of page execution
time on Special:BlankPage (1.5% in/out); after this change
it's down to about 0.98% of page execution time.

Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
2015-01-07 11:14:24 -08:00
Brad Jorsch
29951907f7 Format multiple autocomments in edit summaries
Before r39373, all autocomments in an edit summary were formatted. In
fixing a bug with page titles containing "/*" this was accidentally
broken.

To use a single preg_replace_callback call to replace multiple
autocomments, we need to make sure that the match of one autocomment
doesn't overlap the match of another, which means we can't have "(.*)"
before and after. But we do still need to detect whether there is
anything before or after. "(?=(.?))" and "(?<=(.?))" would do nicely,
except the latter isn't actually supported. "(?=(.))?" and "(?<=(.))?"
work too, but older versions of PCRE don't support that. They do,
however, support "(?:(?=(.)))?" and "(?:(?<=(.)))?", so that's what
we'll go with.

This change does change the values for $pre and $post passed to the
FormatAutocomments hook; extensions need to be updated to accept (and
not prepend/append) booleans for these parameters.

Bug: T18530
Bug: T70361
Change-Id: I36c3a9e548a4ef72f93974bb35f9add8c29e9287
2014-12-31 10:24:05 +11:00
Niklas Laxström
4741900b5e Escape unescaped messages shown on a diff page
Change-Id: I05c07625a2dbb3c5d3ab46d1cfafeaed6a248bba
2014-12-18 20:01:32 +00:00
Ricordisamoa
fc5fd5c37a Typo fixes and non-code tweaks
Skipped replacements:
* prefered → preferred
* prolly → probably

Skipped files:
* resources/lib/jquery.ui/jquery.ui.mouse.js
* resources/lib/jquery/jquery.form.js

Change-Id: Ib7923f362ddfca1b892bf5d601785d6b5aa5d44c
2014-12-12 18:31:15 +00:00
Aaron Schulz
e369f66d00 Replace wfRunHooks calls with direct Hooks::run calls
* This avoids the overhead of an extra function call

Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
2014-12-10 12:26:59 -08:00
jenkins-bot
478272b6e5 Merge "Consistently handle trailing slashes in subpage links." 2014-11-17 17:05:58 +00:00
Bartosz Dziewoński
3e85dfb8ad Standardize indentation of multiline 'if'/'elseif' conditions
Always indent the continuation one level deeper, and always place the
closing parenthesis on the next line, per coding conventions.
https://www.mediawiki.org/wiki/Manual:Coding_conventions#Indenting_and_alignment
https://www.mediawiki.org/wiki/Manual:Coding_conventions#Line_continuation

Regexp used: (\t+)(if|while|\} elseif|foreach).+(?<![;}])\n\1\S

Also:
* Change to just one line if line length stays under 100 characters.
* Add "// Do nothing" comment in empty 'if' bodies.
* Change '#' comments to '//' comments near affected code.

Change-Id: I4f62658fddb5a0ed18bbf9b2231cd794683d6402
2014-11-17 15:33:34 +00:00
C. Scott Ananian
8a797162f0 Consistently handle trailing slashes in subpage links.
The link text for [[/Foo/]] is `Foo` and the link text for
[[../Foo/]] is `Foo`.  So far so good.

But the link text for [[/Foo//]] is `Foo` while the link text
for [[../Foo//]] is `Foo/`.  We are stripping all trailing slashes
in the first case, but not the second.

Fix the code so that we strip all trailing slashes in both cases.
Update some of the comments in the code while we are at it.

Change-Id: Id61eacafea9820c404699a7902c8eb8102779516
2014-11-14 17:09:00 -05:00