Commit graph

382 commits

Author SHA1 Message Date
Reedy
6b6c71558e Fix PreferencesForm alias
Change-Id: I6f24c6283b4165b9209e53f8fc3b8ecb5feb9ca4
2018-05-29 21:44:18 +00:00
Bartosz Dziewoński
c513ec19ef Restore 'PreferencesForm' as alias for 'PreferencesFormLegacy'
In change 4633f4d46a it was changed
to an interface implemented by both PreferencesFormLegacy and
PreferencesFormOOUI so that existing typehints for some functions
parameter would accept them both. Replace those typehints to use
HTMLForm instead. There was really no guarantee in the past that
they would only be given PreferencesForm or its subclasses, either.

Because the typehint change affects some hooks, note it as a
deprecation in MW 1.31 and a breaking change in MW 1.32.

Also add @since tags and correct some typos in code comments.

Follow-up to 4633f4d46a.

Change-Id: I61749f1d864cf68afe90cd9e15ba2d7a74252501
2018-05-24 21:20:50 +00:00
Umherirrender
3124a990a2 Use ::class to resolve class names in includes files
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I07a925c2a9404b0865e8a8703864ded9d14aa769
2018-01-27 20:34:29 +01:00
Max Semenik
55497cdc1a Phan: resolve and reenable PhanAccessMethodProtected
Change-Id: I2bd7c787012f4f54600f3289d9d0d725f87788bc
2018-01-23 09:31:13 -08: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
Umherirrender
23ef520a1c Improve some parameter docs
Change-Id: I31e983d7ac287158101b18ad95779d83537302a2
2018-01-07 11:39:08 +01:00
Sam Wilson
2e248f0bb2 Convert Preferences class into PreferencesFactory service
This deprecates the Preferences class and replaces it with
a PreferencesFactory service. Basically, all code from Preferences
is moved into DefaultPreferencesFactory. All Prefereces methods
are now either shims calling DefaultPreferencesFactory or just
throw exceptions.

Bug: T178449
Change-Id: Id0b2db0c2de0890f6e1609a9a0dca207c4600f99
2018-01-03 09:48:25 +08:00
David Barratt
b39ce8f791 Allow users to prevent new users from sending them email.
Users now have the option to prevent Newbie users from sending
them emails.

Bug: T138165
Change-Id: I5d5332e50971fbcd1fa630d6bd03bdf757a9d1f1
2017-12-11 22:04:18 -05:00
Bartosz Dziewoński
4ca2866a93 Preferences: Display the default skin first in the list
Bug: T181112
Change-Id: If3de084b2a5f214f7d6d05b86daed151a23678a4
2017-12-07 20:01:11 +01:00
Bartosz Dziewoński
737e7f9bc9 Preferences: Sort list of skins by internal name
Sort by the internal name, so that the ordering is the same for each
display language, especially if some skin names are translated to use
a different alphabet and some are not.

Bug: T181112
Change-Id: I763150cc578e9aa70990a53895c032f17d96e97a
2017-12-07 20:01:11 +01:00
jenkins-bot
490035943c Merge "RCFilters: Make 'days' and 'limit' sticky" 2017-12-05 11:46:37 +00:00
Bartosz Dziewoński
808e45d13d Revert "Special:Preferences: Use OOjs UI" and follow-ups
The number of issues with the new interface is unacceptable and we
will not be able to fix them reasonably quickly. See subtasks of
T180538 for the list of issues, raised both by the Wikimedia community
and by WMF employees.

I should have pushed back harder against the merging of this half-baked
change with the promise that we'll fix it later. I convinced myself
that the regressions were not so noticeable and that the issues that
were pointed out will in fact be fixed by someone. Predictably,
however, regressions were bad and the only person fixing the issues
was me.

I am not going to work nights to make this page decent again within a
reasonable timeframe; I'm not sure if I'd even be able to since many
issues are problems with the design rather than the implementation. No
one else seems to be working on improving it, therefore I am reverting
the change.

On the bright side, this work has resulted in a number of improvements
to HTMLForm and Preferences code, which are not being reverted here:
<https://gerrit.wikimedia.org/r/#/q/topic:T117781>.

