Commit graph

45 commits

Author SHA1 Message Date
Amir E. Aharoni
c14bbf4e2f Consistent spelling of "subpage"
Also:
1. Other minor fixes in comments touched by this patch.
2. Add a separate test for subpage with spaces.

Change-Id: I267f19027098e5778b1cd491826e1741fc7ee794
2024-08-06 04:01:02 -04:00
Amir Sarabadani
d9370003fb maintenance: Introduce getReplicaDB() and getPrimaryDB()
And start using them instead of wfGetDB(), LB/LBF connection methods or
worse, $this->getDB().

$this->getDB() reuses the database object regardless of whether you're
calling a replica or primary, leading to returning a replica on a
primary and other way around.

Bug: T330641
Change-Id: I9e2cf85ca277022284fc26b9f37db57bd12aaa81
2024-01-18 15:12:04 +01:00
Niklas Laxström
7a16479719 Fix typo in maintenance script
Change-Id: Ia8ea294b7bc961fe34dd4457a8eabc27f41c4056
2023-12-13 10:32:17 +02:00
James D. Forrester
1d0b7ae1e2 Namespace User under \MediaWiki\User
Bug: T166010
Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
2023-09-19 19:18:16 +00:00
James D. Forrester
5088626212 Namespace 'special' Pagers under \MediaWiki\Pager
They're under 'specials' because that's where they're mostly used,
but they're just another kind of Pager (shown by their use outwith
the MediaWiki\Specials hierarchy, which is a bad code smell for us
to review later).

Bug: T166010
Change-Id: Iad3f91582b723c1e6679525aa852ffdfd8c6d5ba
2023-09-18 18:23:13 +01:00
jenkins-bot
f1db8173fd Merge "maintenance: Replace usages of deprecated WikiPage::doDeleteArticleReal" 2023-09-11 22:24:55 +00:00
Derick Alangi
74033c50cd maintenance: Begin using Maintenance::getServiceContainer()
Maintenance class provides a method for getting a fresh reference
of the MW services container instance. Let's make use of these in
maintenance scripts now that we have it.

NOTE: There are still some static methods like in refreshLinks.php
that makes use of services that we can't use this method for now.

Change-Id: Idba744057577896fc97c9ecf4724db27542bf01c
2023-09-04 10:39:58 +00:00
James D. Forrester
ad06527fb4 Reorg: Namespace the Title class
This is moderately messy.

Process was principally:

* xargs rg --files-with-matches '^use Title;' | grep 'php$' | \
  xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1'
* rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \
  xargs rg --files-with-matches 'Title\b' | \
  xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1'
* composer fix

Then manual fix-ups for a few files that don't have any use statements.

Bug: T166010
Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a
Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
2023-03-02 08:46:53 -05:00
Umherirrender
ade5816751 Use LanguageNameUtils::AUTONYMS/SUPPORTED instead of hard coded value
Easier to spot the documentation what happen with this option

Change-Id: I6764dff8f79a6e667a0f4f61336f6280c7f13ed2
2022-12-29 13:47:29 +01:00
Umherirrender
ea5ea60b31 Various doc fixes about false on method arguments/return types
Doc-only changes

Change-Id: I5177f582ae7ee70c357e9389fed14819faf79463
2022-11-10 19:23:46 +00:00
jenkins-bot
da2833c96d Merge "maintenance: Use $this->waitForReplication()" 2022-10-27 12:22:24 +00:00
Amir Sarabadani
0fff5089ba Reorg: Move StubObject classes in includes to its own directory
Bug: T166010
Change-Id: Idcf0e9dc6e0841e4f132207bce0f96774dad898c
2022-10-25 16:04:48 -04:00
Amir Sarabadani
b525884e11 maintenance: Use $this->waitForReplication()
This adds reconfiguring db pools in case a replica gets depooled

Bug: T298485
Change-Id: Id052ce8ed45c51e51b071778858d27b48605bf93
2022-10-24 21:11:53 +02:00
Daimona Eaytoy
762de4cca7 maintenance: Replace usages of deprecated WikiPage::doDeleteArticleReal
Use DeletePage instead.

Change-Id: Icf064d6f8ce609d1119b45377af037ed03e464a4
2021-11-08 14:39:28 +01:00
DannyS712
a2b20b63d7 Emit deprecation warnings reading from $wgUser
With this patch deprecation warnings will be emitted
if $wgUser is accessed or written into. The only pattern
of usage still allowed is

$oldUser = $wgUser;
$wgUser = $newUser;
// Do something
$wgUser = $oldUser;

Once there is no deprecation warnings, we know that nothing
legitimately depends on $wgUser being set, so we can safely
remove the code that's still allowed as well.

Bug: T267861
Change-Id: Ia1c42b3a32acd0e2bb9b0e93f1dc3c82640dcb22
2021-09-15 20:17:04 -07:00
vladshapik
c7e6c67dc5 Hard deprecate User group methods
1) The following methods were hard deprecated:
- User::addAutopromoteOnceGroups
- User::getEffectiveGroups
- User::getAutomaticGroups
- User::getFormerGroups

