Commit graph

826 commits

Author SHA1 Message Date
Umherirrender
fe48e1223a cache: Fix various scalar and null types to match documentation
Adding float as type when INF is used as argument

Found by phan strict checks

Change-Id: I7e19cd0d9b09bf685e4e8387c900f303b669ad54
2022-03-14 17:36:04 +00:00
jenkins-bot
0200221a93 Merge "Fix various documentation related to null types (part II)" 2022-03-09 22:42:42 +00:00
jenkins-bot
96393c492e Merge "Add various fallback values for null return values" 2022-03-09 22:32:29 +00:00
jenkins-bot
8f618cf551 Merge "Avoid use of null, bool or Status in log messages" 2022-03-09 22:15:20 +00:00
Umherirrender
19925ef026 Add various fallback values for null return values
Found by phan strict checks

Change-Id: I83187b5fd25b015d2c75e22d4b5202803653d743
2022-03-09 20:15:36 +01:00
Umherirrender
d7248d63fb Fix various documentation related to null types (part II)
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
2022-03-08 23:45:31 +00:00
Reedy
11cc2d6993 Consistently use @deprecated since rather @deprecated
Change-Id: I301786f35cd6eb9c63fb72e0b64cffa9efd7b86b
2022-03-06 02:55:54 +00:00
Umherirrender
58fdd4f8e3 Avoid use of null, bool or Status in log messages
Explicit convert to string

Found by phan strict checks

Change-Id: I843fe4c30b2f82ef3b98241e208b5d38002c0d07
2022-03-02 22:45:10 +00:00
Umherirrender
f9858b2863 MessageCache: Move LanguageConverterFactory call from wiring to constructor
This avoids mismatches between the language in the message cache and the
language converter used for content language.

Bug: T292239
Change-Id: I1f0ca70b184362a783d164658b3867e00a306591
2022-02-28 23:05:35 +00:00
Umherirrender
b126dbe3f2 Fix various documentation related to null types
The functions returning null or the class property is set explict null

Found by phan strict checks

Change-Id: I4a271093fb6526564d8083a08249c64cb21f2453
2022-02-26 10:31:24 +01:00
Reedy
86934b2fa8 Replace some more usages of Wikimedia\(suppress|restore)Warnings()
Change-Id: I2eb133a9e32116cd155f59086245bc4d15ecbfcc
2022-02-24 20:27:46 +00:00
jenkins-bot
6a85933fd7 Merge "Avoid references to DefaultSettings." 2022-02-22 23:47:25 +00:00
daniel
a5277ce87f Avoid references to DefaultSettings.
This replaces references to DefaultSettings with
references to config-schema.yaml where appropriate.

NOTE: this does not yet change Setup.php. DefaultSettings.php
remains intact and is still being used.

NOTE: this does not remove usages in the installer, see I5d8843a1062fbf
for that.

Bug: T300129
Change-Id: Ie6152cf510c3be61bc22167ca6d90dfc28910a45
2022-02-22 19:43:50 +01:00
Gergő Tisza
6a7bffaac2
LinkBatch::getPageIdentities(): Fix return type
LinkBatch::getPageIdentities() returns PageIdentityValues, which
are ProperPageIdentities. Indicate this in the return type
documentation to avoid phan complaints.

Change-Id: I461f2964aa9b4178d41e6071763e016b207c77d5
2022-02-19 10:09:57 -08:00
jenkins-bot
be029c5fa4 Merge "MessageCache: Avoid Undefined offset in normalizeKey()" 2022-02-04 17:52:15 +00:00
Timo Tijhof
067b07f4fc MessageCache: Avoid Undefined offset in normalizeKey()
It is quite rare that a notice like this is best fixed so close to
the caller. More often than not, low-level code like this doesn't
have a reasonable way to handle it and it's a genuine issue but one
that a higher-level should prevent instead.

In this case though it seems fair to handle here because an empty
string is actually, according to most l10n-related classes, a valid
message key. It can't exist, but it is a valid key.

See also MessageCache::get() which does not consider it an error and
similarly returns false. That method never calls normalizeKey with
an empty string though. The error came from ApiQueryAllMessages.

I don't think it should be ApiQueryAllMessages's concern to normalize
this key or otherwise hardcode its non-existence over there.

Bug: T300792
Change-Id: I8a8eed66704862bb3a645ef5941a5264e65bde4c
2022-02-04 03:37:36 +00:00
Tim Starling
ca71e69fc6 Try not to discard Excimer timeout exceptions
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
2022-02-02 16:27:44 +11:00
jenkins-bot
c0f7f43e75 Merge "Fix pollution of LinkBatch/LinkCache with interwiki link" 2022-01-31 19:03:19 +00:00
Tim Starling
16979ecf29 Fix pollution of LinkBatch/LinkCache with interwiki link
* In LinkBatch::addObj(), reject interwiki links with a warning.
  Otherwise the link is added to the batch by ns/title and later
  reconstructed as if it were a local link without an interwiki
  prefix.
