Commit graph

129 commits

Author SHA1 Message Date
Tim Starling
92da816a92 Special:Undelete "load more" followups
* Rename $offset to $extraConds
* Pass the limit as an integer instead of an options array
* Fix unnecessary extra parameters
* In JS, fix URL encoding
* In JS, show the link again on error so that the user can retry, and so
  that it doesn't appear as if the end of the list was reached.

Bug: T249977
Change-Id: Ifaf8d1e9537da9245a7340c76af9c975f1fb643f
2023-05-29 11:19:54 +10:00
arttsymbar
f399b285da Add load more button to get Special:Undelete revisions by parts.
Update SQL query option to use timestamp for search.
Update "undelete logic" to load data by parts according to history
limit constant. Create module with js and styles for "load more"
button, use ajax call to get next revisions data.

Bug: T249977
Change-Id: I102b6ea1109733d032223e4fa187f934cf128740
2023-05-29 11:19:54 +10:00
Umherirrender
fdde3961df tests: Fix casing of MediaWiki\ namespace references
Change-Id: I0cd36c5321499f1993804656318d56843b3f3090
2023-05-05 22:19:56 +02:00
Tim Starling
be3018b268 Just another 80 or so PHPStorm inspection fixes (#4)
* Unnecessary regex modifier. I agree with this inspection which flags
  /s modifiers on regexes that don't use a dot.
* Property declared dynamically.
* Unused local variable. But it's acceptable for an unused local
  variable to take the return value of a method under test, when it is
  being tested for its side-effects. And it's acceptable for an unused
  local variable to document unused list expansion elements, or the
  nature of array keys in a foreach.

Change-Id: I067b5b45dd1138c00e7269b66d3d1385f202fe7f
2023-03-25 00:39:06 +00:00
Tim Starling
5e30a927bc tests: Make some PHPUnit data providers static
Just methods where adding "static" to the declaration was enough, I
didn't do anything with providers that used $this.

Initially by search and replace. There were many mistakes which I
found mostly by running the PHPStorm inspection which searches for
$this usage in a static method. Later I used the PHPStorm "make static"
action which avoids the more obvious mistakes.

Bug: T332865
Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
2023-03-24 02:53:57 +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
Amir Sarabadani
c8116223b4 Reorg: Move category-related classes from includes/ to Category/
Bug: T321882
Change-Id: I0b86acfdeaa3a2a0a14b7763fd088122820bafdc
2023-02-09 20:18:54 +01:00
Func
f81ab9545a Replace some use of Language::truncateForDatabase() with mb_strcut()
For MessageContent::getTextForSummary(), the behaviour is exactly
the same;
For WikiPage::insertRedirectEntry(), the trailing ellipsis would
prevent landing on the position of the anchor;
For UserOptionsManager::saveOptionsInternal(), I also found the
trailing ellipsis is unnecessary, follow-up to commit 2a51865.

Bug: T326696
Bug: T207876
Change-Id: I2ec1878147cb0447794d2404db632733f83164cd
2023-01-30 04:50:33 +00: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
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
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
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
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
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
6555923b08 tests: Replace deprecated WikiPage::factory
Bug: T297688
Change-Id: Ic84d491c5603f3590e26cb56a305508b2b0ca109
2022-09-02 19:34:02 +00: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
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
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
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
jenkins-bot
993b432670 Merge "Avoid COUNT(*) in assertSelect() for WikiPageDbTest" 2022-01-26 20:04:52 +00:00
Umherirrender
5503987b98 Avoid COUNT(*) in assertSelect() for WikiPageDbTest
This makes the query working on postgres and sqlite

assertSelect generates a query like:
SELECT COUNT(*)
  FROM `unittest_redirect`
 WHERE rd_from = 2
 ORDER BY COUNT(*)
Which seems problematic on both rdbms

Bug: T195807
Bug: T197734
Change-Id: I6a687bb9a40b05c380bac0d1a32e13589485ac7f
2022-01-26 18:42:56 +00:00
Ammarpad
a47e06b669 Category: Return proper int for files, subcats and pages count
Count should rarely be anything other than number. Most callers
have to manually cast to integer after calling these methods[1]

Although boolean false is internally cast to 0, explicit int
for both success and failure is better here.

[1] https://codesearch-beta.wmcloud.org/search/?files=&i=nope&q=-%3EgetPageCount%5C%28

Change-Id: Ia7965835a6929b0f91453211233e188c755d8b9f
2022-01-24 06:27:18 +01:00
Daimona Eaytoy
2688c59606 tests: Replace usages of deprecated WikiPage::doDeleteArticleReal
Add a new helper to MediaWikiIntegrationTestCase, since deleting pages
seems to be pretty common in tests.

Some calls to WikiPage::factory were also updated to use WikiPageFactory.

Change-Id: I5b5100273a00ac292a1900022ca79708fa254347
2022-01-17 15:38:02 +00:00
Tim Starling
682aad7557 Move LinksUpdate and LinksDeletionUpdate into the new namespace
Change-Id: I5cf7a08324d08aa89c23540222ba8eddc1ae2647
2022-01-04 15:35:57 +11:00
daniel
cbfcf9e8a8 Introduced PreparedUpdate to replace PreparedEdit
PreparedUpdate represents an in-progress edit. It can be used to access
information about the edit from hooks that do to have access to the
PageUpdater. Ideally, the PreparedUpdate or PageUpdater would be passed
to the hook as a parameter. Handlers of legacy hooks may use
WikiPage::prepareUpdate() to access it.

Bug: T242249
Needed-By: I23324a31e06e7e6f28077085c0ade05db63e9a35
Change-Id: Id5ba40a21cc4547205adf2f3a1f725c3a69c24d8
2021-12-20 21:19:52 +01:00
Derick Alangi
8fe9e0317f Introduce Redirect(Lookup&Store) services to handle redirects
The concept of a redirect chain didn't really work for a value of
max redirect > 1. In the ideal world, we just want to have a source
which points to target (source -> target) discarding the concept of
a redirect chain completely.

Having something like: source -> target -> target1 -> target2 doesn't
really work well with the current database design.

NOTE: Support for $wgMaxRedirect will be removed soon hence
deprecation without interfaces for replacement.

Bug: T290639
Change-Id: I469de6f85e405e8ddbe7abaa5b99b77cb9cf415d
2021-12-01 19:14:22 +01:00
Aaron Schulz
b1ab76471f edit: Make PreparedEdit->timestamp lazy to avoid eager parse
Avoid triggering a parse in DerivedPageDataUpdater::getPreparedEdit().

Defer the internal getOutput() call till when something actually tries
to access the timestamp property.

Bug: T277788
Change-Id: I899d9966214b36ebcd660aaf7c2da399e35be92e
2021-12-01 12:34:36 +00:00
Derick Alangi
45c692eeef Stop accessing members of the Title class publicly
For now, let's just proxy the title object and set the
interwiki but to make things nicer, we should not provide
a title via setUp(), we should use providers.

Bug: T275763
Change-Id: I761de85ae5a839e8a695b85ce0fd7200b498da22
2021-11-22 14:22:51 +00:00
Reedy
6e29611642 Remove or replace usages of "sanity"
Still some more to go...

Bug: T254646
Change-Id: Ia117f01e443c35b4765f3275cab4f2707e1be96f
2021-11-21 16:42:31 +00:00
Daimona Eaytoy
1ccd95dca4 Deprecate $hasHistory param to ContentHandler::getAutoDeleteReason()
Unused except for DeleteAction, which now uses a custom query (similar
to the one in ContentHandler::getAutoDeleteReason). Passing the
parameter is hence hard-deprecated, and it will be removed in 1.39.

Also escalate the exception logging from wfDebug to error, since we want
to know what exceptions are being caught.

Bug: T288282
Change-Id: I91ed9574da68bc7ff36e968f016da390b6d295ed
2021-11-11 23:14:42 +00:00
Roman Stolar
957697e1e0 Hard-deprecate Content::getParserOutput and AbstractContent::fillParserOutput.
Use ContentRenderer::getParserOutput instead.
Extensions defining a content model should override ContentHandler::fillParserOutput.
Update tests.

Bug: T287158
Change-Id: I1c71a8429806f1813a39f5807256b2eb9fb9901f
2021-10-29 14:04:22 +03:00
Derick Alangi
d62ba36bba Use PageUpdater's fluent interface
Change-Id: I541b7ae565c46d00ab5e1de08a2447461a9e73a7
2021-10-05 07:18:17 +01:00
Umherirrender
0e4bb6d611 Change 'fromdbmaster' to WikiPage::READ_LATEST
Constants are harder to misspell

Change-Id: Ie1afcc8580cccf815df1cc97f05a5be81676d9f7
2021-09-26 19:27:33 +00:00
Derick Alangi
2432cc2bb4 Use PageUpdater's fluent interface as in some parts of our codebase
Some methods in the PageUpdater's class implements the fluent interface
design pattern. Use the fluent interface where need be.

Change-Id: If76a4b8c5070c20ed40038a4ee78e2d677de5180
2021-09-23 00:31:33 +01:00
Daimona Eaytoy
a8200aa5a8 Deprecate WikiPage methods replaced by DeletePage
Also remove the "@unstable" annotation from DeletePage.

Methods without known usages were hard-deprecated, the others
soft-deprecated.

Bug: T288758
Bug: T288759
Change-Id: I30c62572fd533526779a8ade3ab178f35bebb522
2021-09-16 20:17:45 +00: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
jenkins-bot
6ae92c0c73 Merge "Improve DeletePage tests" 2021-09-09 21:10:39 +00:00
jenkins-bot
1efeefe017 Merge "PageStore: Use LinkCache" 2021-09-09 20:04:47 +00:00
Daimona Eaytoy
1f86010f0f Improve DeletePage tests
Should have decent coverage now.

Bug: T288758
Change-Id: I2342f2072cd9c6d50831b9c3e7dd36f4a5e1c8e4
2021-09-08 17:37:52 +00:00
Daimona Eaytoy
73f0ae36a3 Make DeletePage a real service
- Switch do actual DI
- Add some more parameters for needed dependencies
- Create a factory interface, implement it in PageCommandFactory and add
  wiring for it.
- Add new unit tests for DeletePage; unfortunately, this requires
  conditionally disabling some code during tests due to dependencies on
  legacy code that hasn't been migrated yet. I believe that these
  temporary hacks are acceptable, since they allow us to use real unit
  tests immediately.
- Adjust WikiPageDbTest: the two logging tests were identical as of
  Ie0d9da2c8d273c93301921e1e108d9ffb381b8a5; and then the logging part
  could just be part of the "main" test.
- Add integration tests for DeletePage. For now, these are all copying
  their WikiPageDbTest counterpart. More tests will be added soon™.

Bug: T288758
Change-Id: I2fb79ed905ce621cb87f0658983d97148948da28
2021-09-08 11:43:04 +00:00
daniel
3b6345ca16 PageStore: Use LinkCache
This makes the data stored by LinkCache compatible with PageStoreRecord,
so we can use LinkCache inside PageStore.

This causes PageStore to make use of local caching as well as WANObjectCache.

Note that getPageById() does not yet benefit from cache, but does
populate the cache.

Bug: T278940
Change-Id: Icc27a0d9299a3e4ce45521daef87ad06ec06f064
2021-09-01 08:24:34 +00:00
Daimona Eaytoy
6a3b9daf29 Make WikiPage a ProperPageIdentity
Bug: T272424
Change-Id: I1dbcf1192390cbdfd6faaa60f9831f62ec1eff0d
2021-08-30 13:05:18 +00:00