Commit graph

146 commits

Author SHA1 Message Date
Thiemo Kreuz
69242b0876 Various updates and fixes to PHPDoc documentation
Some minor updates I collected in my local dev environment the
past months.

Change-Id: I30d5339bc262d54ba76e2860a3a3e9e5f002fdc3
2021-08-09 09:26:23 +02:00
jenkins-bot
493299e768 Merge "Make following redirects in MediaWikiPageNameNormalizer optional" 2021-07-27 20:44:22 +00:00
Amir Sarabadani
1d85adbf2b Make following redirects in MediaWikiPageNameNormalizer optional
If you want to normalize a page title without following the redirect,
you basically have to re-invent the wheel. Let's DRY it this way.

Bug: T278962
Change-Id: I61080ff0f35199784f4629f61272fb27bac787aa
2021-07-27 04:48:03 +00:00
Thiemo Kreuz
2ba01c7ee7 Remove some more comments that literally repeat the code
… 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
2021-06-18 21:23:56 +00:00
Petr Pchelko
0dfa846653 Use null coalecing operators everywhere consistenctly.
Auto-generated with rector.

Change-Id: I4f27e10cf029bb067b7bc57d82f7a64e21ea8d42
2021-06-03 21:42:06 -07:00
James D. Forrester
df5eb22f83 Replace uses of DB_MASTER with DB_PRIMARY
Just an auto-replace from codesniffer for now.

Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
2021-04-29 09:24:31 -07:00
jenkins-bot
5ea464b234 Merge "Use static closures where safe to use" 2021-02-14 23:05:48 +00:00
Umherirrender
8de3b7d324 Use static closures where safe to use
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
2021-02-11 00:13:52 +00:00
Thiemo Kreuz
947a8cfc00 Use ?? instead of isset/array_key_exists where possible
This patch touches all uncontroversial (I hope) places where a chain
of isset(), array_key_exist() and the ternary ?: operator can be
replaced with the much shorter ?? feature from PHP 7.

?? does the same. It checks if the element before the ?? is set and
not null. When this check fails, the element after the ?? is used.

Change-Id: Id612e2782ae928164b26b6f0de676c6c7d8302f3
2021-02-10 20:32:25 +01:00
Reedy
256e6ff0d9 Revert "Wrap libxml_disable_entity_loader() calls in version constraint"
This reverts commit a4c69bde13.

Reason for revert: Needs a bit more thinking about

Bug: T268847
Change-Id: I82a7bb2a4ef15adc65717d5ba173c8f3cfb0644c
2021-01-27 16:06:38 +00:00
Reedy
a4c69bde13 Wrap libxml_disable_entity_loader() calls in version constraint
Bug: T268847
Change-Id: I56684ce7b39aaebe1ae76811b833bc9183bc359b
2021-01-27 00:42:31 +00:00
Reedy
64ea1577e3 Explicitly wrap some XML calls in libxml_disable_entity_loader()
As per https://www.php.net/manual/en/function.libxml-disable-entity-loader.php
this is technically unnecessary.

>However, as of libxml 2.9.0 entity substitution is disabled by default,
>so there is no need to disable the loading of external entities.

See also https://github.com/php/php-src/pull/5867

>Since the release of libxml 2.9.0 in 2012 external entity loading is
>disabled in libxml by default. This means that using
>libxml_disable_entity_loader() is no longer needed.

Hopefully helps prevent false positive reports from security scanning tools.

Change-Id: I8a09d62a9920fd0bf4a388baa5544a02323bb541
2020-09-20 15:57:14 +00:00
Reedy
c50ba9b190 Fix more PSR12.Properties.ConstantVisibility.NotFound
Change-Id: I0ccda3d1de29b1044f74ef0972949eb8fbcb707d
2020-05-15 00:32:23 +01:00
Itamar Givon
f83f567462 Add flag to force local page name normalization in development env
Change-Id: I5138f6043effab813aacb7b0b408428d3e21d23d
2020-02-18 17:00:20 +01:00
DannyS712
2e3bdb3498 Miscellaneous documentation updates
Update references from .txt to .md when files have moved, a few other
tweaks, no changes to code.