* In CommentParser, treat interwiki links as always good, don't defer
  the existence check.
* In LinkBatch, inject a LoggerInstance instead of calling LoggerFactory
  in four places.
* Add a regression test, and some general tests for known links.

Bug: T300311
Change-Id: I0e5825eb48a6ba2932aea69a4d0fff3439c50ff5
2022-01-28 10:52:38 +11:00
Aaron Schulz
c433c15087 Convert various callers to LoadBalancer::getConnectionRef()
Bug: T193565
Change-Id: I2e2ef6a1d841c632d1f3e53ca3f82a720af15d47
2022-01-27 01:02:44 +00:00
Umherirrender
95852cb22b Explicit cast TS_UNIX to int for arithmetic operations and int args
When the called function has a doc of int, it should be cast to be
explicit here.
Also cast for arithmetic operations to be explicit about the number

Change-Id: I905b78dfb66e66443e0e3203488bab5b548db543
2022-01-11 20:13:13 +01:00
TChin
47adb6d65a Refactor global variables to use MediaWikiServices instead
Automatically refactors wg prefixed globals to use MediaWikiServices config using Rector. Doesn't include files that set globals or files that fail CI.

Rector Gist: https://gist.github.com/tchin25/7cc54f6d23aedef010b22e4dfbead228

* This patch uses a modified source code rector library for our specific use case and the rector will have different effects without it.

A writeup for future reference is here: https://meta.wikimedia.org/wiki/User:TChin_(WMF)/Using_Rector_On_MediaWiki

Change-Id: I1a691f01cd82e60bf41207d32501edb4b9835e37
2022-01-10 13:55:53 -05:00
Siddharth VP
b77dd0640c Fix typos in comments (M)
Change-Id: I5ab88a01ba3e5ea2aae853bb6f06492fbc84ceb5
2022-01-09 23:00:20 +05:30
Siddharth VP
b4b2a62040 Fix typos in comments (L)
Change-Id: I3deb34aec51504e09b20a367a93ebe863335be26
2022-01-09 22:54:04 +05:30
Kosta Harlan
891b51b258 Prefer is_dir/is_file to file_exists
Mirco-optimisation for performance, part II.

Change-Id: Ie8d5332a510bd18456ebc4a851f4d47f6a010dcb
2022-01-04 11:03:09 +01:00
Siddharth VP
061ee25f7e Fix typos in comments (E-H)
Change-Id: I0748e0d5962fa909fdd6b7fcae4ab259bde4cdf1
2021-12-30 18:14:43 +05:30
Amir Sarabadani
ec074a6a27 cache: Add four fields to LinkCache::getSelectFields
These are needed PageStoreRecord::REQUIRED_FIELDS and that's why putting
PageStore on top of LinkCache caused a lot of increase in db reads.

Bug: T297669
Change-Id: If77c2f9879d7bae71eb59944efd8b3798d16aa46
2021-12-14 15:10:49 +01:00
Thiemo Kreuz
b4c63c64ae Remove some more comments that literally repeat the code
Nothing to learn from these.

You can find a longer explanation in the comments in I93751e6.

Change-Id: I195aae70fc282b58be5b18160783f27d38605d15
2021-12-09 19:01:36 +01:00
Alexander Vorwerk
3aa5b6643b Use LanguageNameUtils constants instead of strings
Change-Id: I8521d00675008da0d7c8c768ab75352212653c66
2021-12-05 22:13:34 +01:00
Reedy
2a2bb1e9bd Remove or replace usages of "sane"
Bug: T254646
Change-Id: I096b2cf738a1395a14f1d47bcbed0c2c686c2581
2021-11-22 13:35:17 +00:00
Reedy
6e29611642 Remove or replace usages of "sanity"
Still some more to go...

Bug: T254646
Change-Id: Ia117f01e443c35b4765f3275cab4f2707e1be96f
2021-11-21 16:42:31 +00:00
jenkins-bot
ca45a3b28e Merge "Remove or replace usages of "sanity"" 2021-11-21 14:21:54 +00:00
Reedy
7bf779524a Remove or replace usages of "sanity"
Bug: T254646
Change-Id: I2b120f0b9c9e1dc1a6c216bfefa3f2463efe1001
2021-11-19 23:19:42 +00:00
Reedy
cbfd94c355 LinkBatch/LinkBatchFactory: Minor cleanup
Change-Id: Ieb9219383d343c37876566f9de98fe873b85b543
2021-11-19 18:26:52 +00:00
jenkins-bot
5729022456 Merge "Use ParserOptions::newFromContext in MessageCache" 2021-11-08 21:45:40 +00:00
Martin Urbanec
b406c52adb LinkCache: Try invalidating cache before throwing
The code that was previously in LinkCache::getGoodLinkRow
may return a cached row object (either from the in-process
cache, or memcached). In some cases, this caused
LinkCache::addGoodLinkObjFromRow to throw, because a field
was missing (although the field is missing only from
the cached copy, not from the database).

