Commit graph

397 commits

Author SHA1 Message Date
Thiemo Kreuz
df4120903d Remove now unused (bogus) cache key in RevDelRevisionList
Unused since Idbb5a5a.

Note it never worked because of a misplaced } at the end.

Bug: T238374
Change-Id: Ic8759a78d02fb5d3d600443445ba5122d512794b
2023-01-11 10:33:52 +01:00
Umherirrender
791ea13749 tests: Replace dynamic property MWCallableUpdate::$_name
Creation of dynamic property MWCallableUpdate::$_name is deprecated in
php8.2

Bug: T314099
Change-Id: I5e2b9df6c1f98be7b0c4396290acd545d1029cc2
2023-01-07 21:48:26 +01:00
jenkins-bot
6aa4f207a3 Merge "page: Show revision-deleted comment on oldid= view with unhide=1" 2023-01-03 21:57:06 +00:00
Umherirrender
e59cf6c133 Use SlotRecord::MAIN instead of hard coded value
Makes it clear what about the value is (slot role name)

Change-Id: I0dc195aa24c0e699a32d3b07e62d58e90cfac84d
2023-01-03 16:24:42 +01:00
Umherirrender
c323e36fb1 page: Show revision-deleted comment on oldid= view with unhide=1
A revision-deleted user name is shown for oldid=123&unhide=1
but a revision-deleted comment is not shown.

Just pass the same condition for argument "isPublic" to
Linker::revComment as done for Linker::revUserTools

Bug: T311468
Change-Id: Iad0cf5dd01149764d8a82ab50bc3661acd4c2679
2022-12-17 17:55:05 +01:00
Umherirrender
65087e7990 tests: Expand ArticleViewTest for unhide=1 and without unhide param
Change-Id: I93e53dc0cce50eb24ed0d7de0fd6b6b05e91f190
2022-12-17 17:53:11 +01:00
jenkins-bot
da23ae60e2 Merge "Hard-deprecate WikiPage::factory/newFromID/newFromRow" 2022-12-16 23:02:29 +00:00
Umherirrender
968213861d Hard-deprecate WikiPage::factory/newFromID/newFromRow
Deprecated in f871f7b

Bug: T297688
Change-Id: I7be6a70fd01919579e91856a0b12116381363edd
2022-12-16 23:41:30 +01:00
jenkins-bot
00c2dfa184 Merge "tests: Set UseInstantCommons config to false in WikiPageDbTest" 2022-12-15 19:14:12 +00:00
Amir Sarabadani
ca9ec658cb Reorg: Move PageProps to page/ and namespace it to MediaWiki\Page\
We should slowly migrate page/ to have proper namespace too but that'll
be pretty big.

Bug: T321882
Change-Id: I3e57be8aa8ac08971f190233196e84ea33023d4a
2022-12-09 13:17:40 +01:00
Umherirrender
6844f42f4c tests: Set UseInstantCommons config to false in WikiPageDbTest
When UseInstantCommons is true the tests with file redirects failing due
to http request to commons.
Needs to reset ForeignFileRepos, because UseInstantCommons is a dynamic
config and already evaluated when tests running

Change-Id: I1a2059e578229210a1e3789bf76fa3dfaa7b6ed3
2022-12-06 23:23:53 +01:00
jenkins-bot
1d045146d0 Merge "Make use of the new PageUpdateStatus" 2022-12-01 10:45:32 +00:00
daniel
166b569444 Make use of the new PageUpdateStatus
PageUpdateStatus provides clean access the the newly created
RevisionRecord.

Depends-On: Ia08c586198082ea47e8313d0d41835f9830fb29e
Change-Id: Id6963842321c4eaa3d7d029ad0b769f73433c103
2022-11-30 17:56:58 +00:00
Umherirrender
c6fecd5ab0 tests: Replace assertEmpty with assertSame
assertSame avoids use of loose comparisons and
allows to check the expected type

Change-Id: If821d1be2bc1ff9f8b70968a339f33c7a8e8880a
2022-11-25 00:42:53 +01:00
Amir Sarabadani
bbe704b5c1 Reorg: Move some of request related classes to MediaWiki/Request
Redoing I5ea70120d74 but without moving WebRequest that caused issues
with phan-taint-plugin.

Moving:
 - DerivativeRequest
 - FauxRequest
 - FauxRequestUpload
 - PathRouter
 - WebRequestUpload

