Commit graph

751 commits

Author SHA1 Message Date
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
aude
7c023b5771 Deprecate rarely or unused *LinkAttributes methods in Linker
Linker::getInterwikiLinkAttributes and Linker::getInternalLinkAttributesObj
are not not used any code in gerrit.

Linker::getInternalLinkAttributes is used once, in the Video extension.

Change-Id: I76d9b549e0fdccb9c1b4d9c12ba40a67c2733637
2014-11-13 17:19:38 +01:00
aude
203c5baf12 Remove deprecated Linker::getExternalLinkAttributes method
deprecated since 1.18 and unused anywhere else in
core or all the extensions in gerrit:

https://github.com/search?utf8=%E2%9C%93&q=getExternalLinkAttributes+%40wikimedia&type=Code&ref=searchresults

Change-Id: Id5ae9186b3a83672c8310adb5dfdaf07bfec3d74
2014-11-13 14:39:16 +01:00
Kevin Israel
36c0da63cd Replace a few more logical operators
Changed all remaining uses of 'and' (T_LOGICAL_AND) and 'or'
(T_LOGICAL_OR) except those in includes/libs/lessc.inc.php.

In maintenance/generateSitemap.php, also slightly cleaned up
touched code:

* Inlined GenerateSitemap::init_path().
* Removed the redundant `$fspath && !is_dir( $fspath )` check.
* Return a nonzero exit code if wfMkdirParents() fails.

There are still uses of 'xor' (T_LOGICAL_XOR) in the following
files, which I left as-is:

* includes/Export.php
* includes/htmlform/HTMLCheckField.php
* includes/Autopromote.php
* maintenance/importDump.php
* maintenance/backup.inc

Change-Id: I73cb20da989e90b52782e7499f633debd5ad265d
2014-10-24 11:41:00 -04:00
Chad Horohoe
6c30fff0ba Swap and for &&
Change-Id: I7821a62586cc2d2f929fb3d7d5046958a70efbd0
2014-10-23 13:03:14 -07:00
Niklas Laxström
368a948bb6 Make linker warning useful
Follow-up to I4c397de289ae51bc463b5ae

Change-Id: I4695172b13988fc333707e09fc9d909f20adb7c1
2014-09-23 09:13:33 +02:00
withoutaname
d89deb8466 Enforce some type hinting in Linker class
Specifically for link(), linkText(), makeImageLink(),
and makeBrokenImageLinkObj() functions

Change-Id: I4c397de289ae51bc463b5ae7c2968703d1424368
2014-09-15 18:55:57 -07:00
Brian Wolff
c2665e2cb2 Make sure processResponsiveImages checks for valid thumb object
If the thumbnail is an error (or worse yet, if the MediaHandler
returns false, like TMH does in certain circumstances), we
should not add responsive thumbnail links.

Change-Id: I2aafbd07e8435ce2d1b4cb32e49e98cb5f6c00ab
2014-09-14 21:40:27 +00:00