Commit graph

179 commits

Author SHA1 Message Date
James D. Forrester
df5eb22f83 Replace uses of DB_MASTER with DB_PRIMARY
Just an auto-replace from codesniffer for now.

Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
2021-04-29 09:24:31 -07:00
Cindy Cicalese
fb6b6e058c Fix parameter order of setWatch to match add/removeWatch
Change-Id: I0ea63482a5cab24c23b49b8bbe6c80bdbe8b102b
2021-04-21 04:41:38 +00:00
Cindy Cicalese
a384acffa7 Use WatchlistManager in several classes
Change-Id: I720629e08373736b5fc1e12563b5059311b113e1
2021-04-21 00:37:40 -04:00
mainframe98
a6a051340c Create mediawiki.actions.styles module for misc action styles
These are styles for actions that do not have a dedicated style module.
Given that the amount of css it contains it marginal, creating a
dedicated module for each action would be overkill.

Bug: T278504
Change-Id: Id03c81e7d5ebf179731649aa230def2e8e21ac02
2021-03-31 15:39:51 +00:00
DannyS712
ccc149603f FileDeleteForm: reduce use of global context
Use available context in $this->out

Change-Id: I63e27472dafbb51f0ee1547ff9c3952d7a06bbc5
2021-03-28 22:08:54 +00:00
jenkins-bot
e98ae90c02 Merge "Avoid using User::getBoolOption()" 2021-03-28 02:18:21 +00:00
ZabeMath
60606a2986 Avoid using User::getBoolOption()
User::getBoolOption() is deprecated and should be replaced with UserOptionsLookup::getBoolOption()

Bug: T277600
Change-Id: Ife3c721237258d50852bbf764def74657cc70428
2021-03-27 22:51:03 +01:00
Timo Tijhof
6e9c3ba83f FileDeleteForm: Declare some param and return type hints to methods
These look uncontroversial and safe to enforce.

Change-Id: Ib37f24423a0ee01a1cbd55a7753f8152641b3504
2021-03-27 02:21:32 +00:00
DannyS712
130333b3d3 FileDeleteForm: Remove use of $wgLang
Have a context available.

Bug: T160814
Change-Id: I68e3cefac9158918e0ab9e1df221cb77b65282cd
2021-03-27 02:16:06 +00:00
Umherirrender
8de3b7d324 Use static closures where safe to use
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.

Created by I25a17fb22b6b669e817317a0f45051ae9c608208

Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
2021-02-11 00:13:52 +00: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
Umherirrender
3f1c5d0eea Document list of change tags as string[]
Change-Id: I0ce2a8154af82a363fef126033b5819c4ee84842
2020-11-20 14:12:54 +01:00
Umherirrender
18f20e1795 Replace deprecated WikiPage::factory in deletion related classes
Change-Id: Ie90fc9ffb1471ad58de29530bca51d606ec780af
2020-11-12 23:06:51 +01:00
DannyS712
5dbdacf650 Remove support for FileDeleteForm::doDelete without a user
Bug: T245801
Change-Id: Ica1f49fc257df70c2c1990035414f94bc3b850ff
2020-09-09 23:48:08 +00:00
DannyS712
b3296ab604 FileDeleteForm: Inject OutputPage instance
Class is not @newable or safe for creation, so breaking changes
can be made to the constructor.

Bug: T252979
Change-Id: Ia16a0d3eaabbc450dfd779b71ce1cc28f8d4f3b4
2020-08-29 01:24:35 +00:00
DannyS712
354f168dbe Remove deprecated support for FileDeleteForm creation without User
Class isn't safe to create (@newable) and not providing a User is
also explicitly hard deprecated.