Bug: T321882
Change-Id: I832b133aaf61ee9f6190b0227d2f3de99bd1717b
2022-10-28 10:15:31 +00:00
Zabe
f6b9381d7f Revert "Reorg: Move some of request related classes to MediaWiki/Request"
This reverts commit 2bdc0b2b72.

Reason for revert: T166010#8349431

Bug: T166010
Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
2022-10-27 13:14:16 +00:00
Amir Sarabadani
2bdc0b2b72 Reorg: Move some of request related classes to MediaWiki/Request
Moving:
 - DerivativeRequest
 - FauxRequest
 - FauxRequestUpload
 - PathRouter
 - WebRequest
 - WebRequestUpload

Bug: T166010
Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
2022-10-26 16:49:10 +02:00
Umherirrender
6005493b67 tests: Replace deprecated WikiPage::factory in WikiCategoryPageTest
The factory returns always a WikiCategoryPage for NS_CATEGORY

Bug: T297688
Change-Id: Idb8cf154e57313c4eae8139acf83a61f06c9beac
2022-10-23 22:42:56 +02:00
xiplus
bde49b2153 Article: Fix missing patrol link for pages that have been moved
No need to check if the namespace is the same. There are many articles
moved from draft or user space.

Bug: T162871
Change-Id: Ide73adf356df2047ee821d2a3680c9c163e564a9
2022-10-21 22:13:14 +00: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
Umherirrender
89b2d11a0d tests: Use Title::makeTitle instead of Title::newFromText
Avoid parsing known titles in tests to improve performance

Change-Id: Ie240eb42479d19714e64cc4606e26073fadc2e13
2022-09-23 21:53:11 +02:00
jenkins-bot
aafa2e0b04 Merge "tests: Replace deprecated WikiPage::factory" 2022-09-09 16:25:08 +00:00
Umherirrender
6555923b08 tests: Replace deprecated WikiPage::factory
Bug: T297688
Change-Id: Ic84d491c5603f3590e26cb56a305508b2b0ca109
2022-09-02 19:34:02 +00:00
Derick Alangi
00b38e1345 ParserOutputAccessTest: Inline services & avoid creating variables
The services can just be inlined instead of creating containers that
are only used once.

Change-Id: Ib29a376df9d2cce50c169ba5724d5a9baf65f7d3
2022-09-01 22:25:22 +01:00
jenkins-bot
66d786df0c Merge "Inline a few more trivial createMock() calls in tests" 2022-08-11 23:23:47 +00:00
Amir Sarabadani
8614e30638 rdbms: Stop accepting live connection in DBConnRef constructor
This just makes the class overly complex and defies the whole point of
having this class in the first place (=delaying getting db connections).

It makes it harder to read and understand and specially polymorphic
arguments are quite confusing.

It also would break the reloading db on the fly (I6c3ffde62f6e), users
of DBConnectionRef should not know about the underlying connection, this
class is trying encpsulate that and accepting connection in constructor
breaks this encapsulation.

Bug: T298485
Depends-On: I951ab99ae766788dbae8bd338aaae114a388b21f
Change-Id: I743c0565504c65c4dedf29f2a36d4c386601fda0
2022-08-08 18:11:31 +02:00
Thiemo Kreuz
9e6e3f8d08 Inline a few more trivial createMock() calls in tests
createMock() is still relatively new. This code was using more
complicated mock builders before. This was changed just recently.
createMock() is now so short, the extra helper methods don't make
the code more readable, I would argue.

Change-Id: Ia7e24827157d5f49fc7da102418c79ae33c8e053
2022-08-08 09:50:50 +02:00
Derick Alangi
5e8cd2c838
Migrate from setMwGlobals() to overrideConfigValue(s)
Change-Id: I3f167d0e7d59a5aa091c3095a7d96c889d6e7e78
2022-08-02 10:14:10 +01:00
C. Scott Ananian
008095280a Use canonical parser options when rendering JavaScript/CSS for side effects
In the JavaScript and CSS content handlers we render the page "as
wikitext" solely to generate categories, toc, etc, and then throw that
output away and replace the generated HTML.  Simplify the code paths
and the caching by using the canonical options which don't split by
user language, etc.

Three minor issues with the current patch, which can hopefully be
addressed in follow ups:

1. WikiPage::makeParserOptionsFromTitleAndModel() has a very cumbersome
   name and arguably doesn't belong in WikiPage in the first place.
   T313455 already exists to find a better place for this/way to do this.

