Commit graph

335 commits

Author SHA1 Message Date
jdlrobson
a7786688dd Add mw-list-item class to all menu list items created by makeListItem
When working on multiple skins its been confusing to know how the lists
are created from the HTML. In Vector we've also resorted to some overly
complex styling rules to style `li` elements. It's proposed a mw-list-item
class is added to simplify Vector styling and make it easier to understand
how the HTML is generated.

Change-Id: I67731fe59743620d339ffcca3ffc3b1f127ce3e7
2021-08-27 19:41:42 +00:00
Timo Tijhof
e387cd9c35 Change trivial use of getVal('action') to getRawVal
Per docs added in I18767cd809f67b, these don't need normalization
as they are only compared against predefined strings, and besides
are generally entered manually in a form, and even then would not
require the kinds of Unicode chars that have multiple/non-normalized
forms.

In nearby areas to also fix some trivial cases:

* getVal('title') obviously needs normalization.
  Use getText() to make this more obvious.

* getVal() compared against simple string literals within the code
  obviously don't need normalization (e.g. printable === 'no').

* Change hot code in MediaWiki checking for whether 'diff' or 'oldid'
  are set to getCheck (which uses getRawVal) instead of getVal.
  As a bonus this means it now handles values like "0" correctly,
  which could theoretically have caused bad behaviour before.

Change-Id: Ied721cfdf59c7ba11d1afa6f4cc59ede1381238e
2021-08-26 22:11:58 +01:00
Umherirrender
1d178e177b Remove unneeded continue/return statements
Change-Id: I26f9845b09ecc15de8b6e0213ab369b386194c9d
2021-08-17 22:53:53 +02:00
jdlrobson
0fc9cf4282 Remove doSetupSkinUserCss and setupSkinUserCss
These methods have been replaced by skin options.
Skins should now declare their style modules in skin.json using
the `styles` option.

Bug: T280610
Change-Id: I24abe7e2539499089e91151d9122e05bcb2d32ca
2021-07-27 08:39:25 -07:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
Clare Ming
3336c6e6e9 Remove Skin::getRevisionId, Skin::isRevisionCurrent
Bug: T280613
Change-Id: I5d83ef9a62253c23cd9c047087f9939684543644
2021-07-15 13:52:30 -06:00
Clare Ming
4d4a0d67ef Remove Skin::makeNSUrl
Bug: T280612
Change-Id: I70b3bfb569d92785b719756b81e881951e892967
2021-07-14 17:02:42 -06:00
bwang
f3bab2f249 Remove Skin::generateDebugHTML()
Bug: T280611
Change-Id: I7f2520851fe9f4064e54f869507df4cffdd6684b
2021-07-13 21:07:38 +00:00
jenkins-bot
9fdd82c0c4 Merge "Convert Skin::relevantUser to UserIdentity" 2021-07-13 18:57:27 +00:00
jenkins-bot
9fe2383f8d Merge "links is flat array" 2021-07-13 18:23:36 +00:00
jdlrobson
120ecc6d1b links is flat array
Pass a valid key to makeLink rather than an integer (index)
which may result in an exception.

Bug: T286040
Change-Id: Ic69ec102caec982e65e264f5812ac15df5168008
2021-07-13 18:00:16 +00:00
jdlrobson
14188e13f0 Allow skins to wrap menu item link labels in spans
This is going to be needed for skins that support icons as
in the new mw-ui-icon implementation, labels must be wrapped
in spans.

This is made a skin option so skins can control.
It will be used in Vector (Ia2d2c86e61341b9900f9ac337ddd763252e0515f)

Bug: T191021
Change-Id: I2bfaebf5d766240b57d7baed445001a007634839
2021-07-02 15:21:46 +00:00
jenkins-bot
660180290c Merge "Make user-menu list items produce HTML consistent with other menus" 2021-07-01 22:46:45 +00:00
Ammarpad
a03354006e Provide preference to make skins responsive
Bug: T285402
Change-Id: I4e567199a92c0492dac0561a5c7844f6c5c239e6
2021-07-01 22:18:27 +01:00
jdlrobson
05a02a39fb Make user-menu list items produce HTML consistent with other menus
The `class` property on menu items applies to the <li> tag however
in the case of the personal tools menu for historic reasons it applies
to the anchor tag. To bring these in line, a new optional parameter
is added that is utilized inside SkinMustache. Given the method is
final we do not need to worry about skins extending this behaviour.