Change-Id: I0bfd38c47b9fb0fc11ae98a0a674af66fb4c5a84
2020-02-16 04:38:38 +00:00
Petr Pchelko
204fa7e509 Remove usages of deprecated Language methods
Change-Id: Iad3375b141b1d87c890baec6ecd16ed92f93e699
2020-02-16 00:45:48 +00:00
DannyS712
f6417508c2 Remove FileBasedSiteLookup class, deprecated and unused
Bug: T241356
Change-Id: I252904b6b4c31a0ac42cbfbe7875a23c727150c1
2020-01-03 23:59:16 +00:00
jenkins-bot
ab61a9b2f4 Merge "site: Make getPageUrl consistently return null" 2019-09-23 16:36:32 +00:00
Umherirrender
268346e562 phan: Enable PhanTypeMismatchArgument issue
Bug: T231636
Depends-On: I5de4f8f32a47c3f41c990ffe2ebd091fc23d1a58
Change-Id: I34d65fe3ff1916f2af675f0b1f19641b0cdfadc0
2019-09-19 20:11:42 +02:00
Daimona Eaytoy
67f8131534 site: Make getPageUrl consistently return null
This was pointed out in Ia8443e575c22f47a6d8c63038f4e7ac36815fc27. The
method checks if $url is false, but that's never the case because
getLinkPath returns string|null.

Change-Id: I7850bff928f861d796879301ba0b4e575919407e
2019-09-17 12:20:50 +02:00
Daimona Eaytoy
dddc912fd6 Update docblocks for methods potentially returning null
These were discovered by setting `null_casts_as_any_type` to true in
phan, and filtering by `PhanTypeMismatchReturnNullable`. Of course there
are others, some of which are false positives, but we cannot suppress
them now (or the UnusedSuppressionPlugin will complain).

Change-Id: Ia8443e575c22f47a6d8c63038f4e7ac36815fc27
2019-09-15 15:22:39 +00:00
Daimona Eaytoy
5eac6d131c Unsuppress more phan issues (part 3)
Bug: T231636
Depends-On: I78354bf5f0c831108c8f606e50c87cf6bc00d8bd
Change-Id: I58e67c2b38389df874438deada4239510d21654f
2019-08-31 16:38:55 +00:00
Aaron Schulz
f72ae0f6e6 Switch various LoadBalancer::getConnection() callers to getConnectionRef()
This is the preferred method as it enforces read-only mode for DB_REPLICA
and handles LoadBalancer::reuseConnection() calls automatically.

Change-Id: Iab9439ba8e0810fa14c302661ed7a3534f6bfc0d
2019-07-12 10:56:30 -07:00
Umherirrender
f4a3ff1b76 Fix types around ILoadBalancer and IResultWrapper
Change-Id: I08531ccc6db046114f3535cfe6c108936dfff0d0
2019-07-04 21:56:31 +02:00
Timo Tijhof
4677392718 Remove wgSitesCacheFile and rebuildSitesCache.php (unused)
This seems to have been intended as optimization for SiteStore,
but was never used as far as I can tell. Instead, SiteStore is
already cached via LocalServerCache (APC).

Keep the FileBasedSiteLookup class for one release cycle in case
third parties not indexed by MediaWiki Codesearch are using it.

== History

* 2013: Report of high memcached usage by Wikibase via SiteStore.
* 2014: Lazy-load the data in Wikibase (d3f2e99cb6).
* 2014: Implement the file-based cache (via T47532 and 90f6efc360).
* 2015: Use local-server cache (APC), per T58602.

The file-based code was never used. The related task marked
invalid (T47532).

Change-Id: I8e2d9edcf3880149f824cc3de37793ca57435b49
2019-03-15 20:03:44 +00:00
Fomafix
43b03675d7 Site: Explicit allow setLanguageCode( null )
$site->setLanguageCode( null ) is already used in
DBSiteStore::loadSites and this worked because
Language::isValidCode( null ) === true.

This change explicit check for null and allow to set null without
depending on Language::isValidCode( null ) === true.

Change-Id: I0c9fe03cbf1434b0340e61e96360c0aaeb0fe89d
2019-03-12 10:36:52 +01:00
James D. Forrester
edba8aaf5a Drop SiteSQLStore, deprecated in 1.27, unused
Change-Id: I6743417c3aafbba59ac02350e0190fbf688a5a40
2019-02-08 17:43:33 -08:00
Max Semenik
fa432176d1 Hard deprecated SiteSQLStore::newInstance()
Deprecated in 1.27, no callers.

Change-Id: Ia262790cc6804b29fee656d0f53be1374bf04c2f
2018-12-08 22:12:33 -08:00
Fomafix
43244db9a2 Use PHP 7 '??' operator instead of if-then-else
Change-Id: If9d4be5d88c8927f63cbb84dfc8181baf62ea3eb
2018-10-21 21:46:46 +02:00
Reedy
a075271157 Update composer/spdx-licenses to 1.4.0 and mediawiki/mediawiki-codesniffer to 21.0.0
https://github.com/composer/spdx-licenses/compare/1.3.0...1.4.0

Change-Id: I39f7a1310455159866bfed5224536e800befec0d
2018-07-26 17:44:28 +00:00
jenkins-bot
ef97002179 Merge "Simplify PHP by using ?? and ?:" 2018-07-11 09:09:18 +00:00
Fomafix
6866cfec37 Simplify PHP by using ?? and ?:
Also remove not necessary surrounding parentheses.

