Commit graph

28 commits

Author SHA1 Message Date
daniel
552ec41814 Use name constants to access config settings.
Use name constants instead of string literals in calls to Config::get
and ServiceOptions::get, when referring to core configuration variables.
This protects against typos and makes the decumentation and schema
declaration of the config settings discoverable.

This is the first batch, only touching files directly under /includes/

Change-Id: I7252e636c7c86d950d9257b33491af492c6dd5eb
2022-04-07 13:02:28 +02:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
James D. Forrester
f2f9345e39 Replace uses of DB_MASTER with DB_PRIMARY in documentation and local variables
This is just a start.

Bug: T254646
Change-Id: I9213aad4660e27afe7ff9e5d2e730cbf03911068
2021-05-14 12:40:34 -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
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
Reedy
55561aef17 Pingback.php: Minor cleanup
* Fix comments at end of lines of code
* Swap ini_get( 'memory_limit' ) comparison to !== and compare to a string
** ini_get returns a string - https://www.php.net/manual/en/function.ini-get.php

Change-Id: I3026578cbe5189fdb703233c25aaa42cfa2cb664
2021-01-18 18:44:44 +00:00
Timo Tijhof
b1856d9f38 Pingback: Don't instantiate service if disabled by configuration
The service has an early return already and the performance overhead
of scheduling, executing and instantiatingn the service and its deferred
update is extremely low.

But, it makes the overall system harder to reason about when execution
always runs through here. And it helps developers to isolate problems
and improve fault tolerance by being able to properly turn this off
if it or its dependencies are causing issues for whatever reason.

The dependencies it uses are quite core to MW, and so their issues
should not be ignored, but it makes the difference between a site
mostly working for readers and a site completely being down, because
on a stock MW install, Pingback is the only feature that uses
DeferredUpdates on regular page views by default.

Bug: T270540
Change-Id: I0d5da6bf3affdf8ab27239ef77fb8cfd87aa70d0
2020-12-22 19:13:58 +00:00
Timo Tijhof
43e3a6460b Pingback: Refactor for dependency injection and cover with tests
* Inject dependencies from the constructor and use those instead.

* Make getSystemInfo() static since its sole purpose is to collect
  global state. This also means it can be safely called from the
  Installer without needing to construct this class and its unsafe
  dependencies as the Installer was doing previously.

* Remove private 'id' member. This cached the fetchOrInsertId()
  return value but was never used.

* Remove selectField() fallback IGNORE-mode insert from fetchOrInsertId().
  This existed to handle concurrent writes, but this isn't possible
  since all this runs inside a DB_MASTER lock.

* Add missing call to $cache->makeKey().
  Avoid passing unformatted strings directly to BagOStuff methods.

Bug: T270540
Change-Id: I984526020ea4d5f0fd6f72b6be527edaf6ab0917
2020-12-22 19:13:53 +00:00
Timo Tijhof
cb27326ff3 Pingback: Re-order methods prior to refactor
- Arrange the methods in order of execution.
- Provide a single run() entrypoint for testing
  (added in the next commit).

Bug: T270540
Change-Id: I27369de38a033397aa15e3a7aba7a034dd1c94f3
2020-12-22 19:12:07 +00:00
jenkins-bot
f46260f4d7 Merge "Pass function name to database functions" 2020-06-07 16:03:38 +00:00
Umherirrender
aa83358172 Pass function name to HttpRequestFactory::create
Useful for logging

Change-Id: Ie1e3f2fefdf65cabd3fcca206e793091b99d3faa
2020-06-07 12:20:06 +00:00
Umherirrender
fd1ed0c092 Pass function name to database functions
Useful for logging

Change-Id: Ia2160fb6be5fc93f28ab51f7ae23d7f078247481
2020-06-07 14:16:52 +02:00
Reedy
a8467a0fd7 Fix numerous PSR12.Properties.ConstantVisibility.NotFound
Change-Id: I157220c4e9ff516283a60f06af99efa2439332e3
2020-05-12 18:41:43 +00:00
Aaron Schulz
98a4fa1b37 Cleanup various calls to IDatabase::upsert()
Change-Id: Ic82154f6f62014f892a64e39b4fb6aed202f32eb
2020-02-27 15:27:29 -08:00
Timo Tijhof
f575721a06 Update all use of $wgVersion to MW_VERSION
Follows-up I04628de4152dd5.