This is needed for the mw-ui-icon change as we want to separate
the <a> tag with the mw-ui-icon class from the padding of its container
on the <li> item.

This also makes use the "new" class is added to the userpage link rather
than the list item by using the link-class property. This does not impact
existing skins as the impact is the same before and after this change.

This will temporarily break skins making use of user-menu, but this was
introduced in 1.37 which has not been released yet, so it's okay to
introduce breaking changes. It is currently only used by Vector

Bug: T285960
Change-Id: If399dfff9bbdd3b03b2ca702face3ec5164bef11
2021-07-01 12:37:51 -07:00
Petr Pchelko
5adf116196 Convert Skin::relevantUser to UserIdentity
This is a breaking change, but I've reviewed all usages
and there's nothing that requires full User object to be
returned. Maybe it's too bold, following the deprecation
process is not too hard either.

Change-Id: Id22580945f594d7e0de533226f6c374a7a97fe1e
2021-06-30 13:09:05 -07:00
Thiemo Kreuz
2ba01c7ee7 Remove some more comments that literally repeat the code
… including PHPDoc tags like `@return <type> $variableName`.
A return value doesn't have a variable name. I can see that
some people do this intentionally, repeating the variable
name that was used in the final `return $var;` at the end
of a method. This can indeed be helpful. I leave a lot of
these untouched and removed them only when it's obviously
wrong, or does not provide any additional information in
addition to what the code already says.

Change-Id: Ia18cd9f25ef658b08ad25b97a744897e2a8deffc
2021-06-18 21:23:56 +00:00
Petr Pchelko
92564edc7c Use Message::page instead of Message::title
Also modified new APIs added to ApiErrorFormatter to
use PageReference instead of Title.

Change-Id: I093c89f8e1e6d383603f887358be6ece70f23a02
2021-06-09 13:18:22 +00:00
jenkins-bot
fbb29d06f5 Merge "Skin: Remove duplicated code" 2021-06-03 01:23:53 +00:00
Isarra
6268b3a708 Skin::getCopyrightIcon: ensure it hasn't been unset in config
Sysadmins could unset the entire copyright array in FooterIcons.
Might as well make sure it exists at all before checking if it has
something usable. Also simplifies related testing.

Change-Id: I56e06d564a9d60851d10e69065fd70dd51025bd2
2021-05-23 19:09:28 +00:00
Ammarpad
88fb4dd871 Skin: Remove duplicated code
This check is now in Skin::getRelevantUser() method itself and
so is pointless to repeat.

It was supposed to be removed in I177cd83 but was restored
unintentionally in one of the rebases

Follow-up: I177cd83a9c4f87c27a63d8f530c40895d0f3f5dd
Change-Id: Ic1758775ecd6992e162f1e7461a9ae7afdc9bcd0
2021-05-10 16:32:52 +00:00
vladshapik
9cc797695b Hard deprecate User ::isIP, ::getOptions
Bug: T275602
Change-Id: Id4be13751ca0a900e51214c1855a4624077a5a62
2021-04-26 16:10:24 +00:00
jenkins-bot
f05d54738b Merge "Fix annoying E_NOTICE about undefined 'alt' index in Skin#makeFooterIcon." 2021-03-28 02:17:55 +00:00
Cormac Parle
679497c171 Allow public access to getter for default search page
Bug: T273979
Change-Id: I241a9cce679c7b42ff749c6236299d82b94db669
2021-03-24 14:20:56 +00:00
jenkins-bot
8a21504083 Merge "Allow top-right search form target to be modifiable" 2021-03-16 14:44:50 +00:00
Ammarpad
1c8cda3e87 Skin: Restore use of Authority in place of PermissionManager
This was done originally in Ie530051, but it seems was partially
reverted when I177cd83 was merged.

Change-Id: Ib699f3519a12b442adcd31938a1394918f3a74f7
2021-03-15 07:55:29 +01:00
Cormac Parle
adda9c0555 Allow top-right search form target to be modifiable
Before this patch, if 'search' is in the request params then we always
go to Special:Search. Also, the 'title' param on the top-right search
form is always set to Special:Search, which means that form always goes
to Special:Search too.

In order to allow the search form to go to a different page, this
patch:
1. moves the hardcoded redirect to Special:Search based on 'search' in
the request params, so that it only happens if we cannot determine
the page title in the usual way
2. adds a setter for the default search page title in \Skin, so that
it can be set in a hook