2) User ::getGroups, ::getGroupMemberships, ::addGroup,
::removeGroup were replaced in the production code,
but they were not hard deprecated because of conflict
with UserRightsProxy class.

Bug: T275148
Change-Id: Ia69598316f5dc5dd9511f6112b5b13e1aa07575a
2021-07-23 15:00:16 +03:00
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
jenkins-bot
3a2708bf94 Merge "Inject services into SpecialAllMessages" 2020-11-20 19:07:30 +00:00
Umherirrender
a3194f2194 Replace deprecated WikiPage::factory/newFromID in maintenance scripts
Change-Id: I5b2d4313f986484368da9b63c9a19892c2328dae
2020-11-12 21:48:21 +00:00
Umherirrender
64aba8bc2f Inject services into SpecialAllMessages
This covers only directly used services by this special page and pager
Services used by the base class are not part of this patch set

Have to change the signature of one static function to avoid global
state and changed the caller as well

Bug: T259960
Change-Id: I9502c6cfd718b6edb074a50931094fcdbf2c48de
2020-11-02 02:14:36 +01:00
Reedy
8ba1c75559 Replace wfWaitForSlaves() with LBFactory::waitForReplication()
Change-Id: I337147d61e2ec686a8672d0340dff4b6783f78cd
2020-05-02 02:00:01 +00:00
DannyS712
10fa27fa0f Maintenance: Change ::doDeleteArticle to WikiPage::doDeleteArticleReal
Bug: T248000
Change-Id: I48bcf68e90209c5cfc2b7fedbf70fdffc374ec64
2020-03-25 17:44:18 +00:00
Petr Pchelko
204fa7e509 Remove usages of deprecated Language methods
Change-Id: Iad3375b141b1d87c890baec6ecd16ed92f93e699
2020-02-16 00:45:48 +00:00
Aryeh Gregor
90d4f56fe4 Mass conversion of $wgContLang to service
Brought to you by vim macros.

Bug: T200246
Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
2018-08-11 22:44:29 -06:00
Umherirrender
ad776c7d5f Use ::class to resolve class names in maintenance scripts
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I1d4567f47f93eb1436cb98558388e48d35258666
2018-01-23 17:40:16 +00:00
Bryan Davis
9e34eeff23 Maintenance: add fatalError() method
Deprecate the second argument to Maintenance::error() in favor of a new
Maintenance::fatalError() method. This is intended to make it easier to
review flow control in maintenance scripts.

Change-Id: I75699008638f7e99b11210c7bb9e2e131fca7c9e
2017-11-21 21:34:16 -07: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
Max Semenik
59db24e90b Use addDescription() instead of accessing mDescription directly
Change-Id: I0e2aa83024b8abf5298cfea4b21bf45722ad3103
2016-01-30 01:28:32 -08:00
Reedy
44cebea941 Update wfGetDB calls in Maintenance scripts to use getDB()
Change-Id: I9ad6745d84506b736dae94747256caac89715899
2016-01-02 16:58:23 +00:00
Brad Jorsch
3d0b4fea3d User: Mostly remove password handling
AuthManager is coming, which will make it easier to add alternative
methods of authentication. But in order to do that, we need to finally
get around to ripping the password-related bits out of the User class.

The password expiration handling isn't used anywhere in core or
extensions in Gerrit beyond testing for expired passwords on login and
resetting the expiry date on password change. Those bits have been
inlined and the functions removed; AuthManager will allow each
"authentication provider" to handle its own password expiration.

The methods for fetching passwords, including the fact that mPassword
and other fields are public, has also been removed. This is already
broken in combination with basically any extension that messes with
authentication, and the major use outside of that was in creating
system users like MassMessage's "MediaWiki message delivery" user.

Password setting methods are silently deprecated, since most of the
replacements won't be available until AuthManager. But uses in unit
testing can be replaced with TestUser::setPasswordForUser() immediately.

User::randomPassword() and User::getPasswordFactory() don't really
belong in User either. For the former a new PasswordFactory method has
been created, while the latter should just be replaced by the two lines
to create a PasswordFactory via its constructor.

Bug: T47716
Change-Id: I2c736ad72d946fa9b859e6cd335fa58aececc0d5
2015-10-13 16:10:41 -06:00
Timo Tijhof
036f84cfe7 maintenance: Handle errors in deleteEqualMessages.php
Follows-up 49107fcc2.

Change-Id: I1b4b3f89a383a9b010d557ae0c6cbd767be60fb0
2015-08-26 19:13:03 +02:00
Kevin Israel
49107fcc29 deleteEqualMessages.php: Avoid "Transaction already in progress" warning
Set the $commit parameter of WikiPage::doDeleteArticle() to true so
the transaction it starts is explicitly committed. Also fixed similar
bugs in two other maintenance scripts.

Follows-up 02f17b5790.

Bug: T110189
Change-Id: Ifde98066e25cb616f23c8998f9461ebf7a2073d6
2015-08-26 01:16:22 -04:00
Timo Tijhof
9dc2438011 Fix up php syntax that accidentally became part of a string literal
Follows-up d15f1cc5e1.

