Commit graph

523 commits

Author SHA1 Message Date
Umherirrender
f8c985b645 filebackend: Check for old alias in FileBackendMultiWrite
When the config contains the old class name, the change to the new
namespaced class in 1b29f07440 breaks
existing configs.

Follow-Up: I73fb416573f5af600e529d224b5beb5d2e3d27d3
Change-Id: I5236609dbef5c28c4d220680c501b5813f940e8f
2024-10-22 01:32:54 +02:00
Umherirrender
1b29f07440 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I73fb416573f5af600e529d224b5beb5d2e3d27d3
2024-10-21 20:41:20 +02:00
James D. Forrester
cc28acc455 Add namespace to remaining parts of Wikimedia\Mime and Wikimedia\Stats
Bug: T353458
Change-Id: If0137003ab625017d322d57870448a02569668c3
2024-09-27 16:19:10 -04:00
James D. Forrester
53b67ae0a6 Add namespace to remaining parts of Wikimedia\ObjectCache
Bug: T353458
Change-Id: I3b736346550953e3b2977c14dc3eb10edc07cf97
2024-09-27 16:19:10 -04:00
Adam Wight
188d2cbbb0 Remove unchecked exception annotations
Callers should not catch an unchecked exception, so it doesn't belong
in a function signature.  Unchecked exceptions indicate a coding error,
which by definition the code will not be able to handle correctly.

If any of these exceptions were supposed to be in response to an edge
case, user input, or initial conditions, then they should be changed
to a runtime error.  If the exception class cannot be changed, then
the annotation should include a comment explaining its purpose and
prognosis.

Bug: T240672
Change-Id: I2e640b9737cb68090a8e1cb70067d1b74037d647
2024-09-17 22:20:58 +02:00
Ebrahim Byagowi
fab78547ad Add namespace to the root classes of ObjectCache
And deprecated aliases for the the no namespaced classes.

ReplicatedBagOStuff that already is deprecated isn't moved.

Bug: T353458
Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
2024-07-10 00:14:54 +03:30
Ebrahim Byagowi
1be5d40e56 Add namespace and deprecation alias to FileBackendGroup
This patch introduces a namespace declaration for the
MediaWiki\FileBackend to FileBackendGroup and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: Id33b6bfa56131978900199786b0082481c6c54a5
2024-05-20 20:06:00 +03:30
Ebrahim Byagowi
d21cc67450 Add namespace and deprecation alias to FileBackend
This patch introduces a namespace declaration for the
Wikimedia\FileBackend to FileBackend and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: Id897687b1d679fd7d179e3a32e617aae10ebff33
2024-05-19 22:35:58 +03:30
James D. Forrester
102a4f8a35 build: Upgrade mediawiki/mediawiki-phan-config from 0.13.0 to 0.14.0 manually
* Switch out raw Exceptions, mostly for InvalidArgumentExceptions.
  * Fake exceptions triggered to give Monolog a backtrace are for
    some reason "traditionally" RuntimeExceptions, instead, so we
    continue to use that pattern in remaining locations.
* Just entirely give up on PostgresResultWrapper's resource vs. object mess.
* Drop now-unneeded false positive hits.

Change-Id: Id183ab60994cd9c6dc80401d4ce4de0ddf2b3da0
2024-02-10 02:22:41 +00:00
Amir Sarabadani
7d137d0452 Deprecate ConfiguredReadOnlyMode service
Currently, we have two services: ReadOnlyMode and
ConfiguredReadOnlyMode. The former takes the latter and can easily
support every functionality of CRO. I added methods to support that
functionality (the current class is quite small so it's not adding a lot
more to a monster class) and basically fully deprecate the service
itself to improve developer experience.

It is only called in two extensions in production with straightforward
fix so I directly went with hard-deprecation.

Bug: T343917
Depends-On: Icec0ad3f30c471b428efe80dfb9129f55a351194
Change-Id: I421fd5c8fee7af41c059419c2bbc85b8dccc04ed
2023-09-12 23:22:13 +00:00
Amir Sarabadani
d8e542abf9 Reorg: Move three output related classes to includes/Output/
And namesapce them:
 - StreamFile
 - OutputHandler
 - OutputPage

