Commit graph

36 commits

Author SHA1 Message Date
Petr Pchelko
cd1ead94ea Clean up MergeHistory
1. Remove deprecated support for direct construction of MergeHistory
2. Store reading from the database inside the constructor.
3. Remove ::checkPermissions, deprecated since 1.36

Change-Id: I523d72ab7cb56c76f5d17fb51436fb356441d791
2021-07-13 12:01:04 -07:00
Petr Pchelko
d9b3c66dbc Add convenience constructors for PageReference/Identity
Change-Id: Id2433f707ea84ea5a57f427fd606de4b109eef43
2021-06-07 07:31:24 -07:00
DannyS712
240dfd77d8 Add tests for PageCommandFactory
Replaces the removed tests for MovePageFactory and
RollbackPageFactory, which used FactoryArgTestTrait

Change-Id: I53669590c4aa0ca12d0839e5dde9068abbaa59fb
2021-05-15 19:48:09 +00:00
Petr Pchelko
8cf3ae8613 Drop RollbackPageFactoryTest
Same as recently deleted MovePageFactoryTest, this
test is not really verifying anything and it's too
hard to maintain

Change-Id: I3a85131f9820deb90e1e96a6f16ce70623bd6ff7
2021-05-13 18:07:11 -07:00
daniel
62176bec1b PageIdentityValue: apply basic validation of titles
In order to prevent bad titles from entering the database,
PageIdentityValue should not allow instances that have obviously broken
dbeys, just like it does not allow construction for a special page.

Note however that for now, we allow PageReferenceValue to represent
thigns that are not actual pages, such as titles like "User:#1234" which
are used in the block log to represent autoblock targets. Similarly,
a PageReferenceValue can represent a special page.

This patch introduces a convenience method for constructing
PageIdentityValues in a context where it is uncertain whetehr the title
is valid, providing an opportunity to the caller to report in which
context the bad values were found.

In addition, this patch adds some documentation and testing, to clarify
the semantics of methods in PageStore with respect to invalid and non-
proper titles.

Bug: T282070
Change-Id: I8a44d9e73dda8fe38d009847332946809767d0fa
2021-05-07 17:17:45 +02:00
jenkins-bot
d58e417207 Merge "Eliminate use of Title object in REST infrastructure" 2021-05-06 08:40:46 +00:00
Tim Starling
c5390fcefc Remove harmful validation regex in PageReferenceValue
Catching common issues here instead of where the caller expects breaks
log formatting, including complete breakage of Special:RecentChanges.
The doc comment says that validation is the caller's responsibility,
which seems like a good idea to me.

Bug: T282070
Change-Id: Ic7e5c5576564e61906a812d50ea4e48adf5ac998
2021-05-06 11:56:12 +10:00
Petr Pchelko
4ca16e8d08 Eliminate use of Title object in REST infrastructure
Change-Id: I585f0f23cac5f6dc2a4879f69f7b83828fda3dd3
2021-05-05 18:54:58 -07:00
DannyS712
7bd7d2a6c1 Remove hooks that use Revision objects
All hooks were previously hard deprecated
in 1.35. Affected hooks:
* ArticleRevisionUndeleted - use RevisionUndeleted
* ArticleRollbackComplete - use RollbackComplete
* DiffRevisionTools - use DiffTools
* DiffViewHeader - use DifferenceEngineViewHeader
* HistoryRevisionTools - use HistoryTools
* NewRevisionFromEditComplete - use RevisionFromEditComplete
* PageContentInsertComplete - use PageSaveComplete
* PageContentSaveComplete - use PageSaveComplete
* ParserFetchTemplate - use BeforeParserFetchTemplateRevisionRecord
* RevisionInsertComplete - use RevisionRecordInserted
* TitleMoveComplete - use PageMoveComplete
* TitleMoveCompleting - use PageMoveCompleting
* UndeleteShowRevision - no replacement

Includes a fix for setting the associated rev id
of page protections, which previously was only done
using $nullRevision which was a Revision object created
if any hooks needed it; those hooks were hard deprecated
and so for WMF prod the rev id was not being set.

Bug: T247143
Depends-On: Idfa345193ae99fb2f1c9a8f8d28d8d540a6e3d62
Change-Id: I519167f76a5a3c1f5410415b2721462a3dcc3ec8
2021-04-30 17:28:20 +00:00
Petr Pchelko
ccd4b6d98b Give WikiAwareEntityTrait it's own unit tests.
Change-Id: I7f3b9e58a3d0ff4aeb1315c16d3cf91b79530095
2021-04-27 20:31:14 -07:00
Tim Starling
647e6be277 Remove MovePageFactoryTest
The tests in this file make no sense now that MovePageFactory no longer
exists. Obviously you do not pass all constructor arguments to
PageCommandFactory through to MovePage.

