Commit graph

471 commits

Author SHA1 Message Date
Petr Pchelko
c3bdbb8bed Make actor services usable with object factory.
Change-Id: I75dce2f1131a936d79475f6f8f3474d4bf32b760
2021-02-24 00:11:07 +00:00
Petr Pchelko
2ebb44eac4 Convert AuthManager to Authority: step 1.
Cut the explicit dependency on PermissionManager
and rely on the fact that User implements Authority.

There's still a few ends we need to cut before converting
the method parameters to Authority, but that can be done
in followup steps.

Bug: T273510
Change-Id: I69617e624f47944f8a383d0b28885678c1249f23
2021-02-22 15:40:37 -07:00
daniel
0266b57963 Make ActorNormalization a proper service.
ActorNormalization needs to have separate wiring if we want to be able
to access it by name. This is needed to allow access to the service in
declarative wiring, e.g. via ObjectFactory specs.

As an aside, this changes SpecialPageFatalTest to not construct special
pages in a data provider. Accessing services in data providers should be
avoided. This change does not eliminate all such access, but reduces it
by deferring service lookups via ObjectFactory.

Change-Id: I5792cdcc0e5b0d1681f55dbe3e1f70c34a0cb775
2021-02-22 11:58:46 +01: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
Petr Pchelko
4d8dc6b992 Use ActorStore in RevisionStore
Bug: T273290
Change-Id: Iff9b67455d337ea03cb728dd570c4ce760c39e49
2021-02-10 14:37:54 -06:00
jenkins-bot
be522158eb Merge "RequestTimeout library integration" 2021-02-09 01:01:47 +00:00
jenkins-bot
8d2b4a81dd Merge "Introduce ActorStore, ActorLookup and ActorFactory." 2021-02-08 19:24:50 +00:00
Petr Pchelko
8d2c674ab0 Introduce ActorStore, ActorLookup and ActorFactory.
The ActorNormalization factory methods create
UserIdentityValue from the database rows, either via
fields of a joined table, or via a row from actor table.
They assume that the actor_id exist and throw othervise.

ActorNormalization is a storage-layer service providing
access to finding and acquiring actor_id.

The UserIdentityLookup methods do not instantiate new actor
on demand, they just find an appropriate row in the actor
table and return the result.

Bug: T272689
Depends-On: I74d81f3f0233efb17fc8df5178e4c477cc669c6f
Change-Id: Icfa1daca960c696a8cef8adab5eab53985802858
2021-02-08 10:06:46 -06:00
Tim Starling
2697837fd8 RequestTimeout library integration
* Add $wgRequestTimeLimit. If it is non-null, it starts a time limit,
  using Excimer with a fallback to set_time_limit().
* Add pretty formatting of timeout exceptions thrown by the library.
  Related refactoring.
* Expose the library's critical section feature in MediaWikiServices
* In Setup.php, call warnIfHeadersSent() before sending session headers.
  This helped to debug a related issue I had.
* In wfTransactionalTimeLimit() use the new library, and respect the
  existing library time limit if it is larger than
  $wgTransactionalTimeLimit.

Bug: T269326
Depends-On: I6409ad8a5cba775c27b0d5a79d3300c4dac4c91a
Change-Id: I2e6f6351c451407c06cc7e20932548f7b62e36b6
2021-02-08 11:58:45 +11:00
Tim Starling
99392f3b16 Use Shellbox for Shell::command() etc.
Make Command extend Shellbox's UnboxedCommand. Only a few MediaWiki-
specific features remain in the subclass.

Also add BoxedCommand abstraction and Shellbox client.

The Result alias didn't actually work, I just had to change the return
type hint.

Bug: T260330
Change-Id: Iff7428e4c5fe3959a5cda8e113f223caa0976fc1
2021-02-05 21:51:58 +11:00
jenkins-bot
8d6e4d4044 Merge "Fix fetching ipblock-exempt within BlockManager::getUserBlock" 2021-01-27 22:12:30 +00:00
jenkins-bot
f5ba23f9b4 Merge "objectcache: add statsd key metrics to BagOStuff classes" 2021-01-26 00:15:06 +00:00
Aaron Schulz
57325ba3bd objectcache: add statsd key metrics to BagOStuff classes
Update SQL, REST, and redis subclasses to emit call count and
payload size metrics for cache key operations. These metrics
are bucketed by cache key collection (similar to WANCache).

