Commit graph

106 commits

Author SHA1 Message Date
Sam Wilson
5e0fd6d664 Remove PreferencesFactory::setUser()
This method was recently added and was to result in the deprecation
of a few places where User objects were being passed to the factory.
This has now been reconsidered and this patch reverts to the
previous behaviour. It is largely a revert of Ie1bed9e9537cabc836992ccfa7fb127885ea3e11

Bug: T238466
Depends-On: Idc9f33fd5ab55bde88cc306ca63adead286380a8
Change-Id: I3653559704ccfd9bca0946f5a865be93bdf5ceb6
2020-06-08 00:27:04 +00:00
jenkins-bot
8d7015037d Merge "MultiTitleFilter: Use prefixed text for form display" 2020-06-02 15:58:03 +00:00
Kosta Harlan
d51ed7c3d2 MultiTitleFilter: Use prefixed text for form display
This allows us to distinguish between "Foo" and "User:Foo" in the UI.

Follows-Up: Ia0ddf78646ec4c8ae0b84b6d5b46ef5e51c8e8c1

Change-Id: I960cbd566e444380a253bde364bc9da7e2975823
2020-06-02 12:23:35 +00:00
Tim Starling
68c433bd23 Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.

General principles:
* Use DI if it is already used. We're not changing the way state is
  managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
  is a service, it's a more generic interface, it is the only
  thing that provides isRegistered() which is needed in some cases,
  and a HookRunner can be efficiently constructed from it
  (confirmed by benchmark). Because HookContainer is needed
  for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
  SpecialPage and ApiBase have getHookContainer() and getHookRunner()
  methods in the base class, and classes that extend that base class
  are not expected to know or care where the base class gets its
  HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
  getHookRunner() methods, getting them from the global service
  container. The point of this is to ease migration to DI by ensuring
  that call sites ask their local friendly base class rather than
  getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
  methods did not seem warranted, there is a private HookRunner property
  which is accessed directly. Very rarely (two cases), there is a
  protected property, for consistency with code that conventionally
  assumes protected=private, but in cases where the class might actually
  be overridden, a protected accessor is preferred over a protected
  property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
  global code. In a few cases it was used for objects with broken
  construction schemes, out of horror or laziness.

Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore

Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router

setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine

Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-05-30 14:23:28 +00:00
jenkins-bot
4602f8db2d Merge "Disable parsing of prefs-memberingroups message" 2020-05-26 06:47:15 +00:00
jenkins-bot
4a5c7b4e84 Merge "Deprecate no LanguageNameUtils constructing DefaultPrederencesFactory" 2020-05-11 21:13:20 +00:00
Sam Wilson
36defc20eb Add PreferencesFactory::setUser()
Add a new setUser() method to PreferencesFactory so that a User
object doesn't have to be passed around so much. This is how
GlobalPreferencesFactory has done it, and so after this change
that code can be removed from GlobalPreferences.

Bug: T238466
Change-Id: Ie1bed9e9537cabc836992ccfa7fb127885ea3e11
2020-05-06 09:04:08 +08:00
Petr Pchelko
2501625352 Deprecate no LanguageNameUtils constructing DefaultPrederencesFactory
Depends-On: I3e30bc01ec9333d03e1282a21ae8953ae1f7c770
Change-Id: Ifd9628469bf72ffaa6ab75415ee18edd416cffe2
2020-05-05 16:41:31 -07:00
Kosta Harlan
7880815b4d Add MultiTitleFilter class
Add a new preference filter for use with HTMLTitlesMultiSelectField, to simplify
the process of saving article text as IDs in user preferences, and reading those
IDs back to text for presentation in the form.

Example usage in the Echo extension: I67f751eae5fdc5bccff7fe3047227d432c1cb8d5

Change-Id: Ia0ddf78646ec4c8ae0b84b6d5b46ef5e51c8e8c1
2020-04-28 14:06:51 +00:00
Peter Ovchyn
7d57b967b5 deprecation: Remove DeprecationHelper::newArgumentWithDeprecation and change callers accordingly
Bug: T245075
Change-Id: I0714b1c5d5a379cfe3ca473b72244d4d6bd1b7b8
2020-04-27 20:23:58 +03:00
jenkins-bot
f898b49c98 Merge "docs: Hook interface doc comment review" 2020-04-21 06:41:19 +00:00
jenkins-bot
cc89a81451 Merge "Automatically generated hook interfaces" 2020-04-21 00:07:41 +00:00
apaskulin
c44488f725 docs: Hook interface doc comment review
Edited doc comments for hook interfaces to improve
consistency and add type hints.