2. Title::isConversionTable() requires a downcast of the page reference
   to a full title object.  This method also probably wants to live
   somewhere else.

3. It really would be nice to combine this more properly with
   ContentHandler::getParserOutputForIndexing(), but that method
   uses a ParserOutputAccess object which requires a PageRecord,
   and we don't have a PageRecord available in fillParserOutput().

Bug: T307691
Change-Id: I081105741b507ed49e19cb878550ba4293e09413
2022-07-28 10:45:35 -04:00
Umherirrender
8b1a3d13eb tests: Use WikiPageFactory to create WikiPage object
Bug: T259948
Change-Id: I9afcf3b845306f81ee5ca156553256e6c38df3a0
2022-06-26 23:21:02 +02:00
jenkins-bot
b66fddf583 Merge "page: Change visibility of some WikiPage members to protected" 2022-06-16 20:29:11 +00:00
Derick Alangi
d01e3ed739 Replace deprecated calls ParserOptions::newCanonical( 'canonical' )
This is a quick find & replace of calls to the deprecated method
ParserOptions::newCanonical() when the context is the string literal
'canonical'. This can be safely replaced by called newFromAnon().

Change-Id: If7bb68459b11e0c5f5de188f10fdae85ad1a78bf
2022-06-16 14:22:24 +01:00
Derick Alangi
40c1f56dcc page: Change visibility of some WikiPage members to protected
After surveying consumers of these members, apart from the WikiPage
class itself that uses it internally and FlagabbleWikiPage in the
FlaggedRevs ext which subclasses WikiPage, I don't see any other
consumers of this member.

So it can be safely marked as protected as we're sure nothing is
consuming this publicly.
See: https://codesearch.wmcloud.org/search/?q=%5C-%5C%3EmDataLoaded&i=nope&files=&excludeFiles=&repos=,
https://codesearch.wmcloud.org/search/?q=%5C-%5C%3EmPreparedEdit&i=nope&files=&excludeFiles=&repos=,
https://codesearch.wmcloud.org/search/?q=%5C-%5C%3EmLatest&i=nope&files=&excludeFiles=&repos=

NOTE: The tests in ArticleTest.php was removed as the WikiPage::mLatest
      is now a protected member and can't be accessed publicly.

TODO: The last of it's kind is WikiPage::mTitle which will be removed in
      a later patch and that one will be quite bit and tricky.

Change-Id: I78c5b4c31090fe2e01b4cc922ec77131be3223dc
2022-06-16 13:21:34 +01:00
Derk-Jan Hartman
ae943daee4 SVG Language selector should default to page language
Taking into account the pagelanguage should help take into account the
language variant on image pages in languages that have variants.

Bug: T310445
Change-Id: Ic821b2de66ed876e47c74ac21cedaad7a70a80fc
2022-06-13 21:17:25 +00:00
DannyS712
e91c3520a1 Make user parameter required in WikiPage::prepareContentForEdit()
Has been emitting deprecation warnings if not provided since
1.37.

Bug: T285732
Change-Id: I1ffc013f0371e309e50e0cfabc530ff7ce1a95cf
2022-06-03 23:48:05 +00:00
DannyS712
0e3942092e Remove deprecated WikiPage::doEditContent()
Bug: T286139
Change-Id: I17b144f62a3e8f42d221d6476651dbd4c7554524
2022-06-03 21:43:31 +00:00
Umherirrender
05cf95e7bb wikipage: Remove usage of protection related deprecated Title function
Bug: T306131
Change-Id: Idfda7f0550f9b213c6ac436404831ec445be3372
2022-05-10 22:28:48 +02:00
Amir Sarabadani
30aa4679c0 Remove references to legacy page_restrictions field in page table
Bug: T218446
Change-Id: I4d45de0890b96e00d4b24fc96ceffbf336928bc2
2022-05-09 11:20:53 +02:00
Umherirrender
2909d06a08 Use new namespace for revision related classes
All revision related classes are namespaced MediaWiki\Revision
instead of MediaWiki\Storage since 1.32. The old namespaced
class names are deprecated and only kept for backwards-compatibility.

Bug: T305784
Change-Id: I34e492d84d9fc4bc78481667202716d93b3c43cb
2022-04-14 23:03:43 +02:00
Jon Robson
1c13772366 Drop messagebox, warningbox, errorbox classes
This can be done when relevant communities have been notified
and the classes have rolled out of cached HTML.