Bug: T235705
Change-Id: Icaa3fa1ae9c8b0f664c26ce70b7e1c4fc5f92767
2021-01-25 14:36:29 -08:00
Paladox
ffe96ff3fb Fix fetching ipblock-exempt within BlockManager::getUserBlock
Bug: T271551
Bug: T270145
Change-Id: I458b7b6b3f79c5961c01c35677b7b25021e316a0
2021-01-25 13:29:39 +00:00
Petr Pchelko
2dd374f038 Make ContributionsLookup use Authority
Change-Id: Idcddff0f9c1968e24dc8d7d767e3233e368ec029
2021-01-21 13:45:18 +00:00
jenkins-bot
065aaa3ddc Merge "Revert "Enhance GroupPermissionsLookup and use it."" 2021-01-12 05:39:15 +00:00
Ppchelko
bdb5f394d3 Revert "Enhance GroupPermissionsLookup and use it."
This reverts commit 900c6663b0.

Reason for revert: breaks Parsoid CI. Instead of fixing the test in presence of the FlaggedRevs hook, I would rather convert DefaultPreferencesFactory to Authority and fix the tests once instead of doing it twice.

Change-Id: Iaa440a9804c9ed97339e737162ef64ccf29ceb51
2021-01-12 04:48:49 +00:00
jenkins-bot
87f373579c Merge "WatchedItemStore: use UserFactory" 2021-01-12 00:28:58 +00:00
Petr Pchelko
900c6663b0 Enhance GroupPermissionsLookup and use it.
Added new methods:
- ::getGroupsWithAnyPermissions
- ::getGroupsWithAllPermissions
- ::groupHasAnyPermission
- ::groupHasAllPermission

Replaced relevant calls to PermissionManager with
calls to GroupPermissionsLookup.

Bug: T254537
Change-Id: I0b9c3352c5bebc94e1649239fe0527144e7c2eb2
2021-01-11 11:05:54 -06:00
DannyS712
b40ca337c9 WatchedItemStore: use UserFactory
Will allow for converting to true Unit tests

Change-Id: I0ef2ada0d5ee9a80a104cb9b07a50e3887d02dd3
2021-01-10 03:12:25 +00:00
jenkins-bot
ef27ef25d1 Merge "rdbms: Use PSR-3 for ChronologyProtector shutdown debug message" 2021-01-09 00:41:53 +00:00
Timo Tijhof
613df39569 rdbms: Use PSR-3 for ChronologyProtector shutdown debug message
This is sent at the end of the LBFactory::shutdown wrapper, so will
still happen at the same logical point in time.

Use LBFactory->replLogger since that it is also the logger used
by ChronologyProtector.

Bug: T254634
Change-Id: Ic4a9573e6cd3ea00f77b2f44c03453c5b96fa486
2021-01-07 23:35:37 +00:00
Petr Pchelko
ae0b6c6a1e Introduce GroupPermissionsLookup
In order to break up cyclic dependency between UserGroupManager
and PermissionManager, introduce a lightweight service for checking
group permissions.

Bug: T254537
Depends-On: I99ab3a69c41b3ec6721f9504ad6c77d3122df591
Change-Id: I1acd55c07d07b4a0d43fd838e11374b6d9be98d9
2021-01-06 17:12:28 -06:00
Paladox
0b4c4402e8 Fix infinite recursion with wgAutopromote when using getBlock within checkCondition
The problem was that when using $user->getBlock
within checkCondition (APCOND_BLOCKED) caused a infinite
recursion as calling getBlock eventually leads back to checkCondition.

The fix here is to stop using userHasRight as that is the cause of the recursion.

This also fixes testGetUserAutopromoteBlockedDoesNotRecurse test so it
shouldn't fail.

Bug: T270145
Change-Id: Ic751eba70730de286bbd55772bd7562459fb30b4
2020-12-17 19:57:10 +00:00
Petr Pchelko
5a995333fb Remove ParserCacheFactory::getInstance
Added in 1.36, no deprecation process needed.

