-> Fixed TODOs such as adding test cases for namespaces that are
not in `$wgNamespacesWithSubpages` in `testGetSubpageText()`.
-> Re-arranged provider methods to come before the test case as
already in the files for consistency.
Change-Id: Ice2b3a07ea2ddd20417cbe87da93065e1812619e
The behavior of getCascadeStrictionSources was changed by Ia73ea587586cb69eb5
to conform to the documented behavior: it would always return false as the
first element of the return value if there were no cascading restriction sources,
as specified in the documentation.
Hopwever, the previous behavior was to return an empty array in that
case, unless the $getPages parameter was false. That behavior seems more
senible, and there is existing code that relies on it.
This patch restores the previous behavior and updates the documentation
instead.
Bug: T218395
Needed-By: I31ca0a8987f9694bc3b312a48c2c111ceda6fa3e
Change-Id: I1f24703b80566220ac6fe8ee500e838ed7fd29af
The methods that have been covered in this patch are listed below:
~ Title::hasFragment()
~ Title::getFragment()
~ Title::setFragment()
~ Title::isMainPage()
~ Title::equals()
~ Title::getPrefixedURL()
~ Title::prefix()
~ Title::__toString()
~ Title::getFullText()
Bug: T241406
Change-Id: I51ffadb52e7eef822e9e619e5132513dc1501f9b
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
This allows checking restrictions without a dependency on Title, based
only on a PageIdentity.
Additional fixes along the way:
* Correctly return false instead of 'infinity' for
getRestrictionExpiry( 'create' ) on an existing page
* Correctly handle non-special pages that can't exist (like media pages)
in listApplicableRestrictionTypes() (return empty array instead of
'create')
* Improve readability of isProtected()
The expectation change in TitleTest::testIsProtected() is because the
test was formerly broken, since it set mRestrictions without setting
mRestrictionsLoaded. (Which illustrates how this approach to testing is
essentially broken.)
Co-authored-by: Vedmaka <god.vedmaka@gmail.com>
Bug: T218395
Change-Id: Ia73ea587586cb69eb53265b2f8f7a296a2573dd0
Changes from patch set Icb93c79f4843b59dae80d3eda1a880457a1a68f2
Also some swaps from assertEquals to assertSame/True/False/Null
Change-Id: Ife497ae6cb1888b77eb25e85b76df72adc65641a
Tests for the following methods don't need integration:
- legalChars()
- convertByteClassToUnicodeClass()
- newFromTitleValue()
- newFromLinkTarget()
- castFromLinkTarget()
Change-Id: I2ec6505088c74a90da9d0b8305ce94d81cc0562a
Results in passing a user where previously the fallback
to $wgUser was being used, mostly in tests.
Bug: T255507
Change-Id: Iabe24315b23c0ad1272353186425e71974528d23
Replacing the mock InterwikiLookup used in
MediaWikiTitleCodecTest revealed that that test was,
because of the mock not behaving correctly, testing the
wrong thing - interwiki prefixes are *not* case sensitive,
and are always converted to lowercase in the actual
ClassicInterwikiLookup. Fixed those expectations.
Change-Id: I242431e88860b7700a9f93f77a0fe195fd748800
It is not entirely meaningless. It might be an indicator that
the number of calls to a method is intentionally unlimited.
This is similar to e.g. an @inheritDoc PHPDoc comment that
marks a method as being "intentionally undocumented".
However, what's the meaning of being "intentionally
unconstrained"? Let's just not have any constraint then.
I feel all these ->expects( $this->any() ) bloat the test
code so much that it's never worth it.
Change-Id: I9925e7706bd03e1666f6eb0b284cb42b0dd3be23
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
Code that needs to store an actor ID in the database to
represent a UserIdentity, or needs to construct a UserIdentity based on
an actor ID loaded from the database, should use the ActorNormalization
service.
Note: The getActorId() method is removed from the UserIdentity interface,
but all concrete classes continue to support it for now.
UsererIdentityValue::getActorId() is hard deprecated and should
be removed in 1.37. It always returns 0.
User::getActorId() is not deprecated at this point.
Bug: T274179
Depends-On: Id2b3ddf6a2a7cdf90f8936a69148d2cce6fde237
Change-Id: I9925906d11e47efaec3c1f48d5cb3f9896a982c1
We can't really watch invalid titles, since they
definitely can not exist in the database, so having
them in user watchlist doesn't make much sence either.
Bug: T278735
Change-Id: I411ca9227da8050d026a57db690824afd3423a89
Bad redirects in the database led to fatal errors when attempting to
resolve the redirect when visiting the page. This patch does three
things to address this:
* change Title::isValidRedirectTarget to actually check whether the
target is a valid title.
* change WikiPage::recorddRedirectEntry to reject invalid redirect
targets
* change WikiPage::getRedirectURL to ignore invalid redirect target
that may be present in the database.
Bug: T278367
Change-Id: Ib17ebfb99fa17b846302438c675a968a1ec0f488
This patch hard-deprecates the following methods,
that are overdue for hard deprecation:
- ::getPreviousRevisionID
- ::getNextRevisionID
- ::getFirstRevision
- ::getEarliestRevTime
Also, it removes the following methods:
- ::countRevisionsBetween
- ::getAuthorsBetween
Bug: T274151
Change-Id: If022b907652efdad84180476649a612059c6ef18
This reverts commit 36f1adf670.
This has seemingly broken FlaggedRevs and thus a bunch of repos.
Bug: T272170
Change-Id: I26c6fd656c75a6b209fb17965dc9109edf68642b
This allows Title and WikiPage objects to be compared with PageIdentity
and LinkTarget instances consistently.
Change-Id: I1bbd15d17d046359393ecfc1acd2778273260a95
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
* parent::setUp() should be first, and ::tearDown()
should be last
* Move tests that directly extend PHPUnit\Framework\TestCase
to /unit
Change-Id: I1172855c58f4f52a8f624e6d596ec43beb8c93ff
The InterwikiLoadPrefix hook isn't compatible with Parsoid, as it is
unidirectional and doesn't support enumerating all valid prefixes
(T270444). Set/reset $wgInterwikiCache to mock the interwiki table
for parserTests and other unit tests instead.
This is a soft deprecation, as the used-in-production
Extension:Interwiki still uses InterwikiLoadPrefix, although not in a
way that would break Parsoid (since $wgInterwikiCache is set in
production).
Bug: T270444
Change-Id: If2507017c99c4ee42c104a0890bc45a84d7239d5
Title::userCan, ::quickUserCan, and ::getUserPermissionsErrors, hard deprecated in 1.35
Bug: T246138
Change-Id: Iee990a16c15bd827cf631fb5ff683367082d2ebe
This helper method was introduced in I3d8c6f6. I found this bug while
working on I0a5be39. The method was cutting off strings like "/subpage"
into "ubpage".
I made sure no existing test case changed, as you can see.
I also tried to document the basic idea:
The first character can never be a subpage divider, even if it is a
slash, because this would result in an empty base. The code tries to
skip initial slashes and use the first non-empty substring as the base.
However, if there is nothing but slashes, the worst-case fallback is
to use the first slash as if it is the base.
I think there are still 2 different ways to split the following
edge-cases:
* "//foo" could become:
a) base "/" + divider + subpage "foo", or
b) base "//foo" with NO subpage.
* "//" could become:
a) base "/" + divider + empty subpage, or
b) base "//" with NO subpage.
Personally, I would pick b). But there was a test case already that
forced me to stick to a).
Bug: T229443
Change-Id: I4914b57c81ce6c7fdf10746f0da902c65f0ac2c9
This is for consistency with the previous behaviour.
Follow-up: I3d8c6f6ffc4234ac938a39f5cc55691d62e1d7ac
Bug: T256922
Change-Id: I0928f85c862d3b2baf49317a206ca140a1ab3c16
The name change happened some time ago, and I think its
about time to start using the name name!
(Done with a find and replace)
My personal motivation for doing this is that I have started
trying out vscode as an IDE for mediawiki development, and
right now it doesn't appear to handle php aliases very well
or at all.
Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
This ensures that getBaseText and getRootText always
return a valid title, even for degenerate cases like "/" or
"//foo//bar//baz//".
Bug: T229443
Change-Id: I3d8c6f6ffc4234ac938a39f5cc55691d62e1d7ac