Change-Id: I0eb5c9c1bdfb09a800258379cdcefb5fd4d3d21c
2018-07-10 20:03:17 +00:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Kunal Mehta
e0193327bd Fix MediaWiki.Commenting.LicenseComment.InvalidLicenseTag errors
Change-Id: I936c3f5fca1a0061f215e80469f5d882cb32ee29
2018-05-23 16:23:42 -07:00
Lucas Werkmeister
c1afba8ccf Improve normalizePageName documentation
Even though it wasn’t documented in the interface,
MediaWikiPageNameNormalizer::normalizePageName returns false for pages
that do not exist on the remote site. Too many users already depend on
this feature to remove it, so at least document it properly.

Change-Id: Ic2ba86b81bba86b868a6697aa57fdd46432c0d7d
2018-04-11 15:48:16 +02:00
Thiemo Kreuz
0df357b913 Fix (MediaWiki)Site::normalizePageName return type
I checked all callers of these methods and almost all of them expect the
method to return false. It looks like this return type was known at some
point, but got lost. Let's add it back.

Bug: T191634
Change-Id: I43484835b8f26e07ada6a2b1452a99ccc6d9b438
2018-04-08 11:36:19 +02:00
Umherirrender
3124a990a2 Use ::class to resolve class names in includes files
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I07a925c2a9404b0865e8a8703864ded9d14aa769
2018-01-27 20:34:29 +01:00
Umherirrender
f739a8f368 Improve some parameter docs
Add missing @return and @param to function docs and fixed some @param

Change-Id: I810727961057cfdcc274428b239af5975c57468d
2017-09-10 20:32:31 +02:00
Brad Jorsch
01a10dba5a Remove reference to deprecated IDatabase->nextSequenceValue()
The method was deprecated and made unnecessary in Ib308190c.

Change-Id: I1729ac0b3a88270a4c2f064187a2472112aaeb1e
2017-09-01 12:28:39 -04:00
jenkins-bot
84b6d5c2e5 Merge "Add missing type to @param documentation" 2017-08-11 21:31:51 +00:00
WMDE-Fisch
6df9ed1ad6 update mediawiki-codesniffer to 0.11.0 and fix issues
- mostly auto fixes
- some too long lines fixed
- ignore amp space in one case  passing by reference

Change-Id: I6472f83bc3cbf4bd629d83050cc3319b19ec465c
2017-08-11 22:27:51 +02:00
Umherirrender
5544cef16b Add missing type to @param documentation
Change-Id: I6b2c9c7af9a281fe457099cc3a336a60a25e74aa
2017-08-11 20:37:35 +02:00
Thiemo Mättig
d14faa6bed Remove auto-generated "Constructor" documentation on constructors
Having such comments is worse than not having them. They add zero
information. But you must read the text to understand there is
nothing you don't already know from the class and the method name.

Change-Id: I994d11e05f202b880390723e148d79c72cca29f0
2017-07-10 10:15:51 +00:00
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
Kunal Mehta
2dec360a6b CachingSiteStore: Avoid deprecated wfMemcKey()
Change-Id: I123b29dd41c6e0f020e0fcc661813addbec92b27
2017-05-25 11:20:24 -07:00
Florian
8d010b9721 Add maintenance script to add sites to sites table
Also: Add language code validation to Site::setLanguageCode().

Bug: T132937
Change-Id: I763ec65cb06d5250a3886a66eefdde8701b2299c
2017-02-26 16:30:13 +00:00
Aaron Schulz
64df456b39 Move remaining LoadBalancer classes to Rdbms
The old names are left as aliases.

Change-Id: I52a327f2463a2ba7437324047b5b00d28cd1d758
2017-02-23 20:38:31 -08:00
Thiemo Mättig
a068f570be Add more specific Site[] type hints to SiteStore classes
Change-Id: Ie52313861972fd1b269375dfc8f94afdf67bcb9f
2017-01-11 16:39:13 +00:00
Aaron Schulz
b6d8421ab6 Minor LoadBalancer cleanups
* Close the master connection in safeWaitForMasterPos() if created.
* Remove unnecessary reuseConnection() calls.
* Add DOMAIN_ANY constant for readability.

Change-Id: I9e64a7405e0eedc50e7b93d05d65cf00d5544a77
2016-10-06 19:07:27 -07:00
Aaron Schulz
950cf6016c Rename DB_SLAVE constant to DB_REPLICA
This is more consistent with LoadBalancer, modern, and inclusive
of master/master mysql, NDB cluster, and MariaDB galera cluster.

The old constant is an alias now.

Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
2016-09-05 22:55:53 -07:00