Bug: T269869
Depends-On: I5d81622d5857bc1d06a3600d8e9554882532714a
Change-Id: I182cb0cb7e4c569a64e2455ca80eda2d1f570608
2020-12-14 19:12:04 -06:00
daniel
00a3439dce Introduce RevisionOutputCache
Bug: T267981
Change-Id: Ib1dc641ed10d786918362b25bd655780d5844ba1
2020-12-14 16:50:28 +00:00
daniel
2c7ba6f62b PoolWorkArticleViewOld: use WANObjectCache
Use WANObjectCache instead of the local cluster object cache.

Bug: T268278
Change-Id: Ic16feffecaf4b75c284c6ef34de42ac113e625f8
2020-11-30 16:38:56 +00:00
C. Scott Ananian
c64e71615e Replace $wgDisable{Lang,Title}Conversion with LanguageConverterFactory methods
Replace direct access to $wgDisableLangConversion with
LanguageConverterFactory::isConversionDisabled(), and replace direct
access to $wgDisableTitleConversion with
LanguageConverterFactory::isTitleConversionDisabled().  However, most
places that check ::isTitleConversionDisabled() actually want
::isLinkConversionDisabled(), so add that too (and deprecate
isTitleConversionDisabled()).

Code search:
https://codesearch.wmcloud.org/search/?q=Disable%28Lang|Title%29Conversion&i=nope&files=&repos=

This change removes a number of spurious dependencies on the global
configuration and reduces code duplication (for example, if the logic
for disabling language conversion were ever to change).

Depends-On: I6fa8230ae97b0e34c381003548e61f9b7387d363
Change-Id: Icc4687638ff1815003dd903854efdbd904854f1e
2020-11-25 12:47:26 -05:00
Umherirrender
7f03231ace Inject services into SpecialContributions/SpecialDeletedContributions
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 another service to avoid global state

Bug: T259960
Depends-On: I07203e22f4b254df5c8cd6180d915a1537b7de30
Change-Id: Ifed2cbd2eee7166daf2e7d9bab017786247f88f6
2020-11-24 17:18:40 +00:00
Petr Pchelko
dbdc2a3cd3 Introduce JsonCodec to help with serialization/deserialization
Change-Id: I5433090ae8e2b3f2a4590cc404baf838025546ce
2020-11-19 08:32:21 -07:00
jenkins-bot
6e5c7e97b4 Merge "PoolWorkArticleView: inject logger" 2020-11-18 20:47:06 +00:00
jenkins-bot
2be635539f Merge "ParserOutputAccess: cache ouput for old revisions" 2020-11-18 19:52:10 +00:00
daniel
195bc9715d PoolWorkArticleView: inject logger
Bug: T267832
Change-Id: I7f4763d0e812d076188bb1a4ca2c333f50dffbee
2020-11-18 17:08:37 +01:00
jenkins-bot
c7f12ebae2 Merge "Replace deprecated WikiPage::factory in import/export related classes" 2020-11-18 00:15:28 +00:00
daniel
a2ae4192c0 ParserOutputAccess: cache ouput for old revisions
DEPLOY: Set $wgOldRevisionParserCacheExpireTime = 0 in production first!

Bug: T267832
Depends-On: I3c73f5d9f6a54e2736600e8f9506659a3fb0e7f6
Change-Id: I0fe275b4991f1bf89c7bb587132bc4fb0ea862e2
2020-11-17 20:52:35 +00:00
daniel
ed41864370 Extract PoolWorlArticleViewCurrent
Extracts a specialized subclass for rendering the current revision
from PoolWorlArticleView, which then no longer knowes about caching.

In the next step, we will add a subclass that implements caching for old
revisions.

Bug: T267832
Change-Id: I56fb365962951e6c723a01cf9243dbc0094b5581
2020-11-17 20:17:02 +01:00
daniel
175d548e61 Clean up PoolWorkArticleView
PoolWorkArticleView needs some cleanup before we can make it
cache output for old revisiosn (T244058).

This patch does doe following:
* apply dependency injection
* remove backwards compatibility code for legacy constructor calls
* mark PoolWorkArticleView as @internal (unused in extensions)
* remove audience check (to be done by caller)
* no longer set $wgUseFileCache to false.

For $wgUseFileCache, it seems like this has had no effect for a long
time. It would be set to false only on a cache miss during a page view.
But the file cache is only updated via HtmlCacheUpdater on edit and
purge.