Bug: T246855
Change-Id: I38fa802463cd6f39bf5946dbbeb1b3ebaea604b2
2020-04-21 09:10:08 +10:00
Sam Wilson
368df9e5b5 Remove hash style comments and dividers
The modern style is to use forward slash comments, and the
dividers date from before this class was refactored to separate
these sections by method. Some @todos are also reformatted.

Change-Id: Ib642e83802cc78025ab22614a8e5fa9472d4bf59
2020-04-20 18:31:37 +08:00
Tim Starling
f5aaf75ad1 Automatically generated hook interfaces
Add hook interfaces which were generated by a script which parses
hooks.txt and identifies caller namespaces and directories.

Hook interfaces are mostly placed in a Hook/ subdirectory
relative to the caller location. When there are callers in multiple
directories, a "primary" caller was manually selected. The exceptions to
this are:

* The source root, maintenance and tests, which use includes/Hook. Test
  hooks need to be autoloadable in a non-test request so that
  implementing test interfaces in a generic handler will not fail.
* resources uses includes/resourceloader/Hook
* The following third-level subdirectories had their hooks placed in
  the parent ../Hook:
    * includes/filerepo/file
    * includes/search/searchwidgets
    * includes/specials/forms
    * includes/specials/helpers
    * includes/specials/pagers

Parameters marked as legacy references in hooks.txt are passed
by value in the interfaces.

Bug: T240307
Change-Id: I6efe2e7dd1f0c6a3d0f4d100a4c34e41f8428720
2020-04-20 13:31:05 +10:00
Timo Tijhof
50c3a47140 Setup: Move wgSkipSkins appendix to Skin::getAllowedSkins
This isn't a default setting or fallback, it's unconditional
business logic that can't be overidden. This doesn't need to
run on every web request in Setup.php.

Bug: T189966
Change-Id: I708131b111cd2ff0e34c3cc8a4b933eff260b3da
2020-03-13 23:45:12 +00:00
James D. Forrester
51ae353ab5 Special:Preferences: Split the unknown/neutral gender into label and help
The extensive label for the "how" of the form in English obscures the "what". By
splitting the radio button's label into a short "what" and retaining the current
message, which in English is currently *entirely* a "how", allows translators to
retain the opportunity to advise their users about the manner in which this will
affect their experience.

Change-Id: I5ca2fb56ee4b50bd6af9b13dfe3c50c1f661a4e8
2020-02-26 17:22:56 -08:00
Petr Pchelko
204fa7e509 Remove usages of deprecated Language methods
Change-Id: Iad3375b141b1d87c890baec6ecd16ed92f93e699
2020-02-16 00:45:48 +00:00
Peter Ovchyn
74b7a2bef9 parser: Inject a LanguageConverterFactory through DI containers:
Add braking changes into DefaultPreferencesFactory

Bug: T243321
Depends-On: I654620c1741c9f07f5c995f32292287b8d4a71ff
Change-Id: I0501cf49c5dc1dc7b157b475577cc9ebc380e8c7
2020-02-04 16:09:20 +02:00
Peter Ovchyn
50e3bd4fac parser: Inject a LanguageConverterFactory through DI containers:
1. into class Parser
2. into class LinkHoderArray
3. into class DefaultPreferencesFactory

Add more tests for DefaultPreferencesFactory:
1. testVariantsSupport verifies that converter with variants is used correctly.
2. Test testUserGroupMemberships verifies that membership is used correctly

