The functions returning null or the class property is set explict null.
Some function should not accept null or return null.
Found by phan strict checks
Change-Id: Ie50f23249282cdb18caa332f562a3945a58d86ff
Some function already document "False on failure", but does not document
it on the used type
Found by phan strict checks
Change-Id: I12eb8bbc99179833ee3e42c1a7d1dc1443682ca6
This is split from I1d267ae, as well as a follow-up to Ie70d849.
Custom code like this exists because some messages do something
like {{#if: … | … | - }} to get dynamically disabled. This is not
something isDisabled() supports. That acts on the unparsed message
before any {{…}} was expaned.
The few cases in this patch are not affected because they use plain(),
which does not do any {{…}} expansion anyway.
Change-Id: I70541cf28c6fff14422e202f774b86086c2a850c
The methods Linker::tooltipAndAccesskeyAttribs, Linker::titleAttrib
and Linker::accesskey are not true static methods as they use classes
outside the ones passed in parameters. This blocks writing unit tests
in certain parts of the skin code, so these are now added as optional
parameters
Change-Id: I01e956084e8163f07afe2308d670d6efa3bea656
This makes the call to getImageLinkMTOParams consistent between thumbs
and not thumbs by now passing the parser in the former. The result
being that the nofollow relationship is now added for external thumb
links as well.
Linker::getImageLinkMTOParams sets the parser-extlink-target based on
the same getExternalLinkTarget call. This also makes it clearer when
parser-extlink-rel is modified by the target in getExternalLinkAttribs.
custom-target-link does have a higher precedence but it looks like this
was added in 1a4957e as a fallback to respect the global config so the
change seems fine.
A few parserTests cover this with the wgExternalLinkTarget config but a
case for thumbs with external links was added.
The phan annotations look like a false positive similar to
https://github.com/phan/phan/issues/3645
from the use of `$params[$type][$paramName] = $value;`
Change-Id: Icf887b13d046b0f610b1984d641f248d1dec5226
When a nonexistent message is requested, a WAN cache request results,
because nonexistent keys are suppressed in the main cache by
isMainCacheable(). There is some performance degradation when such
keys are requested on every page view.
So:
* Make it so that keys prefixed with accesskey-, tooltip- and nstab-
use Message::isDisabled() instead of Message::exists(), so that they
can be blank instead of missing by default.
* Add blank messages for several such keys.
Change-Id: Ie70d849a8ecbf9ab70e58f582b9ba89afe9f2829
In PHP 8.1 the default $flags argument to htmlspecialchars() has changed
from ENT_COMPAT to ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401. This
breaks some tests.
I changed all the calls that break unit tests, and some others
based on a quick code review. A lot of callers just use the default for
convenience, and were already over-quoting, so the default should still
be good enough for them.
Change-Id: Ie9fbeae6f0417c6cf29dceaf429243a135f9fecb
When revisions have the same timestamp the rollback could be confused
about the order of both revisions.
Add additional order by rev_id as used in
RevisionStore::getRelativeRevision to fix this situation
mysql is ordering by the primary key in case of same values of an index,
using the same order, but postgres fails in this situation.
Bug: T195807
Bug: T218400
Change-Id: Id40f8351992de0fb747f09821de4e8463c8986d2
Linker::getRollbackEditCount can return 0 on replica lag
In this code the function does not return false or null, because
- false only when $verify is set (which is false here)
- null only when $wgShowRollbackEditCount is not set, but that is
already checked
Bug: T89780
Change-Id: I2d8108b1be5d25c33a68c40731a127deb3f45819
Follow up to the FIXME added in I6d03037af1b5c90e6d57fd048506da2b4e4bc704
The output isn't great but at least it matches Parsoid's.
Change-Id: I5660b8ccdb8bd0c89b94669a1c6ab260d57183df
This is spec'd out at https://www.mediawiki.org/wiki/Specs/HTML#Media
It's also useful in the bug to determine when the link is pointing at
the resource, and hence MediaViewer should open.
Previously that was distinguished with .image class on the link but
that's now omitted in getDescLinkAttribs.
FIXME: Should the "resource" contain querystrings? Maybe this needs to
be done on the Parsoid side as well.
Bug: T292657
Depends-On: Idb60e418f79dcb6a121de2a11e6e0ed0b31fd3ff
Change-Id: Ia94138383ebdbfc2feef75fdf651b969085a72b1
* Magnify clip isn't present in print styling
* Print and screen thumbborder are different
* Print thumbinner and thumbimage borders are absent
Bug: T287965
Change-Id: Ie1dac57412da7da3e73eb39ef20a6077923860d6
Change documentation to null or false where the type is allowed
Also use int on Linker::tocLine, because an int is passed most
Change-Id: I9591ac91586aa9a28f38f80e0ab576b66b303d8d
* Do not store table of contents in parser output
* Instead inject table of contents via strpos where needed
inside Article based on Skin "toc" option
* Use <mw:tocplace> as a TOC placeholder; for Parsoid compatibility
this will be replaced with a <meta> tag in a followup patch.
Bug: T287767
Change-Id: I44045b3b9e78e7ab793da3f37e3c0dbc91cd7d39
CommentParser:
* Move comment formatting backend from Linker to a CommentParser service.
Allow link existence and file existence to be batched.
* Rename $local to $samePage since I think that is clearer.
* Rename $title to $selfLinkTarget since it was unclear what the title
was used for.
* Rename the "autocomment" concept to "section link" in public
interfaces, although the old term remains in CSS classes.
* Keep unsafe HTML pass-through in separate "unsafe" methods, for easier
static analysis and code review.
CommentFormatter:
* Add CommentFormatter and RowCommentFormatter services as a usable
frontend for comment batches, and to replace the Linker static methods.
* Provide fluent and parametric interfaces.
Linker:
* Remove Linker::makeCommentLink() without deprecation -- nothing calls
it and it is obviously an internal helper.
* Soft-deprecate Linker methods formatComment(), formatLinksInComment(),
commentBlock() and revComment().
Caller migration:
* CommentFormatter single: Linker, RollbackAction, ApiComparePages,
ApiParse
* CommentFormatter parametric batch: ImageHistoryPseudoPager
* CommentFormatter fluent batch: ApiQueryFilearchive
* RowCommentFormatter sequential: History feed, BlocklistPager,
ProtectedPagesPager, ApiQueryProtectedTitles
* RowCommentFormatter with index: ChangesFeed, ChangesList,
ApiQueryDeletedrevs, ApiQueryLogEvents, ApiQueryRecentChanges
* RevisionCommentBatch: HistoryPager, ContribsPager
Bug: T285917
Change-Id: Ia3fd50a4a13138ba5003d884962da24746d562d0
The non-strict conditions in if/while are true/false without the check.
In some situation the true/false is removed, because it is known to be a
bool (by is_bool check or type hint)
Change-Id: I5ca4c4771af25d2e785e82732df204a73653886e
This module provides styling for span.comment, produced by
Linker::commentBlock, which EditPage calls when generating the
HTML for the edit summary.
Add a notice for that to Linker::commentBlock, like was done
in ddbf011257, and update the
comment in the stylesheet.
Bug: T288907
Change-Id: I3d929eaae54754bd3e41a9add419f1098a7f8e3a
Introduced in 2008, and would involve a lot of unnecessary complexity
and potential software confusion, so revising comment to explain
the constraint that access key cannot be a "-" character.
Bug: T284139
Change-Id: I25f5b1943c58f76df9e3a7830d0d4c377494b280
Gated behind the flag $wgParserEnableLegacyMediaDOM. The scattershot
usage of it is a little unfortunate but isn't expected to live very long
so maybe that's acceptable.
Further details can be found at,
https://www.mediawiki.org/wiki/Parsing/Media_structure
Bug: T51097
Bug: T266148
Bug: T271129
Change-Id: I978187f9f6e9e0a105521ab3e26821e36a96b911
… including PHPDoc tags like `@return <type> $variableName`.
A return value doesn't have a variable name. I can see that
some people do this intentionally, repeating the variable
name that was used in the final `return $var;` at the end
of a method. This can indeed be helpful. I leave a lot of
these untouched and removed them only when it's obviously
wrong, or does not provide any additional information in
addition to what the code already says.
Change-Id: Ia18cd9f25ef658b08ad25b97a744897e2a8deffc
This also tries to centralize adding logic of adding history-deleted
class as well. To make future changes easier.
This doesn't affect history deletion on files, recentchanges, and logs yet
Bug: T23272
Change-Id: I08f14f712479e1b170c606e2b64857f8386acd76
This module is used almost everywhere these elements are found.
Methods in Linker that produce these elements list that this module
is required for proper styling.
Where possible, the module is added to retain the styles.
Bug: T278576
Change-Id: I7dedebd3bce3b4aec127738edc81b180325f0836
User::getBoolOption() is deprecated and should be replaced with UserOptionsLookup::getBoolOption()
Bug: T277600
Change-Id: Ife3c721237258d50852bbf764def74657cc70428
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.
Created by I25a17fb22b6b669e817317a0f45051ae9c608208
Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
Html::element is more lenient about which characters it escapes.
But really this is just factored out of the next patch for ease of
review.
Change-Id: I9abb4d866a624df7bf4628ab9cc581967e715160