Bug: T245581
Change-Id: I9859cbfb21e8fbe012980a381e7cde28b8837bc6
2020-08-26 23:51:44 +00:00
jenkins-bot
02c533e837 Merge "Combine mediawiki.action.delete.js and mediawiki.action.delete.file.js" 2020-08-13 07:07:57 +00:00
Umherirrender
91a95e56bd Split reason dropdown list for action=delete
Reasons for oversighter should only used by them,
so allow them to be added to the end of the list if the user is allowed.
There is no extra separator between both lists,
because the reason list can be structured by */**

Done for page deletion and file deletion

Similar to I7cb8bc17a297285da83b3b4c664b634fe0db660c

Bug: T250631
Change-Id: I854a390c9abf8bb78fec520cd59b41ba6b7513b5
2020-07-01 20:23:25 +00:00
DannyS712
5ee9e03637 Combine mediawiki.action.delete.js and mediawiki.action.delete.file.js
Virtually identical

Bug: T249677
Change-Id: I97bdee39c5a8cb830020ed069ac040f014011881
2020-06-30 09:46:18 +00:00
Tim Starling
d459add63d Introduce wfDeprecatedMsg()
Deprecating something means to say something nasty about it, or to draw
its character into question. For example, "this function is lazy and good
for nothing". Deprecatory remarks by a developer are generally taken as a
warning that violence will soon be done against the function in question.
Other developers are thus warned to avoid associating with the deprecated
function.

However, since wfDeprecated() was introduced, it has become obvious that
the targets of deprecation are not limited to functions. Developers can
deprecate literally anything: a parameter, a return value, a file
format, Mondays, the concept of being, etc. wfDeprecated() requires
every deprecatory statement to begin with "use of", leading to some
awkward sentences. For example, one might say: "Use of your mouth to
cough without it being covered by your arm is deprecated since 2020."

So, introduce wfDeprecatedMsg(), which allows deprecation messages to be
specified in plain text, with the caller description being optionally
appended. Migrate incorrect or gramatically awkward uses of wfDeprecated()
to wfDeprecatedMsg().

Change-Id: Ib3dd2fe37677d98425d0f3692db5c9e988943ae8
2020-06-22 14:34:39 +10: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
Umherirrender
6cf64addf3 Improve docs in FileDeleteForm
Change-Id: Iefc552a4d522b2a4af1224bef514b66e94f4e49d
2020-05-07 20:16:33 +00:00
DannyS712
f0864571d4 FileDeleteForm: Use LocalFile::deleteFile
Bug: T245710
Change-Id: I40ef1a88f21fc9972a610d3acfcca00550893fd4
2020-03-20 20:46:53 +00:00
DannyS712
7380aba100 Pass a user to WikiPage::doDeleteArticleReal, use new signature
Don't need to worry about supporting prior versions, since its core

Bug: T247869
Change-Id: Iad9397327731817b8c276d0b9786c3bc5ecf6476
2020-03-19 00:54:29 +00:00
DannyS712
05cf8ae216 LocalFileDeleteBatch: Migrate to new signature requiring a user
Move the user parameter to be before the other optional parameters,
and hard deprecate not passing a user. Interim signature is fully
backwards compatible, emitting deprecation noticed when a user is
not passed but otherwise accepting parameters in the old order as well
as the old order, including handling of defaults.

File::delete is a soft deprecated wrapper for the new File::deleteFile,
and File::deleteOld is a hard deprecated wrapper for the new
File::deleteOldFile. Both of the former methods accepted optional user
parameters; both of the new methods require a user, so that the call to
construct a LocalFileDeleteBatch can pass a user.

Bug: T245710
Change-Id: I9cde7831e16a719c22f093f95248b8055d9ac6fd
2020-03-17 15:38:42 +00:00
Umherirrender
e28b4bd8af Use MediaWikiServices::getRepoGroup in file related classes
Change-Id: Iceec961de4f0cc689f7d3b981afac923b46c98f6
2020-03-14 12:36:27 +00:00
DannyS712
e8d9ec0d47 Deprecate calling FileDeleteForm::doDelete without passing a user
Bug: T245682
Change-Id: I33dc25401251f057f3db7d7b69f5ced00a86f896
2020-02-21 04:11:30 +00:00
DannyS712
7391df21a6 FileDeleteForm: Add a user to constructor, hard deprecate not providing
There is only 1 call for creating a new FileDeleteForm, and it is
also updated; not passing a user is hard deprecated.

Also removes use of Title::getUserPermissionsErrors

Bug: T244929
Bug: T245233
Change-Id: Iaa3002ccc91f795bb1c6728163867e4b7a98a261
2020-02-18 16:53:27 -08:00
Kunal Mehta
bfa7aa20ab FileDeleteForm: Fix phpdoc for doDelete()
$oldimage isn't required and can be null.

Needed to have Nuke pass a newer version of phan.

Change-Id: I3e4b0947580836f1bf5c3807e98fb1d9543f4523
2019-12-22 02:29:30 -08:00
Umherirrender
3e57a7ea65 Document $file in FileDeleteForm as LocalFile (not File)
Deletion is only possible for files on the local wiki, so this is always
a LocalFile. The static self::doDelete already requires a LocalFile.

Caught by PhanTypeMismatchArgument, to be enabled with I34d65fe3ff191.

Change-Id: Iee0774340208b493b075085485343e05f922751c
2019-09-08 04:02:20 +00:00
jenkins-bot
31a987345d Merge "Better grouping for code adding elements to arrays" 2019-09-03 19:00:53 +00:00
Daimona Eaytoy
9881ea93be Better grouping for code adding elements to arrays
Change-Id: I7cc8c810f0dcf1ee84b9d5f14967ec2568e3e0be
Follow-up: I50377746f01749b058c39fd8229f9d566224cc43
2019-09-03 19:38:57 +02: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
jenkins-bot
75f1fe04a8 Merge "Avoid usage of deprecated setTags() method, use addTags() instead" 2019-09-01 15:25:02 +00:00
Derick Alangi
89cd937798 Avoid usage of deprecated setTags() method, use addTags() instead
$tags can be `null` as seen in most cases and this causes failures,
so, the safer path is to make sure if $tags is a null, do nothing.

Change-Id: I5b7e39adba5d08fdcd42c437a72a391be98c8695
2019-09-01 14:54:03 +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
Petr Pchelko
1d286560d2 Replace User::isAllowed with PermissionManager.
Covers root includes, actions, api, block, changes,
changetags, diff and PermissionManager itself.

Bug: T220191
Change-Id: Ic027d32f5dd8f4c74865df0c8a9fcf91123c889c
2019-08-20 14:43:51 -07:00
Brad Jorsch
0abb9338f8 Mostly drop old comment schemas
This removes most of the pre-CommentStore text columns, and the
$wgCommentTableSchemaMigrationStage setting that used to determine
whether the columns were used.

rev_comment remains in the code, as on Wikimedia wikis the revision
table is too large to alter at this time. A future change will combine
that with the removal of rev_user_text, rev_content_model, and
rev_content_format (and the addition of rev_comment_id and rev_actor).

CommentStore's constructor continues to take a $stage parameter, and
continues to have the logic for handling it, for the benefit of
extensions that might need their own migration process.

Bug: T166733
Change-Id: I1479c73774e01ead1490adf6128f820c09bce9d4
2019-02-07 16:59:27 +11:00
Thiemo Kreuz
4b71077646 Remove a few obscure "done" and "empty" comments
These don't add any knowledge to what is already obvious from the
code, I find.

Change-Id: Ia613b6a059f78dbeefdfd020899bd1a6e239a731
2019-01-30 20:35:14 +00:00
C. Scott Ananian
ade27ecba3 Use OutputPage::wrapWikiTextAsInterface() to add safe <div> wrappers
This ensures that broken messages can't break the <div> wrapper and
that the output is tidy.

Bug: T205624
Change-Id: I2511adf593a13528e205a82d9fcdc8a524d0a95f
2018-10-17 11:08:16 -04:00
C. Scott Ananian
c0ed262053 Use OutputPage::addWikiTextAsInterface() instead of untidy addWikiText()
This change ensures that the output is tidy, and is necessary to support
future parsers which will not be able to produce untidy output.

Bug: T198214
Change-Id: I743f4185a03403f8d9b9db010ff1ee4e9342e062
2018-10-17 10:35:28 -04:00
jenkins-bot
695d7c28fe Merge "Convert file delete to use OOUI" 2018-08-01 17:23:24 +00:00
Jayprakash12345
65a8e68ec0 Convert file delete to use OOUI
Also make a few changes for consistency with normal delete form:
* Add `autofocus` attribute on the "Other/additional reason" text field
* Remove bold styling from "Suppress …" checkbox label
* Remove `class="wpReasonDropDown"` from the "Reason" dropdown
* Remove `id="wpDeleteSuppressRow"` from the "Suppress …" form row

Bug: T173997
Change-Id: Ia5a0412c959c6149b01afe7fc6cbf5e8591673ac
2018-08-01 17:02:37 +00:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Aaron Schulz
c8085ad43f rdbms: make IDatabase::onTransaction* methods pass the DB handle for convenience
Change-Id: Ia45a26830d62326b103593268fbf34c907783c90
2018-04-24 16:45:11 -07:00
Brad Jorsch
ccc1c08089 Update more forms to limit comments by codepoints rather than bytes
This updates the deletion forms, Special:Block, Special:EditTags,
Special:MovePage, Special:RevisionDelete, Special:Undelete, and
Special:UserRights to limit by code point count rather than by byte (or,
in some cases, by UTF-16 code unit).

Bug: T185948
Change-Id: I20d11d7cc4f58902cbcb6dda70af533bce6dd170
2018-02-26 13:16:19 -05:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
Thiemo Mättig
91a920fd85 Remove auto-generated "Constructor" documentation on constructors
Having such comments is worse than not having them. They add zero
information. But you must read the text to understand there is
nothing you don't already know from the class and the method name.

This is similar to I994d11e. Even more trivial, because this here is
about comments that don't say anything but "constructor".

Change-Id: I474dcdb5997bea3aafd11c0760ee072dfaff124c
2017-07-21 12:19:30 +02:00
Brad Jorsch
35f428a2a7 FileDeleteForm: Create log entry even if the page didn't exist
Deleting a file with no description page should still produce a log
entry.

Bug: T167712
Change-Id: Icc7d9d12365d38faa502689ceefb4d1ee5f60210
2017-06-12 18:04:46 +00:00
WMDE-Fisch
ae3419f532 Replace some of the deprecated wfGetLBFactory() calls
Change-Id: I87aa0ebe273706438f1634167de8c60f51432878
2017-02-07 14:41:09 +01:00