Commit graph

825 commits

Author SHA1 Message Date
Kunal Mehta
230958d97c Autofix MediaWiki.Commenting.FunctionComment.SpacingDoc* errors
Change-Id: I63761ebce04c03b9b13237919c27cc10180f198f
2018-05-19 14:07:03 -07:00
Brad Jorsch
27c61fb1e9 Add actor table and code to start using it
Storing the user name or IP in every row in large tables like revision
and logging takes up space and makes operations on these tables slower.
This patch begins the process of moving those into one "actor" table
which other tables can reference with a single integer field.

A subsequent patch will remove the old columns.

Bug: T167246
Depends-On: I9293fd6e0f958d87e52965de925046f1bb8f8a50
Change-Id: I8d825eb02c69cc66d90bd41325133fd3f99f0226
2018-02-23 10:06:20 -08:00
jenkins-bot
ea43303951 Merge "Move methods for handling external usernames to a dedicated class" 2018-01-19 14:43:42 +00:00
Amir Sarabadani
dc4089b268 Move methods for handling external usernames to a dedicated class
This makes things centralized to reduce maintenance cost and also
enables me to use this methods in Wikibase to handle RC injection

Bug: T185034
Change-Id: Ic8c602e316144ccb5b05c69a0cc607cd53e38912
2018-01-18 21:02:49 +01:00
jenkins-bot
a18476eab3 Merge "Remove @param comments that literally repeat what the code says" 2018-01-11 23:48:03 +00:00
Thiemo Mättig
ef470ebf7f Remove @param comments that literally repeat what the code says
These comments do not add anything. I argue they are worse than having
no comments, because I have to read them first to understand they
actually don't explain anything. Removing them makes room for actual
improvements in the future (if needed).

Change-Id: Iee70aad681b3385e9af282d5581c10addbb91ac4
2018-01-10 14:14:26 +01:00
Albert221
a9cbe0c847 Add text to tab links telling if they do exist
And changed a little bit signature of Linker::titleAttrib
and Linker::tooltipAndAcceskeyAttribs. Added $options
parameter to the second one and made $options parameter
satisfied by passing an array with options, because there
is one more now: 'nonexisting' which tells to add text
about the thing that the page does not exist to its tooltip.

Bug: T19099
Change-Id: Ia76dd6db363f6add5efb8955be9e23a1f8e8476f
2018-01-08 16:42:01 +00:00
Thiemo Mättig
544122a6c2 Remove self-explaining "section heading" comments from classes
I can see that "parent::__construct" literally calls the parent
constructor. I can see that stuff preceeded by the keyword "protected"
is protected. I really (really) don't need comments explaining such.

Change-Id: I7458e714976a6acd3ba6a7c93fdc27d03903df83
2017-12-28 16:12:08 +01:00
Fomafix
65b888a520 Add HTML attributes lang and dir to toctitle
The toctitle is in user interface language. This change add the
HTML attributes lang and dir to the toctitle.

This allows to copy (a part of) the rendered HTML to a word processing
and the language for spell checking has the right language.

Change-Id: I17730869f81744560672d7d0acb67ced71e69c4e
2017-12-27 20:26:06 +01:00
jenkins-bot
86b4925b2e Merge "Linker: Use Parser::guessSectionNameFromStrippedText()" 2017-12-12 13:13:07 +00:00
Roan Kattouw
62f284a6ac Linker: Use Parser::guessSectionNameFromStrippedText()
Instead of weird partial stuff.

Change-Id: Ibe7435a4723d2741e32d37d2ba67396d78d14044
2017-12-07 10:23:10 -08:00
Brad Jorsch
96bd79b4a3 Avoid DB rows with usable names but ID = 0 by introducing "interwiki" usernames
Importing revisions in MediaWiki has long been weird: if the username on
the imported revision exists locally it's automatically attributed to
the local user, while if the name does not exist locally we wind up with
revision table rows with rev_user = 0 and rev_user_text being a valid
name that someone might later create. "Global" blocks too create rows
with ipb_by = 0 an ipb_by_text being a valid name.

The upcoming actor table change, as things currently stand, would
regularize that a bit by automatically attributing those imported
revisions to the newly-created user. But that's not necessarily what we
actually want to happen. And it would certainly confuse CentralAuth's
attempt to detect its own global blocks.

Thus, this patch introduces "interwiki" usernames that aren't valid for
local use, of the format "iw>Example".[1] Linker will interpret these
names and generate an appropriate interwiki link in history pages and
the like, as if from wikitext like `[[iw:User:Example]]`.

Imports for non-existant local users (and optionally for existing local
users too) will credit the edit to such an interwiki name. There is also
a new hook, 'ImportHandleUnknownUser', to allow extension such as
CentralAuth to create local users as their edits are imported.

Block will no longer accept usable-but-nonexistent names for 'byText' or
->setBlocker(). CentralAuth's global blocks will be submitted with an
interwiki username (see Ieae5d24f9).

Wikis that have imported edits or CentralAuth global blocks should run
the new maintenance/cleanupUsersWithNoId.php maintenance script. This
isn't done by update.php because (1) it needs an interwiki prefix to use
and (2) the updater can't know whether to pass the `--assign` flag.

[1]: '>' was used instead of the more usual ':' because WMF wikis have
many existing usernames containing colons.

Bug: T9240
Bug: T20209
Bug: T111605
Change-Id: I5401941c06102e8faa813910519d55482dff36cb
Depends-On: Ieae5d24f9098c1977447c50a8d4e2cab58a24d9f
2017-11-30 13:12:44 +11:00
jenkins-bot
afbf5e7899 Merge "Do not double decode HTML entities for IDs" 2017-09-13 17:50:37 +00:00
jenkins-bot
f1c7c0f03d Merge "Linker: Accept LinkTargets in makeCommentLink()" 2017-09-13 10:15:54 +00:00
jenkins-bot
62a9ee2f45 Merge "Linker: Accept LinkTarget objects in link()" 2017-09-13 10:10:39 +00:00
jenkins-bot
083c0dce4e Merge "Linker: Don't use Title::setFragment()" 2017-09-13 10:07:16 +00:00
Fomafix
b6c895ddc5 Do not double decode HTML entities for IDs
* in links (T103714)
* in indicators (T104196)

This change removes the automatic Sanitizer::decodeCharReferences from
Sanitizer::escapeId and Sanitizer::escapeIdInternal. Where decoding of
HTML entities are wanted an explicit call to
Sanitizer::decodeCharReferences is added.

Explicit decode HTML entities in non local autocomments. (T104311)

Bug: T103714
Bug: T104196
Bug: T104311
Change-Id: I88e8e2077e6f5eec2b232391f7818370894a62dc
2017-09-12 15:42:17 +02:00
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