If anyone reattempts this, I recommend gating the new interface behind
a configuration variable and URL parameter, like we did with
$wgOOUIEditPage in the past, and testing thoroughly in production
before enabling it for everyone.

* Revert "Special:Preferences: Use OOjs UI"
  This reverts commit 486e566cfe.
* Revert "Preferences: Show preview of edit fonts in edit font selector"
  This reverts commit 6634ff729d.
* Revert "Follow-Up Iae63b6994: Add missing editfont dependency"
  This reverts commit ce42fdf151.
* Revert "Preferences: Improve visual appearance by “unboxing” sections"
  This reverts commit c9415bb005.
* Revert "Remove box-shadow from preference panels for ooui-apex"
  This reverts commit a934b82ca2.
* Revert "Preferences: Don't show the watchlist token; just link to ResetTokens"
  This reverts commit e8c9102fc7.
* Revert "mw.special.preferences: Make the "Basic information" section more compact"
  This reverts commit d48b7260f3.
* Revert "mw.special.preferences: Widen the dropdown of the "Time zone" field"
  This reverts commit afd5f1417e.

Bug: T117781
Bug: T180538
Change-Id: I44b5daea1828f71881b5bd35218f5ecb7ab7f36e
2017-12-02 22:32:08 +01:00
Moriel Schottlender
86d1c0bc00 RCFilters: Make 'days' and 'limit' sticky
* Each has a hidden preference to override the preferences value
* Each value is different between Watchlist and RecentChanges
* rcfilters-limit is updated when rclimit is changed
* Not conditionally hiding the rcdays, watchlistdays and wllimit yet
  because hide-if's behavior is annoying

Bonus:
* Add a static method to check whether RCFilters UI is enabled
  and enabled by default. Adjust the call for Watchlist which
  checks a slightly different configuration setup.

Bug: T174415
Change-Id: Ib933de3a3f9e876924386e80f315506f60f8af54
2017-12-01 13:00:05 -08:00
James D. Forrester
e8c9102fc7 Preferences: Don't show the watchlist token; just link to ResetTokens
Also make both the PasswordReset and ResetTokens forms appropriately
flag their action buttons as destructive.

Bug: T180710
Change-Id: I26649900f9360e5175fa93b87dc7840a7c1d4f93
2017-11-20 23:53:16 +00:00
Bartosz Dziewoński
eed3cf7747 Preferences: Remove unwise caching of Preferences::getPreferences()
The result of this function depends on the $user and $context
parameters (e.g. it includes the username from the user, and
localisation messages the language from the context). However,
both of them would be ignored if the result was cached, even
if calling with a different $user or $context.

Rather than make this more complicated just remove the caching.
This is not a hot code path: this function is not called at all
on normal page views, it's called just once when viewing
preferences, and at most twice when saving them.

Change-Id: I92390120a16448383a25e9ba2dd35a434a2f21bf
2017-11-15 11:04:52 +00:00
Bartosz Dziewoński
486e566cfe Special:Preferences: Use OOjs UI
* Change the form to OOUI mode. Tweak some formatting to look better
  with this mode. Change various random links to be OOUI buttons.
* Rewrite custom tabs to use OO.ui.IndexLayout instead.
* Update styles and JS enhancements for OOUI widgets.
* Rename ResourceLoader modules so that old skin-specific styles
  (from $wgResourceModuleSkinStyles) no longer apply. They tend
  to make no sense with the OOUI styling.

Bug: T117781
Change-Id: Ie9396f0146f5020e52710c41e55ec86151ae0095
2017-11-13 20:51:09 +01:00
Ori Livneh
a603ae73a7 Fix letter-case of several namespace and class names
'Mediawiki\Widget\SelectWithInputWidget' is the only one that shows up
in the logs, but I tidied up a few others I came across.

Change-Id: I700dec858007a8013e6d7b9e37ddf518f223d8b7
2017-10-14 21:43:05 -04:00
Fomafix
ea0bd74a94 Refactor global function wfBCP47 to static function LanguageCode::bcp47
Deprecate global function wfBCP47.