Bug: T212738
Change-Id: I718474ec0d9fd29ac2c05477f0f2493615d8aff5
2020-02-25 02:16:12 +00:00
James D. Forrester
4f2d1efdda Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse
Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
2020-01-10 09:32:25 -08:00
Umherirrender
c7ad21c25f Improve param docs
Change-Id: I746a69f6ed01c3ff000da125457df62b02d13b34
2019-11-28 19:08:59 +01:00
Umherirrender
5f43b1706c Pass options as array to IDatabase::insert
The documentation only allows arrays there

Change-Id: I00c6e47a817a70bed9a443aebc675ef4c3d6b1e5
2019-06-07 19:12:35 +02:00
Aryeh Gregor
9018579681 Deprecate the Http class
All methods got moved to HttpRequestFactory or MWHttpRequest or dropped.

I made the return value of the new HttpRequestFactory::request/get/post
methods null on error instead of false, so that when we drop PHP 7
support, we can use a "?string" return value. This could theoretically
change behavior of code that was switched from the old Http methods, but
probably won't. I kept the old behavior for the deprecated methods.

I changed the default value of $wgHTTPProxy from false to ''. This way
it should be usable directly without a trivial wrapper method. For the
benefit of anyone who might have set it to false in LocalSettings.php, I
also recommend casting to string just in case.

Http::$httpEngine is deprecated. Eventually it will be removed along
with the curl and PHP engines, leaving only the Guzlle engine.

I also added deprecation of MWHttpRequest::factory, which occurred in
1.31, to the release notes for 1.34. Now hopefully we can hard-deprecate
it in another couple of versions.

Bug: T214390
Change-Id: I2a316a758d793857f248bd251b90f5e9a6440e3a
2019-05-06 12:07:26 +03:00
Tim Starling
ba54f7f90d Fix pingback on non-MySQL
MySQL has its own implementation of upsert(), but the others rely on
$uniqueIndexes being a field list, not a field/value associative array.
The previous code generated an SQL error when checking for existing
values.

Bug: T200864
Change-Id: Ifb56f7f350fbb84144bc6f5a1dd76939816338a6
2018-08-01 11:33:19 +10:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Cindy Cicalese
fbba5dae54 Added heartbeat for pingback.
The current implementation of the pingback feature sends new data on
the first page load after running the update.php maintenance script if
no ping has yet been sent for the wiki's current MediaWiki version.
There is no way by observing the event log to determine if a given wiki
is still operational, since no further pings are sent unless the
MediaWiki version on the wiki changes. Wikis that are created for
testing purposes or that have been decommissioned will continue to live
on in the pingback data.

This patch adds a monthly heartbeat ping. The structure of the heartbeat
ping is identical to the original ping. The heartbeat ping serves not
only to indicate that the wiki is still alive; it will send updated
information, so it will be possible to find out if any of the data, such
as the PHP version or memory limit, has changed since the last ping even
if the MediaWiki version has stayed the same.

Bug: T189785
Change-Id: Ia3077ed02e36eb6ad6ef0ae4d085ecaeb1547a52
2018-03-26 11:48:27 -04: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
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
Chad Horohoe
26b01331e3 Pingback: Tweak docs a tiny bit to point to mw.org better
Change-Id: Ia01380d6bb20cfb22b6cc3717ce530df87e0d42b
2016-08-22 10:14:28 -07:00
Kunal Mehta
fa887f2fc2 Pingback: Fix phpdoc
Change-Id: Ib4fd932a9b65e46e9b43e594a6e1ab5a4dac76d9
2016-08-03 01:56:28 -07:00
Kunal Mehta
e62a95a241 Pingback: Show exactly what data is being sent during the installer
We have access to all the information that will be transmitted, so for
full transparency, display the actual JSON blob that will be sent.

Change-Id: I7dcc7bafb42619a8d49a27649fd7ac981efcd960
2016-07-22 14:08:14 -07:00
Ori Livneh
f181cdec56 Add option for sharing info about this MediaWiki install via pingback
When $wgPingback is true, MediaWiki will periodically ping
https://www.mediawiki.org/beacon with basic information about the local
MediaWiki installation.  This data includes, for example, the type of system,
PHP version, and chosen database backend.

The pingback is sent via a deferred (post-send) update whenever $wgVersion
changes, using the updatelog table to ensure we don't send duplicate pingbacks.
A database lock ensures only one thread attempts to send the pingback, and a
cache key throttles attempts to no more than once per hour.

$wgPingback is false by default. The web installer has a checkbox for
controlling this option, and it is checked by default. This nudges new installs
to turn on pingbacks, but does not sneak this decision past sysops of existing
installs.

Change-Id: Ie43a6b46a07ebd9ccc1b9c3001f2ea02435d826b
2016-07-21 21:00:28 +00:00