To make it pass against the following commit, I could update the
getExtraClassArgCount(), but that would be necessary pretty much every
time the constructor argument list of either class is changed. There's
no reason to think a difference in argument count is an error anymore.

Change-Id: Id4f4b43d47217ebb0111800d7ccb9855d56f7abb
2021-04-15 14:05:49 +10:00
jenkins-bot
9c74a067c3 Merge "Factor out rollback logic from WikiPage" 2021-04-14 20:22:27 +00:00
Petr Pchelko
46db19ecdf Factor out rollback logic from WikiPage
Change-Id: I95da91875fcf2f53143c315560e35ccd5ffbf4b3
2021-04-14 11:49:07 -07:00
daniel
5faa080374 Introduce PageReference
This explores the idea of a PageReference type which represents a
namespace/dbkey pair.

Every ProperPageIdentity is a PageReference. Some LinkTargets can be
mapped to a PageReference.

Bug: T279522
Change-Id: Id8b0c781fce329adcc4770f4840b2ba0108f6898
2021-04-13 23:32:20 +02:00
daniel
a4b73eb217 PageRecord: make language optional
Title::getPageLanguage has complex logic to determine the effictive
language of the page. PageRecord is a storage layer primitive and should
not haveknowledge of such logic, nor should PageStore.

The effective content language of a page needs to be determined
programmatically, see discussion on the ticket.

Bug: T278591
Change-Id: Ic26f6f7690499b3dd87982e3822881fd473cfd68
2021-04-08 20:16:36 +02:00
daniel
fe9430947d Use PageStore in RevisionStore
This introduces PageStoreFactory as well.

Change-Id: I7abd3c6a8ea70a68e8f8e9460d3bdd8c6f45338a
2021-04-05 20:58:54 +02:00
Petr Pchelko
bc7b6c1d14 Convert MergeHistory to Authority
Change-Id: Ic610f6db83c8e6724efa642ae59b617249af0a73
2021-03-23 16:52:07 -06:00
daniel
f37ebf4478 Introduce PageRecord interface
PageRecord is intended as a lightweight alternative to WikiPage,
similar to RevisionRecord.

Bug: T272421
Bug: T272422
Depends-On: Ia34cc8fa795b6b27832982fc22fa237ee36339b4
Depends-On: I39a984c9f3132f755f7d8984b789d05ad080d7b4
Change-Id: Ib3c9b22e0c0b7c97e6c230f2fecf0663b4c68cc6
2021-03-22 12:41:29 -06:00
Petr Pchelko
7955db4d8d Convert MovePage to Authority
Change-Id: I7d4503711ab1b739ca88b5fd0aa9e336cbac06aa
2021-03-17 19:43:46 -06:00
Petr Pchelko
26be00fac4 Introduce helper WikiAwareEntityTrait
Bug: T273948
Change-Id: I21180d7031646f13413e2edb1bf0a17fbfdada13
2021-02-08 13:49:50 -06:00
Petr Pchelko
816e02ae51 Convert RevisionRecord to Authority and PageIdentity
As we convert the RevisionRecord to using Authority,
we no longer need Title instances, so we can convert
that to PageIdentity.

Ideally, we'd part away from using Title at all, but:
1. For foreign wikis PageIdentity has stronger validation,
so calling PageIdentity getId() on Title will break things.
There's still a lot of code depending on lax Title guarantees,
so we keep it.
2. A lot of code still depends on Title, so we try to pass it
through even if we don't nesessarily need to, to save cost
on recreating it later on.

Bug: T271458
Depends-On: I287400b967b467ea18bebbb579e881a785a19158
Change-Id: I63d9807264d7e2295afef51fc9d982447f92fcbd
2021-01-21 13:37:01 -06:00
daniel
98c4dc39b7 PageIdentityValue: fix isSamePageAs for foreign wikis
isSamePageAs needs to pass the wikiId to getId().

Change-Id: I49e50287a782d931334ad8bcea31d2b80f343f0d
2021-01-20 18:30:14 +01:00
daniel
10ccdb2281 Define equality for PageIdentity and LinkTarget
Bug: T272420
Change-Id: I2e0eb21989e2d733088ab77d7461bf003c2905eb
2021-01-19 23:07:37 +00:00
James D. Forrester
a8fe6c9841 Revert "Define equality for PageIdentity and LinkTarget"
This reverts commit 36f1adf670.

This has seemingly broken FlaggedRevs and thus a bunch of repos.

Bug: T272170
Change-Id: I26c6fd656c75a6b209fb17965dc9109edf68642b
2021-01-15 12:30:14 -08:00
daniel
36f1adf670 Define equality for PageIdentity and LinkTarget
This allows Title and WikiPage objects to be compared with PageIdentity
and LinkTarget instances consistently.