To avoid this, try to invalidate the cache
in LinkCache::getGoodLinkRow and retry, before
letting the exception propagate.

Bug: T205349
Change-Id: Ie9e90bf32964047c1831f575cc260d7d62e9e848
2021-11-02 13:10:45 +00:00
Umherirrender
43a1a61c1e Use ParserOptions::newFromContext in MessageCache
The context is already called, just reuse it.
This avoids unstub of $wgLang in ParserOptions constructor

Change-Id: I3ac6abf6237db7c1c09740c1fec1224779e86888
2021-10-27 00:10:36 +02:00
vladshapik
1ae8e89eb5 Hard deprecate LinkCache::addGoodLinkObj
LinkCache::addGoodLinkObj was hard deprecated.
Use addGoodLinkObjFromRow() instead. PHPUnit tests
must use LinkCacheTestTrait::addGoodLinkObject().

Bug: T284955
Change-Id: I0c22be2f00e6d6d4ba6dd1511c5385cad55e8ff7
2021-10-26 18:21:32 +03:00
Reedy
6c62b2164c s/necesssary/necessary/
Change-Id: I38e5ff8b5b84b0d96b9bbc3e168efe416016184b
2021-10-06 01:08:37 +01:00
TChin
fd5915823f Update callers of deprecated BacklinkCache methods
Bug: T290015
Change-Id: I73a111d064f7778bbeb90fd4ea85d8bec201427b
2021-09-29 18:56:17 +00:00
Umherirrender
769bdbf091 docs: Fix nullable documentation for class properties
Change-Id: I6d0577124d852103f485ffdc819876a13f6641c3
2021-09-24 00:54:53 +00:00
Alexander Vorwerk
d028567e4c Remove MessageCache::singleton()
deprecated since 1.34, hard deprecated since 1.37 and unused.

Bug: T249031
Change-Id: Iab7e0dda610b2e65624ede2a0bb419b0b9cc03d1
2021-09-15 18:13:37 +02:00
Alexander Vorwerk
0139a3b814 Remove LinkCache::singleton()
Deprecated since 1.28, hard deprecated since 1.37 and unused.

Bug: T249034
Change-Id: I224272e428f49db2498c30e6d12e2280fd580469
2021-09-15 18:05:34 +02:00
jenkins-bot
5a53d57449 Merge "LinkCache: soft deprecate addGoodLinkObj()" 2021-09-10 17:22:02 +00:00
jenkins-bot
7ece0e7afd Merge "Title: Make use of BacklinkCacheFactory service" 2021-09-10 14:31:23 +00:00
daniel
855988fd0e LinkCache: soft deprecate addGoodLinkObj()
addGoodLinkObj() has many optional arguments, but omitting them actually
means corrupting the cache.

Nearly all existing callers are in tests.
So LinkCacheTestTrait::addGoodLinkObject() was created only
for testing. It is better to have this method in the
trait, because building the row directly in each test
would make these tests brittle against schema changes.

The only usage in WMF production code was in WikiPage and has been
fixed.

Bug: T284955
Change-Id: I03a2bd9ed64fcc0281ee29a286c8db395a9e03d9
2021-09-10 16:00:02 +02:00
jenkins-bot
1efeefe017 Merge "PageStore: Use LinkCache" 2021-09-09 20:04:47 +00:00
Derick Alangi
db43511e6a Title: Make use of BacklinkCacheFactory service
Change-Id: I48161585de6f329ec4037156234e0b07b3b837e6
2021-09-09 14:04:02 +01:00
Derick Alangi
96bc83e8eb Add BacklinkCacheFactory Service
Bug: T279433
Change-Id: I2943935e2d8148fce4457f76eca0234be72a5a5a
2021-09-09 09:58:52 +01:00
Umherirrender
44fd53fee3 Using @return never documentation on always-throw-function
This helps phan to detect unreachable code and also impossible types
after the functions.
It helps phan to avoid false positives for array keys
when the keys are checked before

Bug: T240141
Change-Id: I895f70e82b3053a46cd44135b15437e6f82a07b2
2021-09-07 17:29:03 +02:00