Bug: T273879
Change-Id: If62573d19ca76ed1db53a5117182172233e514ab
2021-03-12 17:38:13 +00:00
jenkins-bot
cd083821aa Merge "Use getHTMLTitle instead of getDisplayTitle" 2021-03-10 11:26:55 +00:00
jdlrobson
8d0edcda45 Use getHTMLTitle instead of getDisplayTitle
Per docs, getHTMLTitle
Return the "HTML title", i.e. the content of the "<title>" tag.

getDisplayTitle can return HTML

Bug: T157145
Change-Id: Ib9aa89d10a1263308b5426306f2c8b046084553b
2021-03-08 12:26:46 -08:00
Ammar Abdulhamid
242b9b2f6a Enforce concealment of hidden RelevantUser at Skin level
Skin is what takes a user or extract it from a title to set relevant
user and so this is the right place to handle permission check too
because if the user is hidden, it should be made known for all
callers, instead of hoping each caller will do similar check
which is duplication and not guranteed.

Skin:setRelevantUser always takes user and this is now typehinted to
avoid errors. Callers need to give what's required.

Bug: T120883
Change-Id: I177cd83a9c4f87c27a63d8f530c40895d0f3f5dd
2021-03-08 15:38:07 +01:00
Petr Pchelko
ea185c872e Rename Authority::getPerformer() to ::getUser()
We started to call Authority argument $performer everywhere,
and $performer->getPerformer() doesn't look that good.

Change-Id: Id2cf3f27b18340314e4ed1ea9931ad9404b4df6f
2021-03-04 12:45:28 -07:00
Petr Pchelko
bb990c7e94 Convert skin code to Authority where ready
Change-Id: Ie530051d7abb3137e0e79114cb01dbb129ae0fe0
2021-02-23 21:04:19 -07:00
jdlrobson
a3a4e6ad74 Add to configuration to allow addition of certain tags to page
The following fields are needed for the display of Twitter cards
In conjunction with Ie5889b4a4a5685298fe00ecced0dbebb91d7f87c this
should provide the minimum to let cards render on Twitter.

By default this change will have no effect on page rendering,
to avoid any conflict with existing solutions, for example in
Wikidata.org.

Bug: T157145
Change-Id: I7f6cf7b415ad122b24c428cee2df2d3fed362395
2021-02-18 21:40:59 +00:00
mainframe98
c40f955312 Skin: Add notifications and user-menu content navigation
This allows separating notifications from personal tools.
The notifications are still inserted into the personal tools,
after the userpage, for skins using BaseTemplate, skins that
call buildPersonalUrls without the argument, skins that call
either getStructuredPersonalTools, makePersonalToolsList without
providing it personal tools or getPersonalToolsList.

Mustache skins that use data-personal are unaffected, and can
retrieve personal tools without notifications from data-user-menu
and notifications from data-notifications, both of which are in
the data-portlets array.

Notifications are manually inserted in both SkinTemplate and
SkinMustache to prevent calling buildPersonalUrls multiple times.

For backwards compatibility with user code and gadgets, the new
user-menu portlet uses the same id and classes as the personal
tools, allowing it to serve as a drop-in replacement.
Skins shouldn't output both.

Bug: T266613
Depends-On: Ib4112364c173952eb363e52756f03693a2e03512
Change-Id: Ia1451e3e802441162eecfc5b7f6a7ba2ae72f377
2021-01-26 22:33:40 +00:00
jenkins-bot
658cb99a4b Merge "Emit deprecation warning for deprecated overrides." 2021-01-13 04:06:55 +00:00
daniel
8a7d487545 Emit deprecation warning for deprecated overrides.
This introduces a utility method in MWDebug, and uses it to clean up
the deprecation mechanism for Skin::setupSkinUserCss().

Bug: T257990
Bug: T267080
Change-Id: I5b07fa82dcc2b0fd112f122e45c9b2562cd09247
2021-01-08 19:33:57 +01:00
Krinkle
34ab93a6b8 Revert "Provide native support to dismiss sitenotice in core."
This reverts commit 14ce139f94.

Bug: T271365
Bug: T259903
Change-Id: I31ed9488297e516920a2183e4311357ffdd098a7
2021-01-06 15:45:15 -08:00
Umherirrender
e9e784a09e build: Enable phan-taint-check-plugin and suppress issues
Taint check checks for possible security issues by tracking html
escaping and more by using phan.
This slows done the phan-job a bit and requires more ram

Keep the DoubleEscaped issues out to make reviewer easier

Adds suppression for false positives
Adds taint-annotation to help taint-check
Removes suppression for code phan now understand better by the tracking
of keys in taint-check
Fix some small issues by adding int cast or htmlspecialchars calls