Bug: T270796
Change-Id: If35ebe88702bf97f2306c77b26d8b3cab4c0420d
2022-04-11 17:40:04 +00:00
Adam Wight
f21b52bec3 Remove test-only method
Usually we opt to break access control in a test, rather than expose
internals in production classes.

Change-Id: I7e393d2569e8784e2c8eb7ed29d60aab58b9bd83
2022-04-06 10:01:52 +02:00
Daimona Eaytoy
4ce0b39043 UndeletePage: Undelete associated talk page
* Adds option to undelete associated talk page in the context of a
  subject page
* If subject page undeletion fails, talk page undeletion is aborted
* If restoring the associated talk page fails, a status with a
  warning message is returned

Bug: T304962
Change-Id: I7b30863060974d4079639f57178062d359956c2e
2022-03-30 14:08:08 -04:00
stang
9c70df0cf6 Fix uses of (error|warning|success)box in core
Replace HTML class for boxes with "mw-message-box-" style.

Bug: T300358
Change-Id: Iddb0fd3ae859714fb03d3a6d4586f8525becaac6
2022-03-20 21:15:26 +00:00
daniel
e239b02a5e Add convenience methods for asserting status.
This ensures that assertions work in a uniform way,
and provides meaningful messages in cause of failure.

Change-Id: Ic01715b9a55444d3df6b5d4097e78cb8ac082b3e
2022-03-16 22:44:25 +01:00
Timo Tijhof
8d406bbcd6 phpcs: Disable Generic.Files.LineLength for test files
There is a common and reasonable need for longer lines in tests.
The nudge for shorter lines doesn't seem valuable here. The natural
breaks will likely still fall in 80-100 given the enforced practice
for non-test code, e.g. whether through habit, or 80-100 column markers
in text editors, or the finite width of diff and code review
interfaces.

Change-Id: I879479e13551789a67624ce66f0946d2f185e6ee
2022-02-18 18:32:05 +00:00
Amir Sarabadani
206f6cbd50 ParserOutputAccess: Add process cache within the service class
This guards against duplicate parses.

These happen when a page is parsed but an extension needs the
ParserOutput again in the same request when it hasn't made into the
ParserCache yet, or if it is considered uncachable. In that case we
still want to allow re-use within the same process.

Bug: T301310
Change-Id: I1ddd967a40b760b1e53f1fd227cb0d0732f78ec1
2022-02-16 12:18:21 +00:00
Func
7f74a2e50c Clean up tests that misused the parameters of assertSame/Equals
Expected value is the first parameter to assertSame() or assertEquals().
And turn to use assertCount() for some assertions aginst count of array.

Based on code search `assert(?:Same|Equals)\(.+,.+expected` and I look
through files roughly, so some assertions that don't contains 'expected'
are also fixed. In the meantime, some assertions that I am not clear
about are not touched.

Change-Id: I75798b60d29fd19b33f4fdf34ed3c788db420d01
2022-02-08 07:21:10 +00:00
Ammarpad
c7734cbb9f Add getMemberCount() to Category to supersede getPageCount()
getPageCount() method return `cat_pages`, a value that makes sense
on database table but is currently non-intuitve in object context
where there's a value that better deserves the name. This makes it
necessary for callers to repeat same logic to get the content pages
count and a comment to explain the behavior.

In this patch, getMemberCount() is added. It returns the total
member count as getPageCount(), by default, does now.

getPageCount() now takes a parameter and two public constants are
provided for that; Category::COUNT_CONTENT_PAGES return count of all
memebers to retain existing behavior, Category::COUNT_CONTENT_PAGES
will return only content pages.

In future there'd be no need for the parameter. Content pages will
be returned always. Total member count is already accessible with
getMemberCount().

Also improve return type doc of getId() and getName()

Bug: T299350
Change-Id: I63c711ebc697c1a131a50910c854f956d4021254
2022-01-31 13:59:34 +01:00
Alexander Vorwerk
decbaf4f38 phpunit: use ->getServiceContainer() in integration tests
Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
2022-01-27 22:04:16 +01:00
jenkins-bot
fd84c0f087 Merge "tests: Replace usages of deprecated WikiPage::doDeleteArticleReal" 2022-01-27 19:32:06 +00:00