Bug: T321882
Change-Id: Iedf8d88c595e580f2d8f0734c92aa5c45618ba33
2023-09-05 19:36:42 +01:00
Amir Sarabadani
f4e68e055f Reorg: Move Status to MediaWiki\Status\
This class is used heavily basically everywhere, moving it to Utils
wouldn't make much sense. Also with this change, we can move
StatusValue to MediaWiki\Status as well.

Bug: T321882
Depends-On: I5f89ecf27ce1471a74f31c6018806461781213c3
Change-Id: I04c1dcf5129df437589149f0f3e284974d7c98fa
2023-08-25 15:44:17 +02:00
James D. Forrester
7438e6cc60 Drop LockManagerGroup::getDefault() and getAny(), deprecated since 1.35
Change-Id: I18cb4da74369703aead42df689b54d43d70f094f
2023-08-16 16:58:34 +08:00
Amir Sarabadani
623d3dc419 rdbms: Move ReadOnlyMode and ConfiguredReadOnlyMode to rdbms library
The db/ directory does not have an owner and it's a mess in general.
These classes don't depend on anything in core except the rdbms library.
Let's simply move it there. In other words, Krinkle made me do it.

Since the class was moved in I6202e52ba73 merged less than a week ago,
no need to alias anything.

Bug: T321882
Change-Id: I24ceeb8bf765a50f441270136acd612359d50aa2
2023-05-04 23:41:21 +02:00
Amir Sarabadani
d59ffa4202 Reorg: Move ReadOnlyMode classes to db/
They are not suitable to go to rdbms library as they depend on mediawiki
pieces, the second best place is the db/ directory.

Bug: T321882
Change-Id: I6202e52ba7306d74261206c2ba7930c5f1a0a18e
2023-04-28 12:13:01 +02:00
jenkins-bot
a85966542d Merge "Use short array destructuring instead of list()" 2022-10-21 11:11:06 +00:00
Tim Starling
0077c5da15 Use short array destructuring instead of list()
Introduced in PHP 7.1. Because it's shorter and looks nice.

I used regex replacement.

Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
2022-10-21 15:33:37 +11:00
Tim Starling
43a93d9782 Use the null coalescing assignment operator
Available since PHP 7.4.

Automated search, manual replacement.

Change-Id: Ibb163141526e799bff08cfeb4037b52144bb39fa
2022-10-21 13:26:49 +11:00
Aaron Schulz
8607105de9 lockmanager: remove MysqlLockManager and DBLockManager
This obscure class could only be used by running file_locks.sql and
customizing $wgLockManagers. It was not worth the overhead of having
to maintain it.

Remove DBLockManager since there are no subclasses now.

Change-Id: Id7e3fde02dfca02271bcec039be5c079de9de830
2022-10-14 17:43:44 -07:00
Timo Tijhof
bfd419fb9e filebackend: Remove LBFactory dep from LockManager service
This was added during the conversation to a service class in
commit 5a6c18a086 (Iaa7354f31), but the code it was for is unused
and was shortly after removed in commit 37022e2e (Ifa00c59ab), thus
leaving this unused dependency behind.

The motiviation for this change is that Parser is used during
the installer (maintenance/install.php) with DB services naturally
disabled, and Parser has the dependency chain Parser -> BadFileLookup
-> RepoGroup (hidden) -> FileBackendGroup -> LockManagerGroup.

Solving the hidden part is proposed in I9de42a26cd, but fails as
LockManagerGroup currently depends on LBFactory which makes
it crash in db-less environments.

Change-Id: Icaad0acbed2957c1f86e4089dd221a8cdcb1a1ae
2022-08-02 22:22:48 -07:00
Mark A. Hershberger
b19a827295 Ensure that strlen() does not get passed a (valid) null
Seen in FileBackendGroupIntegrationTest::testGuessMimeInternal().

Bug: T289926
Change-Id: I8bf50d0fc026b2880427d3d75d57e38d4e2989d3
2022-07-12 10:35:39 -04:00
Timo Tijhof
e94e3e9545 docs: Move, clarify and cross-ref "DI Principles" for easy reference
Loosely based on https://phabricator.wikimedia.org/T218555,
https://phabricator.wikimedia.org/T242835#6064656, and
https://phabricator.wikimedia.org/T302627#7846955.

