Syntactical leftover with no significance in modern web.
Bug: T309150
Depends-On: I3a029ca950db42b938962b2452ad136ae8ddea6f
Depends-On: Id0557ac19583de36d7226b14a4c06933da47fe97
Depends-On: I17580a72e4a9384d7d774866e610197e950900cb
Change-Id: I4bbfa47fbf6e30fb90d920d6d02cdf6e0b1cdb46
Rather than suppress the TOCData in ParserOutput when __NOTOC__ is used,
set a new parser output flag, NO_TOC, since some clients want to know
whether there are sections present on the page irrespective of whether
the UX for the Table Of Contents should be displayed/suppressed.
Added OutputPage::getOutputFlag() as an @internal method for the
moment; eventually we should use the same object to represent
metadata in ParserOutput and OutputPage (T301020).
Bug: T332243
Followup-To: Ife2126ace95ac4d9ec44f6374c63d8fc995cf034
Followup-To: Iea6426336f93c053a5977768f0785cdb46daf5bf
Change-Id: Ib41e6e4926cb752826ad75d10e8692125fc0b064
* 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
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
This fix is for the behavior of language variants, including:
* Fix the language variant behavior in meta alternate hreflang URLs.
meta alternate URLs should point to respective canonical URLs.
meta alternate URLs should be kept even in current page view language
* Make meta canonical URL language-variant-aware.
This only take effect when there's variant or uselang specified in
URL, so it doesn't affect variant-non-specified (variant-auto-
detected) URLs.
See `LanguageConverter::getURLVariant()` .
Bug: T54429
Bug: T108443
Bug: T305540
Change-Id: I5e6c8c3f7671d27aecdb52be271b34ba524fadf7
Co-Authored-by: Func <Funcer@outlook.com>
Co-Authored-by: Jdlrobson <jrobson@wikimedia.org>
Split this into multiple functions with multiple concerns for
easier maintenance and code review.
Bug: T330777
Change-Id: I80d93ec09be2df5c8b94a16140ba11da4827a42d
We'd lose more useful coverage and spend more effort keeping these
accurate through refactors etc than is worth the theoretically "bad"
accidental coverage. Plus, even then we still very often forget to
update these and waste time digging into seemingly uncovered code
and either write duplicate test or discover they are already covered.
Especially for private methods this can be a flawed endavour as
we tend to trust tests when changing those and thus feel we shouldn't
update tests, except it's riddled with private method mentions for
coverage purposes (not in terms of actual called code).
I think the best practice is to write good narrow unit tests,
not to write bad tests and then hide their coverage. Generally
that's what we do. Maybe these are useful when invoking a huge
legacy class, but generally we don't need these I think, at least
in the libs our team maintains.
Change-Id: I4c7d826c7ec654b9efa20778c46c498784661f1c
Having pig-latin enabled per default in dev environments is convenient
for manual testing. More importantly, it will allow us to write
end-to-end tests for variant conversion.
Depends-On: I9dc2f743ac487b0f7cfb667150c0f6950d5e7fce
Depends-On: I85b66c85be3959d48a048733af17197bc4cf70af
Change-Id: Ia80ad33cbf5e311fa8b84bd765a8df8d156f4c38
The class change in 76d1135 which triggered this test failure sounds
like a valid good practice, and the test should not assume no other
body class is set.
Bug: T321021
Change-Id: Iaee1881f37b3e24a89b3c1f1b05a19c6260184aa
And also assertNotRegExp -> assertDoesNotMatchRegularExpression. The
methods were renamed in PHPUnit 9.
Done automatically with:
grep -rl assertRegExp tests/ | xargs sed -r -i "s/>assertRegExp\(/>assertMatchesRegularExpression\(/"
grep -rl assertNotRegExp tests/ | xargs sed -r -i "s/>assertNotRegExp\(/>assertDoesNotMatchRegularExpression\(/"
Split out from Ifdba0f9e98eb6bce4590b7eb73170c51a697d7c6 so that it
remains smaller and easier to review.
Also make a test use MediaWikiUnitTestCase (it's already in the unit/
dir) so that it can access the forward-compat method.
Bug: T243600
Change-Id: Ifa279d5f201d7abeebece292141ebface8278046
Varnish is unable to cache these currently. However since pages with an
invalid title will never have any variable/editable content, we can
cache them unconditionally.
Also, undeprecate OutputPage::enableClientCache for this since it
is clearly useful here, but the parameter is being removed since
OutputPage::disableClientCache should be used to disable client side
caching instead.
Bug: T316932
Change-Id: Ib98fd165bffd9ca3dcbbcb8c6f06964dba7c90b7
Also, make use of MainConfigNames constants where necessary like in
HashConfig map.
NOTE: Since `wgConf` is not a setting, keep using `setMwGlobals()`
in this case.
Change-Id: I8d0c718fd02043835fe122d675cce3d759b30330
Parser output flags are intended to be "set only". That means that
extensions can *set* the SHOW_TOC flag, but once set SHOW_TOC can't be
reset, and the TOC will be shown in the result if *any* of the merged
ParserOutputs on the OutputPage contain the SHOW_TOC flag set. That's
consistent with prior merge behavior.
There's a possibility extensions are playing other games with the
Table Of Contents (TOC) in the OutputPageParserOutput hook; be
compatible with prior behavior for now but we may need to provide
additional functionality (perhaps a way to merge new section data) if
needed.
Bug: T310083
Change-Id: I0909ac85c6c785d9089b077a16923c61d6a09996
The files in `tests/phpunit/includes/` directory are now all
covered. Will do sub-directories of `/includes/` next.
Change-Id: I8d5655ce267b6d32cf3c7ee40dc5d2992631b5a6
Currently, the hreflang Tags' alternate URLs are not fully-qualified,
resulting these tags useless in SEO stand point.
This change makes sure hreflang Tags' alternate URLs are fully-qualified,
with testcase coverage.
Bug: T294716
Change-Id: I1dd3453c44f5c80adfbd7309860563d3bb9a7f86
Alternative to having this in the skin, is to do it for each separate
indicator. A counter argument against this was inline vs block mode
elements, specifically the reason why we stripped the p element. But
the p element has a margin in each and every skin. It's rather
unlikely that div's have such a standard layout. The wrapping div
around each indicator at the skin level is already inline-block, so
interactions between the indicators are already decoupled via that
skin element.
In this patch the wrapping is done in OutputPage when a ParserOutput
is added. OutputPage::addHelpLink() also adds indicators, which would
not be wrapped by this patch; this is reasonable since the content of
::addHelpLink() is not parsed wikitext. It's possible external users
may also call OutputPage::setIndicators() directly, which would also
add unwrapped indicators; the caller of OutputPage::setIndicators() is
responsible for wrapping any indicators which might come from parsed
wikitext.
Bug: T188443
Co-Authored-By: C. Scott Ananian <cananian@wikimedia.org>
Change-Id: I42be893101f7d7887480fe635143bea535ee5634
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader itself.
Move the tests by analogy.
I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".
I did not address DependencyStore which continues to have a non-standard
location and namespace.
Revert of a241d83e0a.
Bug: T308718
Change-Id: Id08a220e1d6085e2b33f3f6c9d0e3935a4204659
This reverts commit e08ea8ccb9.
Reason for revert: Breaks Phan in extensions, and as far as I’m aware,
this change isn’t urgently needed for anything, so the simplest fix is
to revert it again for now. After PHP 7.4 it should be safer to try this
again (we hopefully won’t need the two “hack” classes by then).
Bug: T308443
Change-Id: Iff3318cbf97a67f821f78e60da62a583f63e389e
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader and
ResourceLoaderContext.
Move the tests by analogy.
I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".
I did not address DependencyStore which continues to have a non-standard
location and namespace.
Change-Id: I92998ae6a82e0b935c13e02a183e7c324fa410a3
Logo variant override is available for 'wordmark' and 'tagline' in
the new Vector skin and has been used for a while, but the 'logo'
feature built in the core didn't take variants into account.
The logic should be pushed down to ResourceLoaderSkinModule so that
behavior can be consistent between skins and core.
Also, old code use $title->getPageViewLanguage() to determine the
variant of logo, which is a wrong behavior. Logos should be in the
interface language instead of the content variant.
Bug: T273578
Change-Id: Ifb3cc45600d57cf9c72757016148684cd7ab1400
- Add private var, helper methods to format and set robots options.
- Add reference to new method in OutputPage::getHeadLinksArray().
Bug: T301584
Change-Id: I2652f20c9fe5f2d3e28e329d4eddc2a2ff88cf76
Application logic should use the BaseDirectory config variable.
Framework code should use MW_INSTALL_PATH to locate files should.
NOTE: Update https://www.mediawiki.org/wiki/Manual:$IP
Bug: T300301
Depends-On: I7142af16d692f26e90673b058029f572c1ea3991
Change-Id: Ib4caa80bb7007c4c7960a2fd370cf5da7d9ba344
Fake time is automatically reset by MediaWikiTestCaseTrait
after each test. Individual tests need not duplicate that.
Change-Id: I926bf21d915208ea33ae0be2ef00eeba0160c9c8
Follows-up I361fde0de7f4406bce6ed075ed397effa5be3359.
Per T253461, not mass-changing source code, but the use of the native
error silencing operator (@) is especially useful in tests because:
1. It requires any/all statements to be explicitly marked. The
suppressWarnings/restoreWarnings sections encourage developers to
be "lazy" and thus encapsulate more than needed if there are multiple
ones near each other, which would ignore potentially important
warnings in a test case, which is generally exactly the time when
it is really useful to get warnings etc.
2. It avoids leaking state, for example in LBFactoryTest the
assertFalse call would throw a PHPUnit assertion error (not meant
to be caught by the local catch), and thus won't reach
AtEase::restoreWarnings. This then causes later code to end up
in a mismatching state and creates a confusing error_reporting
state.
See .phpcs.xml, where the at operator is allowed for all test code.
Change-Id: I68d1725d685e0a7586468bc9de6dc29ceea31b8a
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