Bug: T243320, T243321, T243317
Change-Id: I1e5c37e18332d0d32391c74c06e3d84862e48df8
2020-02-04 14:42:03 +02:00
Peter Ovchyn
61e0908fa2 languages: Introduce LanguageConverterFactory
Done:
* Replace LanguageConverter::newConverter by LanguageConverterFactory::getLanguageConverter
* Remove LanguageConverter::newConverter from all subclasses
* Add LanguageConverterFactory integration tests which covers all languages by their code.
* Caching of LanguageConverters in factory
* Make all tests running (hope that's would be enough)
* Uncomment  the deprecated functions.
* Rename FakeConverter to TrivialLanguageConverter
* Create ILanguageConverter to have shared ancestor
* Make the LanguageConverter class abstract.
* Create table with mapping between lang code and converter instead of using name convention
* ILanguageConverter @internal
* Clean up code

Change-Id: I0e4d77de0f44e18c19956a1ffd69d30e63cf51bf
Bug: T226833, T243332
2020-02-03 11:38:03 +02:00
Ammar Abdulhamid
116063f32f Disable parsing of prefs-memberingroups message
This prevents the double escaping and similar label messages
such as `prefs-registration` on the same page are already not parsed,
some could have been doubly escaped if they were too.

Bug: T142882
Change-Id: Icec32660a19543f4a97c8acc594b1c09e09f9aa1
2020-01-26 08:37:39 +00:00
Derick N. Alangi
4522b02ed7 preferences: Avoid use of deprecated Language::fetchLanguageNames()
Change-Id: I1f90e5aa78e5535b138d8bf2403c7dd002746f80
2020-01-19 16:57:52 +01:00
hmonroy
c353a6eb54 Move the PRU setting right before email confirmation label
Move the Password Reset Update (PRU) setting in user profile preferences
right before the `Email confirmation:` label.

Bug: T239938
Change-Id: Ib8bfd23e7bf94d3113846436d162cd3a059f115c
2020-01-15 13:24:30 -08:00
James D. Forrester
0958a0bce4 Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNull
Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
2020-01-10 14:17:13 -08:00
jenkins-bot
26a13a686e Merge "Add user preference info to basic info section" 2019-12-18 00:28:53 +00:00
hmonroy
d6d5ea5af9 Add user preference info to basic info section
Add informational text under the 'Basic information' section regarding
email user preference setting under 'Email option' section for users with
an associated email address.

Bug: T234952
Bug: T239937
Change-Id: I1a815db0e54673a69afb74506d97c1f6460cb7d1
2019-12-17 09:18:28 -08:00
Daimona Eaytoy
598c4d7fcb build: Upgrade phan to 0.9.0
Scalar casts are still allowed (for now), because there's a huge amount
of false positives. Ditto for invalid array offsets.

Thoughts about the rest: luckily, many false positives with array offsets
have gone. Moreover, since *Internal issues are suppressed in the base
config, we can remove inline suppressions.

Unfortunately, there are a couple of new issues about array additions
with only false positives, because apparently they don't take
branches into account.

Change-Id: I5a3913c6e762f77bfdae55051a395fae95d1f841
2019-12-07 20:16:19 +00:00
Bartosz Dziewoński
7f9dbcf016 preferences: Minor code cleanup
In preparation for bigger additions to this function
coming in next patches.

Change-Id: If8fc3222b5fdf8f18f73b39aff25a221e0e25f1a
2019-11-09 01:27:59 +01:00
Bartosz Dziewoński
251bb8c32d preferences: Remove duplicate error formatting
The <span class="error"> is not needed, the text is already formatted
as an error message by OOUIHTMLForm. Maybe it was needed in plain
HTMLForm back in the day, or maybe this was just always wrong.

Change-Id: I54dd401c059af849a91437d7a89aaa387c301e08
2019-11-08 20:37:18 +01:00
Cormac Parle
c4eae0dad4 Search: Provide new preference to control redirects on search matches
To avoid preference bloat, this preference is hidden unless the new
sysadmin config $wgSearchMatchRedirectPreference is set.

Bug: T235263
Change-Id: Ic16f53a4e6ddb6da071d63cd5da28d937d4692c8
2019-11-06 15:37:56 +00:00
Daimona Eaytoy
bd5b6f98ba Fix new phan errors, part 3
These are almost only doc changes, with two exceptions:
1-In LinkHolderArray, int-alike array keys are now cast to int, to be uniform with what we do in other code paths
2-In ExtensionRegistration, changed a line to throw an Exception
immediately, instead of an ExtensionDependencyError. This is because the
latter takes an array with msg and type, but we were passing it a plain
string (and in fact the code was bugged).

Bug: T231636
Change-Id: I8b0ef50d279c2a87490dde6a467a4e22c0710afd
2019-10-12 10:35:22 +00:00
James D. Forrester
17f3f9cee3 Services: Convert DefaultPreferencesFactory's static to a const now HHVM is gone
Change-Id: If24c5f120cb96311b50750c5b3022664dc6b20e5
2019-10-08 11:28:15 -07:00
jenkins-bot
4e9eb2f8d7 Merge "DefaultPreferencesFactory: Remove fallback for null PermissionManager" 2019-09-17 20:32:17 +00:00
Petr Pchelko
57cffc9e57 Break PreferencesFormOOUI->PermissionManager dependency
Depends-On: Id0f0bdb39b9e0be4d7c38c229371be04bb5aec5c
Change-Id: I9209cf26a27ab66306f61937b620bfe05c2045b0
2019-09-17 08:34:53 -07:00
Petr Pchelko
7b153651c1 DefaultPreferencesFactory: Remove fallback for null PermissionManager
Bug: T220191
Depends-On: Id0f0bdb39b9e0be4d7c38c229371be04bb5aec5c
Change-Id: Iaf43aada39663e48f10dd7d662e85891e568f8d4
2019-09-12 14:10:57 -07:00
Petr Pchelko
5ccb1a42c7 Make DefaultPreferencesFactory depend on PermissionManager.
Bug: T220191
Change-Id: I3f5c4340501d59b5ca63b096364b5cc8388cff80
2019-09-11 15:34:26 -07:00
Max Semenik
d7049bc973 Add a preference to require email for password resets
The actual functonality will come in a later commit.

Bug: T231495
Change-Id: I9977b0d51a2b89b79c199bc4423f123e581e2a2f
2019-09-09 12:11:46 -07:00
Daimona Eaytoy
c659bc6308 Unsuppress another phan issue (part 7)
Bug: T231636
Depends-On: I2cd24e73726394e3200a570c45d5e86b6849bfa9
Depends-On: I4fa3e6aad872434ca397325ed7a83f94973661d0
Change-Id: Ie6233561de78457cae5e4e44e220feec2d1272d8
2019-09-03 17:19:21 +00:00
Daimona Eaytoy
ed398c0253 preferences: Add typehint in saveFormData() for PreferencesFormOOUI
This was temporarily removed in 3bcf5655870f for compat with
the GlobalPreferences extension. The old typehint of HTMLForm
was incorrect (as discovered by a Phan rule that was disabled
for core), because getModifiedUser() only exists in the
PreferencesFormOOUI subclass.

Change-Id: I792286ed44f03467b5d875e61c52b1953252b55f
Depends-On: I4fa3e6aad872434ca397325ed7a83f94973661d0
2019-09-03 17:11:30 +00:00
Daimona Eaytoy
e2e543f7c2 Unsuppress more phan issues (part 5)
Bug: T231636
Depends-On: I6e5fba7bd273219b1206559420b5bdb78734aa84
Change-Id: I50377746f01749b058c39fd8229f9d566224cc43
2019-09-01 09:48:31 +00:00
Daimona Eaytoy
5eac6d131c Unsuppress more phan issues (part 3)
Bug: T231636
Depends-On: I78354bf5f0c831108c8f606e50c87cf6bc00d8bd
Change-Id: I58e67c2b38389df874438deada4239510d21654f
2019-08-31 16:38:55 +00:00
Max Semenik
d06baad826 Add more information to exception thrown
It's not just about the preference name, because current user's properties
are used for validation too.

Bug: T231029
Change-Id: I268b959017bb0dce2b4295d5302a544bfa3513eb
2019-08-26 19:03:09 -07:00
jdlrobson
789b5239f6 preferences: Fix skinname msg check in generateSkinOptions
Fixes a bug introduced in b2b204eeaf.

$useSkin is not the appropriate variable to check here - we want
to check the skin set in preferences.

Bug: T223824
Change-Id: I666e30dd9ff396fd39c47b362d66670dfaa92ca9
2019-07-30 22:37:24 +00:00
Umherirrender
f734e7b108 Fix ServiceOptions type in constructor documentation
Change-Id: I3fcde4e484ddd6d86e4ca12dcf5977051e7f4cf2
2019-06-06 21:59:27 +02:00
Dayllan Maza
6b886e25d2 Fix typo in docs
Change-Id: I69085afd4f3475ae6449a0e3683a28ccddf47445
2019-05-31 00:07:34 -04:00
Thalia
e7cdf4f194 Finish sentence in MultiUsernameFilter documentation
Change-Id: I933f54f505e0680346f73293c98624e0f48e9292
2019-05-28 18:54:18 +01:00
Derick Alangi
166d09893b languages: Hard deprecate Language::getExtraUserToggles() method
This seems to be still used internally in core but in no extension. Also,
this function really doesn't do anything so hard deprecating in preparation
for removal.

Bug: T62260
Change-Id: I568789483084a97e5b3b462235f3d00c3cb87cf9
2019-05-24 10:59:38 -07:00
jdlrobson
b2b204eeaf Allow hidden skins to show up in preferences
It should be possible for power users to reveal hidden preferences
using the useskin query parameter. In future this will allow us
to use wgSkipSkins to deprecate poorly supported skins for new
users whilst not hard deprecating and removing skin support for
users who strongly want to continue to use them.

Change-Id: I1bbd4a09dff72f513c9413e0f826d8db38a5e04c
2019-05-19 15:21:00 +00:00
Aryeh Gregor
3860a8d9b4 Update DefaultPreferencesFactory to use NamespaceInfo
Depends-On: I552264714de7227965f978f20f932f41cf96042e
Change-Id: I0568e7f4c7223208001f378a03fef395df8bff69
2019-05-06 12:19:13 +03:00