Bug: T244058
Change-Id: Ief467562af0aa2f88ff7b42469d0273d2a1dcf7a
2020-11-16 12:06:20 +01:00
Umherirrender
539b6abba2 Replace deprecated WikiPage::factory in import/export related classes
Change-Id: I58c5d1bc7bfca872fe0bcfdc51828dcef5abdf02
2020-11-15 18:32:21 +00:00
Umherirrender
1273d68032 Inject WikiPageFactory into MergeHistory/MovePage
Via PageCommandFactory

Change-Id: Id4f247b9983cb22b8deb9d030ddeffed4ae1c956
2020-11-11 22:10:47 +01:00
DannyS712
3b0c5e579b Move EditPage::runPostMergeFilters to a constraint
Bug: T157658
Change-Id: I071163d6d2538948693527c36e8e59281f528402
2020-11-10 23:34:20 +00:00
Petr Pchelko
7c68ae9296 Safe ParserOutput extension data and JsonUnserializable helper.
One major difference with what we've had before is that now we
actually write class names into the serialization - given that
this new mechanism is extencible, we can't establish any kind
of mapping of allowed classes. I do not think it's a problem
though.

Bug: T264394
Change-Id: Ia152f3b76b967aabde2d8a182e3aec7d3002e5ea
2020-11-10 11:21:09 -07:00
daniel
67d0986211 Introduce ParserOutputAccess
Encapsulate logic for getting rendered page content, for any revision,
with caching and pooling hidden away.

Introducing such a service object will also give us a leverage point for
supporting output transformations. Output transformations are currently
implemented partially in ParserOutput, partially in Parser, and partially
duplicated in Parsoid.

Bug: T267234
Change-Id: I566d7a7936633823ba68b5aecbc8c2d88949b4f8
2020-11-10 15:12:12 +01:00
jenkins-bot
c360fd7f19 Merge "Use LinkBatchFactory in WatchedItemStore" 2020-11-06 21:24:23 +00:00
Umherirrender
eb85d2b795 Add todo comment about UserGroupManager/PermissionManager dependency
Bug: T254537
Change-Id: I600ce49bdb76f0b2fec0d09836dc655bb9eafd35
2020-11-03 18:33:58 +00:00
Umherirrender
17ec6f6a19 Use LinkBatchFactory in WatchedItemStore
Change-Id: I870b6b9780f0131fb8caa6d48999f3ab8800dd81
2020-11-02 19:01:25 +01:00
Umherirrender
64b8d8ad42 Inject BlockManager and BlockErrorFormatter into AuthManager
Change-Id: Icf5a68fa9477bb30afd6f3dd32d96ae44e95fed2
2020-10-30 14:52:08 +01:00
jenkins-bot
c507bff9f6 Merge "Add PageSizeConstraint and ChangeTagsConstraint" 2020-10-28 17:16:29 +00:00
DannyS712
cc8bab4111 Add PageSizeConstraint and ChangeTagsConstraint
Bug: T157658
Change-Id: I2c7b4f77cd07c72b42eaeb7e37095461c92b367a
2020-10-28 16:03:02 +00:00
Bartosz Dziewoński
77cf34fae7 Fix base path handling for MessagePosterModule registration
It was done in a funny way to allow extensions to provide paths that
are relative to a different base path than the core ones. This way
results in wrong paths on Windows. Use the ResourceLoaderFilePath
class instead, which I wrote for this exact purpose :D

With this approach, it should also be possible to handle remote paths
correctly, and remove the `'debugRaw' => false` hack in ServiceWiring,
but I don't entirely understand how that is handled in the extension
registration code.

Bug: T264965
Change-Id: Id501a10d87a60f8c71df49820e1fb866adc12411
2020-10-28 02:27:32 +00:00
DannyS712
05ae763ba2 EditPage: Migrate more checks to constraint
Add
- ContentModelChangeConstraint
- EditRightConstraint
- ImageRedirectConstraint
- ReadOnlyConstraint
- UserBlockConstraint
- UserRateLimitConstraint

Additionally:
- Split EditPageTest into a separate file for
all of the constraints being tested

- Add a helper EditConstraintTestTrait

- Add debug logging for EditConstraintRunner for
the result of each constraint

- Changed the order of some of the checks, which
may result in a different failure code if multiple
checks were going to fail, but shouldn't change the
overall result of whether an edit fails or not.

Bug: T157658
Change-Id: Ib8f8b62b9928544e5559c96d82bf850dd8cf9b05
2020-10-26 22:01:05 +00:00