Bug: T216348
Bug: T268920
Change-Id: I849ac4f120fd15b483e8939d4db45c98dc351259
2020-12-30 19:02:22 +01:00
jenkins-bot
5c6a4e0c71 Merge "Deprecate Skin::getSkinStylePath()" 2020-12-23 16:00:23 +00:00
Ammarpad
77386bea18 Deprecate Skin::getSkinStylePath()
It's more easier for every skin to construct this link as
there is no need for error handling if they do that. It will
also eleminates the need for $stylename property which is the
only reason some skins are extending abstract Skin class now.

Bug: T270754
Change-Id: I64be6cbe1742f2f5fbdb5c3c920c9910cfbd8b72
2020-12-23 06:59:44 +01:00
Ammar Abdulhamid
14ce139f94 Provide native support to dismiss sitenotice in core.
This patch adds a private method and other mechanisms to handle
generation of dismiss button for site notices (which are already
generated by core).

It also adds the $wgDismissableSiteNoticeForAnons global with its
default as set in the DismissableSiteNotice extension. The plan is,
however, to deprecate it later.

Native support will streamline the sitenotice processing and helps
towards more optimum default MediaWiki experience. It will also
eventually obsoletes the need for an extension to provide this crucial
button as well as remove the overhead of managing such extensions.

Bug: T262118
Bug: T259903
Depends-On: Ib80fc24c84eb333daa016c9816fdf91cc60d3983
Change-Id: I276325dc55fd475655e0212fc256b95ebb41b276
2020-12-22 08:04:44 +01:00
James D. Forrester
abdc94a3da Swap out uses of User->isLoggedIn() with ->isRegistered()
Bug: T270450
Change-Id: I90ff94a553ebae9a4ef97c25c333f067f19c327d
2020-12-22 03:13:37 +00:00
Reedy
d2781d9b5c Cache some context and service variables
Change-Id: I1217d9d5112774bb3ad124605239dcc1705ab2eb
2020-12-20 01:32:07 +00:00
DannyS712
b5e7f210cd SECURITY: Act like users don't exist if hidden from viewer
When viewing Special:Contributions for a hidden user and
a missing user, or the user page of a hidden user and a
missing user, if the viewer cannot see hidden users
the output should be the same for hidden users and
missing users.

To that end
* In OutputPage.php, only set the `wgRelevantUserName` javascript
  variable if the user is not hidden, or the viewer can see hidden
  users
* In Article.php, show the `userpage-userdoesnotexist-view` on user
  pages of hidden users if the viewer cannot see hidden users
* In Skin.php, do not add user-specific sidebar links (contributions,
  logs, mute, etc.) if the user is hidden and the viewer cannot see
  hidden users
* In SpecialContributions.php, stop calling Skin::setRelevantUser
  for non-existing users, so that callers of Skin::getRelevantUser
  can ignore users that are hidden from the viewer without creating
  divergent behavior
* In SpecialContributions.php, for users that do exist but are
  hidden from the viewer, don't show `sp-contributions-footer`,
  but do show `contributions-userdoesnotexist`

Bug: T120883
Change-Id: I83b723402f315447bc4b50992e28620e3daace8f
2020-12-18 00:35:54 +00:00
Reedy
b2f16234ca Revert "Define Skin RelevantUser for IP ranges"
This reverts commit 435b44ee15.

Reason for revert: Broken per T206954, followups aren't ready

Change-Id: Iea631b25fcf4924801eba591b1dcffd6aea26e61
2020-12-17 23:19:31 +00:00
jenkins-bot
d26a689edd Merge "Define Skin RelevantUser for IP ranges" 2020-12-16 20:01:03 +00:00
jenkins-bot
870658f1cb Merge "Skin: Limit credits factory creation to when $wgMaxCredits !== 0" 2020-12-16 03:50:51 +00:00
jdlrobson
bdf44d7356 Skin: Limit credits factory creation to when $wgMaxCredits !== 0
Bug: T270135
Change-Id: I64e3aebd8f5d9ac1bac9c54d93d9c5429eb2d6a2
2020-12-16 03:25:52 +00:00
Reedy
bd21266808 Skin: Remove unused $request variable
Change-Id: I8c12cb38194180403380405d2358e9abe5d309a0
2020-12-16 01:38:07 +00:00
jenkins-bot
7fff9280af Merge "Avoid reuse of message contributions for linking" 2020-12-12 20:39:53 +00:00