The arg order of truncate_endBracket is tag, type, lastCh, tags, but the
type and lastCh are in wrong order. This is only relevant when $tag is
still non-empty after the loop, which is only happen for unclosed html
tags.
Found by phan strict checks
Change-Id: I08d6926dd4aac8ccc86c776f57a26437013ecb1d
php internal functions like floor/round/ceil documented to return
float, most cases the result is used as int, added casts
Found by phan strict checks
Change-Id: I92daeb0f7be8a0566fd9258f66ed3aced9a7b792
Rename Sanitizer::removeHTMLtags() into an @internal method named
::internalRemoveHtmlTags() so that we can deprecate external use.
Code search:
https://codesearch.wmcloud.org/deployed/?q=removeHTMLtags&i=nope&files=&excludeFiles=&repos=
Followup-To: Ic864c01471c292f11799c4fbdac4d7d30b8bc50f
Depends-On: Iaca83ed06e9c61d8366579cd2283cba653c82319
Depends-On: I1963bfe9a99198ea02ca482a5769467ce806cd58
Depends-On: I83923d8b38d33f3638cd53958dd10f257ec21f7c
Depends-On: I018b34bb5f6e113056da9b04cc72d4318422adce
Change-Id: I202826f8b27519f7be89643e24eda47a6e3fc9f6
As a result, when an existing Message object is passed in the $key
parameter, the function will return a clone of that object, rather
than a new Message constructed based on the key extracted from the
old message.
This is mostly relevant when the passed object is an instance of
a subclass like RawMessage or ApiMessage, but it could have other
unpredictable consequences. No test failures, though!
Change-Id: I4815e92dfaf5fbcc8c9356106738716c6b9ae0da
This affects messages created using wfMessageFallback() and related
functions, in particular many messages used for navigation tabs in
skins.
Previous attempt in 11d7d97768,
reverted in c83b530f95 due to T302469.
This attempt doesn't introduce any new placeholders to avoid that
issue.
Bug: T300069
Change-Id: Ib0e282b3864caf345e42dd7af4a529f43ae7ba67
Many Language methods can't be typehinted with Language as long as
$wgLang/StubUserLang are not completely removed (T160814)
Lack of explicit StubUserlang in the param type often make it
possible for the typehint to be reintroduced after it was removed,
as it happened in Iec1b562 and If72d054
Change-Id: I9b3e87baf38091e2de428de0c92c5a8a6fea32ea
Sometimes the method is called with a stub language object.
There are probably better ways to avoid that in the long-term
but for now this is a risk-free fix.
Change-Id: I29574c20d2963de826108e5ad9e7e22ec6571ebe
Use the object factory to inject service into TrivialLanguageConverter
class.
The other language converter classes does not use service directly.
The classes are using indirectly services in some function of
the parent class, which needs injection as well (tracked with T294185).
Needs fallback to global state in TrivialLanguageConverter, because the
class is used in extensions integration tests
Change-Id: If72d054d062a4f357e12c5b168e118bfafffd626
If all keys failed, instance of the last message key is returned, not first
Test: wfMessageFallback( 'x', 'y', 'z' )->text()
Change-Id: I115a626d5838240665d1f5044dbee1bac1dd5a37
This affects messages created using wfMessageFallback() and related
functions, in particular many messages used for navigation tabs in
skins.
Bug: T300069
Change-Id: Ia8ba35419285cfa77197810ae9df99e522a0f4ba
It turns out this gets rid of a bunch of suppressed
"SecurityCheck-DoubleEscaped" that appear to have been accurate
warnings.
There seems to have been some confusion about how ::truncateForVisual()
is supposed to be used; in particular it is to be passed *unescaped*
output, because it is not (generally speaking) safe to truncate
HTML-escaped strings. The goal of ::truncateForVisual() is to have
a specific number of codepoints in the output for display purposes,
the encoding of those codepoints is not an issue (htmlspecialchars
can be applied to the *return value*.) If you need a specific number
of *bytes* you should be using ::truncateForDatabase(). If you want
a certain number of *HTML bytes* then the ::truncateHtml() method
is probably what you want.
Slightly refactor some code in RevDelLogItem to avoid a false positive.
Bug: T301205
Bug: T290624
Change-Id: I893362e049aedfa699043fcf27caf4815196f748
Skin::getLanguages() was consuming 4% of index.php CPU time. In local
testing, it was called three times per page view. So:
* Memoize it, analogous to the nonfunctional code in SkinVector.
* Simplify ClassicInterwikiLookup by removing the option to pass a CDB
file path. This was only ever supported by a WikimediaMaintenance
script. In the unlikely event that someone is using this feature, they
have the same motivation to switch to PHP as we did in T122362.
* Increase the size of ClassicInterwikiLookup's MapCacheLRU from 100 to
1000. This helps greatly in the case when $wgInterwikiCache is false
and more than 100 interwikis are requested and seems harmless
otherwise.
* Optimise Title::getNsText() by assuming that the canonical name of
NS_MAIN is the empty string.
* Rearrange Message::__construct() to avoid duplicate type checks.
Change-Id: I736cb74efc267fd2473a3267471735238217251c
Don't catch and discard exceptions from the RequestTimeout library,
except when the exception is properly handled and the code seems to be
trying to wrap things up.
In most cases the exception is rethrown. Ideally it should instead be
done by narrowing the catch, and this was feasible in a few cases. But
sometimes the exception being caught is an instance of the base class
(notably DateTime::__construct()). Often Exception is the root of the
hierarchy of exceptions being thrown and so is the obvious catch-all.
Notes on specific callers:
* In the case of ResourceLoader::respond(), exceptions were caught for API
correctness, but processing continued. I added an outer try block for
timeout handling so that termination would be more prompt.
* In LCStoreCDB the Exception being caught was Cdb\Exception not
\Exception. I added an alias to avoid confusion.
* In ImageGallery I added a special exception class.
* In Message::__toString() the rationale for catching disappears
in PHP 7.4.0+, so I added a PHP version check.
* In PoolCounterRedis, let the shutdown function do its thing, but
rethrow the exception for logging.
Change-Id: I4c3770b9efc76a1ce42ed9f59329c36de04d657c
There is no need for deprecatePublicProperty, when later
deprecatePublicPropertyFallback gets called.
Change-Id: Ib24d1e1bdc729bef132d55234a2062892dd3cf59
Code of some language's parent language can't simply strip out the subcode.
e.g. ike-cans should get iu.
Change-Id: I4cf5bb1ddc463a8d98064451dd8e4dbebeca96e9
This allows the backend to do whatever it can to ensure atomicity, and
is also easier to read, since the intent is obvious.
Change-Id: Ibbfecd92a2c6d9a5997ca37ea101e068bd1e8202
* Added ParamType::OBJECT, which allows Stringable objects to be passed into MessageValue
Bug: T278482
Change-Id: Ib4990f87d4ad70b7525d7aa05c8b97e90c121674
The property was set, but never read. Use it similar to
mHeaderVariant/mURLVariant and return the value when set.
Originally introduced without caching (r60961, 81f62b6f61) but had no
clear explanation. The unclear comment was removed in I62bd09d7d0.
Change-Id: I863d77618c7f26686ae4de76024878655f516e04