Change-Id: Ie6bb061b5d6ca67289bb18bc468a87421f38fc94
2017-10-05 09:54:45 +02:00
jenkins-bot
f58546ef6e Merge "RCFilters: Convert saved queries from filters to parameters" 2017-10-03 20:51:51 +00:00
jenkins-bot
059fdf444e Merge "Remove 'Browser default' editfont option" 2017-10-03 18:46:52 +00:00
Moriel Schottlender
c7b6b598ca RCFilters: Convert saved queries from filters to parameters
This will allow us to load them in the backend, and to keep
consistency between RecentChanges and Watchlist if needed.

Added also a 'backup' preference to keep the previous version
before the conversion, in case of mangling of the queries.

Bug: T166908
Change-Id: I8e26b66e43bd16282b7bdb52abc152f92a9c877d
2017-09-29 14:07:11 -04:00
petarpetkovic
85df9a3a0e Move New Filters opt-out preference to own section
- Add a new section to preference page with the following title:
"Opt out of improvements".
- Move the opt-out option and explanatory text to this new section.

Bug: T175765
Change-Id: Iaf77df2eec714777f54b95b58eb617b5e35bef75
2017-09-18 16:23:25 +02:00
Bartosz Dziewoński
265ff105aa Preferences: Do not set non-breaking space as a label
If there's no label, there's just no label. No need to pretend.

Change-Id: I6b7065a23ba6532641989682d802613e0545f7e8
2017-09-16 15:23:08 +02:00
jenkins-bot
870eaf7c95 Merge "Allow users to restrict who can send them direct emails via Special:EmailUser" 2017-09-14 01:02:25 +00:00
Bartosz Dziewoński
352cea4a94 Fix submit button id on Special:Preferences
For reasons beyond human fathoming, the button had the id set
to 'prefsubmit' in PHP code and then changed to 'prefcontrol'
in JS code. This functionality has been carefully preserved
across multiple rewrites of this code since 2004, when it was
added in 30d0ccd0 (rSVN3618). Let's just set the id in PHP.

Change-Id: Ib23bd0e481e73a51ff0a16731f47a2df11b2c1b8
2017-09-13 22:06:51 +02:00
David Barratt
ce3960ec31 Allow users to restrict who can send them direct emails via Special:EmailUser
Users can now specify a blacklist of users who are prevented from sending them a direct email.

Bug: T138166
Change-Id: Ifa26153f593b0ca3a9121e1e29961911c616c9e4
2017-09-13 11:28:12 -06:00
Bartosz Dziewoński
06daf807ca Split off remaining helper classes for special pages to separate files
includes/specials/formfields/
* EditWatchlistCheckboxSeriesField (for SpecialEditWatchlist)
* UploadSourceField                (for SpecialUpload)
* Licenses                         (for SpecialUpload)

includes/specials/forms/
* EditWatchlistNormalHTMLForm      (for SpecialEditWatchlist)
* PreferencesForm                  (for SpecialPreferences)
* UploadForm                       (for SpecialUpload)

includes/specials/helpers/
* ImportReporter                   (for SpecialImport)
* License                          (for SpecialUpload)

Change-Id: I58abcbb44dbf9bf1762b4252555f7552bfa7c253
2017-09-12 23:22:58 +02:00
James D. Forrester
c12b241929 Provide an opt-out preference for New Filters for RecentChanges
Currently this is disabled by default. On wikis with the BetaFeatures and
WikimediaMessages extensions installed, this preference is set (if the
$wgEnableRcFiltersBetaFeature flag is set) via BetaFeatures. This change
lets users on normal wikis use these too, and lets BetaFeatures-capable
wikis "graduate" the feature to be provided to all users by default.