Change-Id: Ib649297ba28d75eca3c96235124a97ea38dde72c
2022-06-06 14:31:29 +00:00
Aryeh Gregor
7b791474a5 Use MainConfigNames instead of string literals, #4
Now largely automated:

VARS=$(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | \
  tr "\n" '|' | sed "s/|$/\n/;s/'//g")
sed -i -E "s/'($VARS)'/MainConfigNames::\1/g" \
  $(grep -ERIl "'($VARS)'" includes/)

Then git add -p with lots of error-prone manual checking. Then
semi-manually add all the necessary "use" lines:

vim $(grep -L 'use MediaWiki\\MainConfigNames;' \
  $(git diff --cached --name-only --diff-filter=M HEAD^))

I didn't bother fixing lines that were over 100 characters unless they
were over 120 and triggered phpcs.

Bug: T305805
Change-Id: I74e0ab511abecb276717ad4276a124760a268147
2022-04-26 19:03:37 +03:00
Alexander Vorwerk
9b09bf3112 Use updated ObjectFactory namespace
Depends-On: I99c5e5664d2401c36a9890f148eba7c25e6e8324
Depends-On: I48ab818b2965da14af15ef370aa83ad9455badd9
Depends-On: I018371e4b77911e56152ca7b2df734afc73f58a5
Change-Id: I04ebdb52102f6191d49a9cc70b1f98308299e72f
2022-03-09 23:04:51 +00:00
Tim Starling
12cac7cca9 LockManager: distinguish conflicts from other kinds of lock errors
With a user-friendly error message which uses both technical and
non-technical language, without the irrelevant detail of filebackend
URLs.

Bug: T283045
Change-Id: I8704f405d38acdffae7bd4ea5b91f3f591fc2ebc
2021-11-09 21:58:20 +00:00
jenkins-bot
395e60b088 Merge "Simpler RedisLockManager configuration" 2021-11-03 22:38:18 +00:00
Tim Starling
06fc5ddb56 Simpler RedisLockManager configuration
I set up a local test instance with RedisLockManager, but some things
seemed more complicated than they needed to be. So:

* Add lockManager option to $wgLocalFileRepo, which becomes the
  lockManager of the auto-generated file backend.
* Made srvsByBucket be optional. I made the same change to the identical
  code in MemcLockManager and DBLockManager, but I didn't test them.
* Improved doc comments for RedisLockManager::__construct() and
  $wgLocalFileRepo.

Change-Id: I8ce430b8e849589d4ea87c90a56ee3659da085a0
2021-11-02 18:28:23 +11:00
James D. Forrester
20fd877da4 Drop experimental FileJournal system without deprecation
The feature was introduced in 2012 with d19f54602f (just before
the gerrit migration).

Change-Id: Ia3f59ad0ddeb1f610947b14e22b0694ff4c6ed84
2021-11-01 14:08:09 +11:00
Alexander Vorwerk
3f421aba14 Remove LockManagerGroup::singleton() and ::destroySingletons()
both deprecated since 1.34.

Bug: T249030
Change-Id: Ide18730c12af503259c98a0380e34a075ecd7128
2021-09-17 00:25:44 +02:00
Alexander Vorwerk
da26927c73 Remove FileBackendGroup::singleton() and ::destroySingletons()
both deprecated since 1.35, hard deprecated since 1.37 and unused.

Bug: T249025
Change-Id: Ie4759fa3fa25202d623317acb444079f10e33817
2021-09-15 19:21:30 +02:00
James D. Forrester
86f3270bda Tag various new 'primary' methods as @since 1.37
Change-Id: Icbbbc84154174da1bd9398990679857898f418d5
2021-09-02 11:58:19 -07:00
jenkins-bot
ae8522b34c Merge "Same code style and formatting for exists-style SQL queries" 2021-08-24 17:44:17 +00:00
Thiemo Kreuz
46f26dff03 Same code style and formatting for exists-style SQL queries
Queries that query a value "1" are expected to return either
that "1" (possibly as a string), or false. It's safe to simply
cast this to bool and use it as it is.

Queries for COUNT(*) are expected to return that number,
possibly as a string. It's not possible for such a query to
return false. And even if, casting to 0 is fine.

I found an existing code style where the table name and the
"1" are on the same line as the selectField() method name, and
applied it to all similar queries.