Change-Id: I1bbd15d17d046359393ecfc1acd2778273260a95
2021-01-15 17:53:28 +01:00
daniel
1a60008a9a Introduce PageIdentity interface
PageIdentity is intended as a lightweight alternative to Title,
similar to LinkTarget, but providing a page ID. It follows the precedent
of UserIdentity.

Bug: T208776
Change-Id: Iaed4871e0d32c67d4fb13e487625527f6a21e9c5
2021-01-14 13:18:05 -06:00
DannyS712
29aa36c06e Add MergeHistoryFactory interface, implemented by PageCommandFactory
Bug: T249446
Change-Id: I94676e065a8aed5cad2fe2d5cf16ca586adce97d
2020-05-13 19:08:09 +00:00
Max Semenik
09f2feafd6 tests: Make static/non-static functions match
PHP 8 is stricter about this.

Bug: T248925
Change-Id: I0e9c736d0e2a28ce4a1e096a8ec63321d8b41635
2020-04-29 10:59:53 +03:00
DannyS712
b14965e75e Convert MovePageFactory to interface, implement in PageHandlerFactory
Bug: T249446
Change-Id: I1335d976b992f44c8609c298f0ec19d81afa7b84
2020-04-27 23:26:28 +00:00
Matěj Suchánek
3ce567d8ac Replace Linker::link usage with LinkRenderer in includes
Needs one unit test to become integration again :(

Bug: T149346
Change-Id: I62fc566dfb542939431fd4a135c05e0924c70dbf
2020-01-11 11:20:17 +01:00
Max Semenik
48a323f702 tests: Add explicit return type void to setUp() and tearDown()
Bug: T192167
Depends-On: I581e54278ac5da3f4e399e33f2c7ad468bae6b43
Change-Id: I3a21fb55db76bac51afdd399cf40ed0760e4f343
2019-10-30 14:31:22 -07:00
Thiemo Kreuz
e4272518f7 tests: Replace PHPUnit's loose assertEquals(false) with assertFalse()
assertEquals( false, … ) still succeeds when the actual value is 0, null,
an empty string, even an empty array. All these should be reported as a
failure, I would argue.

Note this patch previously also touched assertSame( false ). I reverted
these. The only benefit would have been consistency within this codebase,
but there is no strict reason to prefer one over the other. assertFalse()
and assertSame( false ) are functionally identical.

Change-Id: Ic5f1c7d504e7249002d3184520012e03313137b4
2019-10-04 00:30:36 +00:00
Aryeh Gregor
8ec24b607a Introduce MovePageFactory
This will help make MovePage more testable.

In the course of abstracting the logic out of ParserFactoryTest to
FactoryArgTestTrait so it could be used in MovePageFactoryTest, I made
them all unit tests instead of integration. This required some
modification to the Parser constructor so that it didn't access
MediaWikiServices unnecessarily.

Change-Id: Idaa1633f32dfedfa37516bb9180cfcfbe7ca31aa
2019-08-19 20:25:31 +03:00
Amir Sarabadani
06f645c453 Load GlobalFunctions.php to tests/phpunit/bootstrap.php
That mostly enables testing global functions

Bug: T87781
Change-Id: Ib42c56a67926ebcdba53f4c6c54a5bff98cb77a3
2019-07-14 01:28:07 +02:00
Legoktm
4e35134f7a Revert "Separate MediaWiki unit and integration tests"
This reverts commit 0a2b996278.

Reason for revert: Broke postgres tests.

Change-Id: I27d8e0c807ad5f0748b9611a4f3df84cc213fbe1
2019-06-13 23:00:08 +00:00
Máté Szabó
0a2b996278 Separate MediaWiki unit and integration tests
This changeset implements T89432 and related tickets and is based on exploration
done at the Prague Hackathon. The goal is to identify tests in MediaWiki core
that can be run without having to install & configure MediaWiki and its dependencies,
and provide a way to execute these tests via the standard phpunit entry point,
allowing for faster development and integration with existing tooling like IDEs.

The initial set of tests that met these criteria were identified using the work Amir did in
I88822667693d9e00ac3d4639c87bc24e5083e5e8. These tests were then moved into a new subdirectory
under phpunit/ and organized into a separate test suite. The environment for this suite
is set up via a PHPUnit bootstrap file without a custom entry point.

You can execute these tests by running:
$ vendor/bin/phpunit -d memory_limit=512M -c tests/phpunit/unit-tests.xml

Bug: T89432
Bug: T87781
Bug: T84948
Change-Id: Iad01033a0548afd4d2a6f2c1ef6fcc9debf72c0d
2019-06-13 22:56:31 +02:00