Bug: T168376
Change-Id: I3c75f9f2f6287414bf330f116d959d078250392d
2017-09-11 22:56:00 +00:00
Ed Sanders
3da079ec6f Remove 'Browser default' editfont option
Bug: T170223
Change-Id: I1ace59c980740fc785ccbd500e19cc8b71d46a5b
2017-08-25 18:35:53 +01:00
jenkins-bot
d455aa29a6 Merge "Don't hard-code Preferences page name" 2017-08-21 22:41:17 +00:00
Sam Wilson
2a416c57d5 Don't hard-code Preferences page name
This fixes the restore-prefs link by switching to use whatever
the current title of the PreferencesForm is.

Bug: T173682
Change-Id: I67a13269a63f719a011a2d59a07493d9eb6b653b
2017-08-22 06:27:34 +08:00
jenkins-bot
e7720b8f8e Merge "Change 'editfont' default preference to 'monospace'" 2017-08-21 16:42:23 +00:00
Stephane Bisson
c06e5256db Enable RCFilters app on Watchlist
* Add classes prefixed with cl (for ChangesList)
  to both RC and WL so that the JS app can locate
  similar elements using the same selectors

* Make saved queries preference name configurable
  so that RC and WL use different preferences

* Move some code from SpecialRecentchanges.php to
  its base class so it's accessible to SpecialWatchlist.php

To use the RCFilters app on WL, append ?rcfilters=1 to the URL

Bug: T171132
Bug: T171218
Change-Id: If7c63284224df24fa02022b4ea74bef116f28ca6
2017-08-18 15:34:27 -04:00
Geoffrey Mon
700e49dddd Unwatch link for pages in Special:Watchlist
When the 'watchlistunwatchlinks' preference option is enabled, this
adds a '×' link to each entry of the watchlist that unwatches the page
of that entry. When clicked, it changes into a '+' which can be used to
re-watch the page (effectively undoing the earlier unwatch).
When a page is unwatched, its entries and the entries of its associated
talk page (or vice versa) become translucent and are struck through.

Without JS, '×'/'+' link to action=(un)watch for the relevant page.

In addition, ChangesList classes have been modified to allow a prefixer
that adds a prefix to each line (used in this case to put the unwatch
link) and to add HTML data attributes to reliably determine the target
page of each entry. Unit tests have been updated accordingly.

Bug: T2424
Change-Id: I450b2901413d7e75c11de2a446829fdbb22d31e1
2017-08-12 19:36:29 -04: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
Roan Kattouw
c2d427d370 Set a min and max on the rclimit preference
The same values as wllimit.

Change-Id: I1fbc063455799f7d886d26c7030662f431feb627
2017-08-04 16:45:21 -07:00
Moriel Schottlender
155d1f91d1 RCFilters: Create a sticky preference for days/limit groups
- Add sticky preference for groups and the operation behind
  it.
- Allow normalization from the UriProcessor
- Backwards-compatibility for saved queries
- Allow saved queries to load regardless of sticky params
  and to be compared correctly without the sticky params.
- Add days/limit preferences and update those on change
- Update the preference even if we received a new value
  from the URL.

Bug: T171514
Bug: T171368
Change-Id: I5232f3372f0e5c981332d152faf0ab47cc470b56
2017-07-28 16:06:30 -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
James D. Forrester
af2a215483 Change 'editfont' default preference to 'monospace'
Also change the user preference order to put the default first and the
least-good option last.

Bug: T171201
Change-Id: Ib4c6cd7f2d98824313c2bfcdf3f71d89fc48c929
2017-07-20 12:13:50 -07:00
Piotr Miazga
d8101d8ba1 Pass old user options in PreferencesFormPreSave hook
Changes:
 - added one argument to PreferencesFormPreSave hook,
   a $oldUserOptions array which contains set of all user
   options before save
 - updated documentation

Bug: T169365
Change-Id: I28003c5898d64031e1efb212cb0bec58ff44b958
2017-07-05 17:12:12 +02:00
Moriel Schottlender
8936e6455a RCFilters UI: Add a 'saved queries' quick filters feature
Bug: T151994
Bug: T164128
Change-Id: I5cede87633147736d3b4ee5b8ea178ae21bd441f
2017-05-08 16:20:44 -07: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
This, that and the other
73224f4f8b User group memberships that expire
This patch adds an ug_expiry column to the user_groups table, a timestamp
giving a date when the user group expires. A new UserGroupMembership class,
based on the Block class, manages entries in this table.