Change-Id: I9453196281871c03ef03f653f43762eb9284342f
2021-08-12 11:37:58 +02:00
TChin
fa5d3dba51 Support fluent interface for StatusValue
Also refactored some calls to use it.

Bug: T287485
Change-Id: If9e96ce87dc3f3641e9b3ebe093f92d8fa49b9ee
2021-08-02 15:14:11 -04: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
James D. Forrester
9fe4138f3d Follow-up I68198bc3: Hard-deprecate getMasterDB() methods
Also switch one use that we missed in the rebase.

Bug: T254646
Depends-On: I632610dec1aa6bb59af5423e6f86164fc791aadd
Change-Id: I9873c889f943fcbd7d867d534a7857f20ef0c5dc
2021-07-15 09:12:17 +01:00
James D. Forrester
597376e12c Replace getMasterDB methods with getPrimaryDB
Bug: T254646
Change-Id: I68198bc39b174ea1920b4acc2617cb6c6ce406e9
2021-07-14 16:21:04 -07:00
ZabeMath
08c87c13a3 Hard deprecate FileBackendGroup::singleton() and ::destroySingletons()
both deprecated since 1.35.

Bug: T249025
Change-Id: I271187e8c5ad68459cfad4c0966c8c14d225512f
2021-05-04 21:03:41 +02:00
ZabeMath
79aa859e5a Hard deprecate LockManagerGroup::singleton() and ::destroySingletons()
both deprecated since 1.34.

Bug: T249030
Change-Id: Ic8747430dae6d9ebe8ca52841cf0d998968dfc2f
2021-05-03 18:42:31 +00: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
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
Umherirrender
8eb9e8b6e8 Improve docs in FileJournal class
Change-Id: Ib3aaec1a9ea33c227b3002816907e42d1a970b76
2020-11-27 16:43:16 +01:00
Aaron Schulz
e6cd8f8823 filebackend: convert DBFileJournal to using CONN_TRX_AUTOCOMMIT
This avoids the hack of needing an untracked LoadBalancer just
to get an auto-commit mode connection

Change-Id: I143d92a9c55af9b94f39e5f49bb0aef9e6ab92e5
2020-11-25 21:26:57 +00:00
Thiemo Kreuz
1fc8d79ac6 Remove documentation that literally repeats the code
For example, documenting the method getUser() with "get the User
object" does not add any information that's not already there.
But I have to read the text first to understand that it doesn't
document anything that's not already obvious from the code.

Some of this is from a time when we had a PHPCS sniff that was
complaining when a line like `@param User $user` doesn't end
with some descriptive text. Some users started adding text like
`@param User $user The User` back then. Let's please remove
this.

Change-Id: I0ea8d051bc732466c73940de9259f87ffb86ce7a
2020-10-27 19:20:26 +00:00
Aryeh Gregor
a24e8a06b5 Mark CONSTRUCTOR_OPTIONS as internal
These were never meant to be part of the public interface and should not
ever have been marked with @since. They're only useful for constructing
the respective objects, which no outside users should be doing.

Change-Id: I86e01272d46fc72af32172d8a12b9180971d4613
2020-08-21 00:18:45 -04:00
Umherirrender
fd1ed0c092 Pass function name to database functions
Useful for logging

Change-Id: Ia2160fb6be5fc93f28ab51f7ae23d7f078247481
2020-06-07 14:16:52 +02:00
Ori Livneh
19931e069f mime: Update usage of MimeAnalyzer methods
Follow-up to I93bd71ec1.

Bug: T252228
Change-Id: I45c9fc592c9e41e0868e7d965206d4c04f4f92e1
2020-05-28 20:13:47 +00:00
James D. Forrester
4f2d1efdda Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse
Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
2020-01-10 09:32:25 -08:00
apaskulin
4d24ad65c9 docs: Remove ingroup tag from Markdown files
This patch fixes the nesting issue in the Doxygen navigation
by removing the @ingroup tag from class-level Markdown files.
These files will now appear as top-level files in the
navigation and are discoverable via links on the class pages.

Bug: T87796
Change-Id: I370bfea3bf2a6816724d04b15107658f1c336f0f
2019-11-12 16:11:30 -08:00
Umherirrender
337ecb0514 Add missing @param and @return to documentation
Change-Id: Ibc5849cc8ea7e7c4eb30ded9c1cfa5f52187c377
2019-11-10 22:12:58 +00:00