Previous output:
> 474 pages in the MediaWiki namespace ' .
>                       'override messages.
> 4 pages are equal to the default message ' .
>                       '(+ 0 talk pages).

Change-Id: I6104f716f7dc32d638a2f5a7c37c3a507efad7dd
2014-08-27 15:39:31 +02:00
umherirrender
6b4c44c2db Add missing @param to function docs
Change-Id: Ib26407bc55dff7969d8a3b1e2ae51751b202d8fb
2014-08-18 16:24:59 +00:00
umherirrender
d15f1cc5e1 Break some long lines in maintenance, skins, tests
Change-Id: I5d86ad3e0c90e09440268a670f5af3e2bf080612
2014-07-24 19:03:17 +02:00
Reedy
2dc420dd2a Capitalise Message in SpecialAllMessages files
No internal changes to Special:Allmessage etc made

Change-Id: I21a164af0b6ec123bf654cd1e4e7085b1192f067
2014-06-16 18:25:53 +01:00
Aaron Schulz
02f17b5790 Removed begin/commit calls that result in error spam
* The delete calls already try to start transactions. Also CLI scripts
  run in autocommit mode anyway.

Change-Id: I433691b3e4e578983e4e15334248f029e0b0d277
2014-05-21 15:50:15 -07:00
Siebrand Mazeland
f2f31fadc7 Update formatting in maintenance/ (2/4)
Change-Id: I2b791d3bff0de464b6bdaaeae0622c065389c31c
2014-04-23 20:08:42 +02:00
Timo Tijhof
dafd0ce5aa deleteEqualMessages: Exclude messages that are empty by default
The main purpose of this script is to purge local overrides to
avoid them from blocking an i18n update in the future.

However empty messages should remain empty and often have a
richer edit history (e.g. Sitenotice) and may not stay empty
for long.

Change-Id: I5b416cda25a3641862df9919c46ae59ad5d5d6e0
2013-10-09 21:08:14 +02:00
Timo Tijhof
beb1c4a0ec phpcs: More require/include is not a function
Follows-up I1343872de7, Ia533aedf63 and I2df2f80b81.

Also updated usage in text in documentation and the
installer LocalSettingsGenerator.

Most of them were handled by this regex:
- find: (require|include|require_once|include_once)\s*\(\s*(.+?)\s*\)\s*;$
- replace: $1 $2;

Change-Id: I6b38aad9a5149c9c43ce18bd8edbab14b8ce43fa
2013-05-21 23:26:28 +02:00
Platonides
186f5f63e3 Move the global to the place it is needed.
Follow-up 8be2e118

Change-Id: Ic72a8f24fdcbafcb689370c845dcf6df4f864493
2013-05-20 11:28:27 +02:00
Timo Tijhof
8be2e118fd deleteEqualMessages: Refactor to support all langcode subpages
Previously it ran for either the base pages (comparing against
content language) or 1 lang-code subpage.

And the latter was actually broken as it forgot to add the
subpage back on, thus resulting in incorrect deletions
(deleting MediaWiki:Foo instead of MediaWiki:Foo/nl).

Also fixed a bug where it used the subpage lang-code to create
a Language object and call ucfirst(). Page titles should only be
capitalized by content language.

Bug: 48050
Bug: 43917
Change-Id: I2680413c276365a44c935a6f6fdd740daa86341e
2013-05-17 18:52:05 +02:00
Timo Tijhof
50e7985d4d phpcs: Fix WhiteSpace.LanguageConstructSpacing warnings
Squiz.WhiteSpace.LanguageConstructSpacing:
   Language constructs must be followed by a single space;
   expected "require_once expression" but found
   "require_once(expression)"

It is a keyword (e.g. like `new`, `return` and `print`). As
such the parentheses don't make sense.

Per our code conventions, we use a space after keywords like
these. We appeared to have an unwritten exception for `require`
that doesn't make sense. About 60% of require/include usage
was missing the space and/or had superfluous parentheses.

It is as silly as print("foo") or return("foo"), it works
because keywords have no significance for whitespace between
it and the expression that follows, and since experessions can
be wrapped in parentheses for clarity (e.g. when doing string
concatenation or mathematical operations) the parenthesis
before and after basiclaly just ignored.

Change-Id: I2df2f80b8123714bea7e0771bf94b51ad5bb4b87
2013-05-09 05:56:26 +02:00
Timo Tijhof
3cb6ca1684 deleteEqualMessages: Include list of pages in dry run
Also clarify that the talk page number is in addition to the
other number. So it says "10 pages are equal (+ 2 talk pages)"
instead of "10 pages are equal (2 talk pages)".

Document better that the default is a dry run.

Change-Id: I95edb08d7b92c393ed226bef2575e52a6135f8df
2013-05-03 17:49:10 +02:00
Timo Tijhof
a5028bfe5f (bug 43915) Implement deleteEqualMessages.php
Change-Id: I97529b775d4db4f996c40395c891a0049d2e43c5
2013-01-31 19:45:31 -08:00