When the expiry date passes, the row in user_groups is ignored, and will
eventually be purged from the DB when UserGroupMembership::insert is next
called. Old, expired user group memberships are not kept; instead, the log
entries are available to find the history of these memberships, similar
to the way it has always worked for blocks and protections.

Anyone getting user group info through the User object will get correct
information. However, code that reads the user_groups table directly will
now need to skip over rows with ug_expiry < wfTimestampNow(). See
UsersPager for an example of how to do this.

NULL is used to represent infinite (no) expiry, rather than a string
'infinity' or similar (except in the API). This allows existing user group
assignments and log entries, which are all infinite in duration, to be
treated the same as new, infinite-length memberships, without special
casing everything.

The whole thing is behind the temporary feature flag
$wgDisableUserGroupExpiry, in accordance with the WMF schema change policy.

The opportunity has been taken to refactor some static user-group-related
functions out of User into UserGroupMembership, and also to add a primary
key (ug_user, ug_group) to the user_groups table.

There are a few breaking changes:
- UserRightsProxy-like objects are now required to have a
  getGroupMemberships() function.
- $user->mGroups (on a User object) is no longer present.
- Some protected functions in UsersPager are altered or removed.
- The UsersPagerDoBatchLookups hook (unused in any Wikimedia Git-hosted
  extension) has a change of parameter.

Bug: T12493
Depends-On: Ia9616e1e35184fed9058d2d39afbe1038f56d7fa
Depends-On: I86eb1d5619347ce54a5f33a591417742ebe5d6f8
Change-Id: I93c955dc7a970f78e32aa503c01c67da30971d1a
2017-01-27 09:24:20 +00:00
Yuriy Shnitkovskiy
55667f024d Replaced all deprecated Linker methods with proper ones in core(1)
Change-Id: Ie3a718dc1eae1507f8829fcf419c64c6846d2cb6
2017-01-20 11:46:13 +02:00
Chad Horohoe
0fa3413576 Remove cols and rows preferences
In https://gerrit.wikimedia.org/r/80061/, Chad was convinced this
preference is barely used and mostly set to weird values by people
who don't understand what they're doing.

He made some quick stats: http://p.defau.lt/?fgGU0StB4J9l0LC5GZq8AA

Used defaults of 80 columns and 25 rows in places that still
were asking for it. The old default values are left in
$wgDefaultUserOptions for now, since various extensions are
using them.

The 'rows' and 'columns' messages don't appear to be in use in
any extensions in Git, so I killed those as well.

(This is the same as I642188c74d929a586b1882a1cf8656056c4fcf5a.)

Bug: T26430
Change-Id: I6c9802bc4f9cf32fb75c3dd7b9e2dc18f271eedf
2017-01-09 21:56:57 +11:00
jenkins-bot
6f19bac695 Merge "Proper handling of invalid/unknown time zones" 2017-01-05 15:11:02 +00:00
Bartosz Dziewoński
0cccd68dc8 Code style: no space after unary minus operator
Searched for /([^\d\w\s\)\]]\s*)- \d/ to find potential issues.
It seems there's no PHPCS check for this, huh.

Also fixed typo in a comment in LoginSignupSpecialPage.

Change-Id: Iaab1a1f5a9f234971e550e7909aa5c3e0c02a983
2017-01-05 14:38:32 +01:00
This, that and the other
2b2cda890b Proper handling of invalid/unknown time zones
Currently, a user who has an invalid time zone stored in the database is
effectively locked out of their account on HHVM sites. This patch addresses
this by (1) preventing users from setting invalid time zones, and (2) not
throwing an unhandled exception if a user's TZ is unknown.

When the user saves their preferences, the code silently rewrites invalid
time zones to UTC. I think this is OK, since to cause this to happen you
have to manually muck around with the Preferences page DOM or submit the
form from a script.

Bug: T137182
Change-Id: I28c5e2ac9f2e681718c6080fb49b3b01e4af46dd
2017-01-05 05:24:45 +00:00