Commit graph

50 commits

Author SHA1 Message Date
Kunal Mehta
a85f569dd1 Revert "Use CsrfTokenSet as CSRF token source"
This reverts commit 0d75fdb4f7.

Bug: T287542
Change-Id: Iedd3461869f973f8d621a39e6ad4674cbb577551
2021-08-05 15:48:26 -07: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
Petr Pchelko
0d75fdb4f7 Use CsrfTokenSet as CSRF token source
Change-Id: I079d2c802d9b48d6abf7f37fa9ef7dafac631345
2021-07-12 14:19:15 -07:00
daniel
ae78073f54 Remove unstable marker from Authority interface
NOTE: this should be backported to 1.36 before the RC0 release!

Bug: T275768
Change-Id: I86c1f6e497dcda820944be5adfd80aed7b9c63bb
2021-04-13 21:24:10 +02:00
Petr Pchelko
30cf40568b Add Authority to Context
Bug: T271460
Change-Id: If1038c94ccf8f3e59b5242f5c33b66f076c60816
2021-01-20 09:07:27 -06:00
daniel
272db6afde Replace "@stable for calling" by "@stable to call"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: If560596f5e1e0a3da91afc36e656e7c27f040968
2020-07-13 08:55:28 +00:00
daniel
bd5c3d06a2 Annotate newable classes
This annotates classes that can safely be instantiated by
extensions, per the Stable Interface Policy.

Bug: T247862
Change-Id: Ia280f559874fc0750265ddeb7f831e65fd7d7d6a
2020-07-07 15:38:57 +02:00
Aryeh Gregor
0de9c47b50 Remove Language::factory and getParentLanguage use
Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
2019-10-27 12:34:28 +02:00
Umherirrender
8752df6592 Use varargs for MessageLocalizer::msg and similar
Bug: T191666
Change-Id: I59f2ae1a96af392026fc106e57d23553003c16b8
2019-10-05 17:47:49 +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
Derick Alangi
5479c37368 context: Cleanup is_null() checks and irrelevant else code paths
This class specifically has these 2 things in many cases and converts
into the use of a tenary operations.

Quoting @Thiemo_WMDE from Gerrit comment: "The ?: operator will skip
empty arrays, empty strings, as well as the string "0". But this is
not a problem here because the properties under test are all objects.
Objects are always considered true in PHP."

Sample change can be seen below as, from;
```
if ( !is_null( $this->skin )) {
    return $this->skin;
} else {
    return $this->getContext()->getSkin();
}

```

to

```
return $this->skin ?: $this->getContext()->getSkin();
```

Change-Id: I377b118d86a24c7bcb15512f6714e6201a3e36ee
2019-03-20 20:51:58 +01:00
Umherirrender
7f68979bec Replace some wfMessage by ContextSource::msg
Change-Id: Ie056af7a002dbbf4e8defc8032bfcc0bdefc6566
2018-08-22 15:42:31 +02:00
Max Semenik
8085c58a4b Replace call_user_func_array(), part 1
Uses new PHP 5.6 syntax like ...parameter unpacking and
calling anything looking like a callback to make the code more readable.
There are much more occurrences but this commit is intentionally limited
to an easily reviewable size.

Change-Id: Idcec077ef3fdf029b632cceafd0150851ad723e3
2018-06-04 23:39:04 -07:00
Thiemo Mättig
4d9de6140e Improve 1-letter variable names in MutableContext and implementations
I'm also removing obsolete short comments that don't add anything to
whats already obvious from the method header. For example, I really don't
need a comment to understand that a method that's called "setUser" and
accepts a parameter named "$user" of type "User" is meant to "set the
User object". I mean, how more obvious can it be? ;-)

Change-Id: Ib079108457a5aa2a6896e95837542ab93b465144
2018-01-07 15:53:55 +01:00
Umherirrender
bd741b83bc build: Updating mediawiki/mediawiki-codesniffer to 13.0.0
Change-Id: Ia24dbf015f2b4781683ca980a460d0ac3e85674e
2017-09-25 17:31:56 +02:00
jenkins-bot
e72303c9f3 Merge "Remove auto-generated "Constructor" documentation on constructors" 2017-07-21 13:19:44 +00:00
Thiemo Mättig
91a920fd85 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.

This is similar to I994d11e. Even more trivial, because this here is
about comments that don't say anything but "constructor".

Change-Id: I474dcdb5997bea3aafd11c0760ee072dfaff124c
2017-07-21 12:19:30 +02:00
Timo Tijhof
01938ae7db statsd: Rename MediawikiStatsdDataFactory to IBufferingStatsdDataFactory
Follows-up I2874175647e (7fdc3d09a3).

* Avoid "MediaWiki" in class names. If unavoidable, always camelcase.
* Use a more descriptive name, matching the implementing the class ("Buffering").
* Use "I" prefix for consistency with other MediaWiki-provided interfaces.
  (Avoid "Interface" suffix, which is foreign to MediaWiki and is only used
  in the StatsdClient namespace, which this interface is not in).

Bug: T166354
Change-Id: I06de59122625f9c23e7c1a1bfa69a7ddabbf379e
2017-07-07 17:22:50 -07:00
Amir Sarabadani
d062560f24 Require $key in msg() functions
Note: calling msg() with no parameter was never supported,
doing this on a RequestContext for example would result in:
PHP Warning:  Missing argument 1 for wfMessage() ...followed
by a bunch of fallout.

So this patch only formally declares what was already a
requirement in reality.

Change-Id: I1864afb8bcc641698689828914949a06506d8f3a
2017-06-14 13:26:27 +04:30
Stanislav Malyshev
7fdc3d09a3 Refactor Statsd classes to enable null collector to work.
The following changes are added:
- Created MediawikiStatsdDataFactory interface
- Added hasData() method to see if there are any data to send
- Added getData() method to fetch data
- Made service infrastructure use MediawikiStatsdDataFactory interface
- Made wfLogProfilingData() use MediawikiStatsdDataFactory interface
- Added capability to enable/disable buffering collector

Bug: T166354
Change-Id: I2874175647e987996a9a399829b3319674471aaa
2017-05-29 15:33:02 -07:00
addshore
029ee57a8a Add getStatsdDataFactory to MediawikiServices
Change-Id: Iaf89d5d7887f766064266874ea7ba73362531ed2
2016-04-19 13:11:38 +01:00
Ori Livneh
8340400f27 Add Timing interface
* Add `Timing`, an interface which mimics the W3C User Timing API.
  It provides a canonical way to store and retrieve markers (timestamps)
  and measures (timestamps + duration).
* As the initial use-case, use it to record 'requestShutdown'.

Change-Id: I36b29162ffcc091406df025463b0e2797e52f19a
2015-11-03 15:05:37 -08:00
Kunal Mehta
f318d7a04b Add base interface for setters in RequestContext and DerivativeContext
Change-Id: I819633ca5344f73a196623569bb58fd8372d6779
2015-08-03 11:55:41 +00:00
Ori Livneh
be250544ea Ensure DerivativeContext has a $stats property
Should have been a part of Ie10db1c15 but wasn't.

Change-Id: I4552390e1476766ae2d0946df3836a8a14182b34
2015-07-02 00:41:09 +00:00
Ori Livneh
87dfc20b1e Add StatsD metric logging
This patch adds a metric data service object to the IContextSource interface,
with full support for StatsD meters, gauges, counters and timing metrics, via
the liuggio/statsd-php-client, which this patch also introduces.

Usage example:

    $stats = $context->getStats();
    $stats->increment( 'resourceloader.cache.hits' );
    $stats->timing( 'resourceloader.cache.rtt', $rtt );

The metrics are flushed to a StatsD server, which may be specified via the
'StatsdServer' configuration key. If no such configuration key exists, the
metrics are discarded.

The StatsD client supplants MediaWiki's StatCounter class. wfIncrStats()
will continue to work, but it will delegate to the StatsD data object.

Change-Id: Ie10db1c154d225971398e189737de7c560bf0f90
2015-03-09 16:57:14 -07:00
Aaron Schulz
0d84b20a7c Added clarifying comments to IContextSource
* Also removed some duplicated comments

Change-Id: I2c967d0f3219f3533378ecd5f9fccc40c8f9b219
2015-03-07 13:39:07 -08:00
umherirrender
02dc9da399 Cleanup some docs (includes/[a-d])
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: I7b65fe04db431342cc58b469dc48f41a50c4e891
2014-07-24 19:42:45 +02:00
withoutaname
a395db765b Enforce type hinting for setTitle() in IContextSource subclasses
Change-Id: Iecd8535b04072823a6f4efe33697148f4d20118e
2014-07-13 01:05:39 +00:00
withoutaname
1be828aa6c Removed setLang() too from IContextSource subclasses
getLang() has been removed by e45e0b1a6.

Change-Id: I813f96b78211fbbe5b2e93488fcf1c28878b8d5a
2014-06-22 19:54:14 +00:00
withoutaname
e45e0b1a66 Removed getLang() from IContextSource and subclasses
Change-Id: I94c3df814c06c54c071f371101882dcc71c99417
2014-06-20 11:36:59 -07:00
Kunal Mehta
07c748343c DerivativeContext::setConfig should take a Config object
Change-Id: Icc16a9c206c57fac2d26547cb874e02ef09c0485
Follows-Up: I13baec0b6d4ea7badf20b9c5f9b40846348838e4
2014-05-26 19:36:59 -07:00
Marius Hoch
e2fbfb2f3b Document that IContextSource::getTitle can return null
That can happen if wgTitle is null.

Change-Id: I3d8aab232d408e75afb8be82ca714bf5c4fe2427
2014-04-24 19:53:20 +02:00
Kunal Mehta
fbfe789b98 Config: Add Config and GlobalConfig classes
Allows configuration options to be fetched from context.

Only one implementation, GlobalConfig, is provided, which
simply returns $GLOBALS[$name]. There can be more classes
in the future, possibly a database-based one. For convinience
the "wg" prefix is automatically added.

Ironically, this adds the $wgConfigClass global variable
which is used to determine which implementation of Config
to use by default.

The ContextSource getConfig and setConfig methods were introduced
in I23194d1ba (1.23), but have no uses in Gerrit, so they can safely
be re-purposed.

Change-Id: I13baec0b6d4ea7badf20b9c5f9b40846348838e4
2014-01-27 21:10:30 -08:00
Kunal Mehta
7e0ab7ffd0 Fix typo in DerivativeContext doc
Change-Id: Ife6395fa7f78cb7b52b78cc60419fd387bd8509c
2013-12-25 22:56:49 -08:00
jenkins-bot
57d3f41876 Merge "Begin exposing SiteConfiguration via site contexts" 2013-12-09 12:28:51 +00:00
Siebrand Mazeland
1cdc4ef09b Update formatting and documentation in includes/context/
Change-Id: I8bfdbe8f6d9c325063678e24a9d604f18eb83fc3
2013-11-20 05:25:22 +00:00
Chad Horohoe
101a2a160b Begin exposing SiteConfiguration via site contexts
First step of providing configuration without relying on globals.

You can use this in your code now as follows:
 $myvar = $context->getConfig()->get( 'wgMyVar' )

Change-Id: I23194d1ba747a9e0d925154ae065cbd612b4f591
2013-10-25 14:19:04 -07:00
Brad Jorsch
fc684345b1 Allow $context->setTitle( null )
If something is messing around with $wgTitle before MediaWiki::main()
sets $wgTitle in the first place, it needs to be able to reset it back
to null to avoid a problem like bug 53498. And to do that properly, it
also needs to be able to clear the title in the RequestContext.

Bug: 55435
Change-Id: I6c763b70bbffa0762ca52e61acf7dc200da4075f
2013-10-07 15:01:01 -04:00
Brian Wolff
45024d218d Make msg method of DerivativeContext work properly.
Previously, the msg method was not taking into account any
changes to the context, and was just using the original context.

For example, if you had a DerivativeContext object, where the
original context had a language of en, and then you did
$derivContext->setLanguage( 'fr' );, $derivContext->msg( 'foo' )
was still outputting stuff in english instead of french.

Change-Id: I4a87e0e2664e77bf79a80c873db384e0c3f607e7
2013-08-18 09:20:38 +00:00
Timo Tijhof
176c5354bb docs: Consistently use "since" phrasing in @deprecated
Most have it already:
https://doc.wikimedia.org/mediawiki-core/master/php/html/deprecated.html

Ran a find/replace on "@deprecated \d" to fix the odd ones.

Change-Id: I5217aaf75264a0036b5426cd8536116b4bb8f535
2013-05-15 00:56:57 +00:00
Siebrand Mazeland
f741f6c092 Update doc comments and code formatting.
Change-Id: I1896d7b1ab5d11d3a609fd97db7c503ad6c590e5
2013-01-11 16:56:04 +01:00
Siebrand Mazeland
d4b046a893 Update docs for return and exception info
* Removed some inline tabs in the process.
* IDE fixed some incorrect leading spaces, too.

Change-Id: Ic9303eff6db4424ac3f1fa2816839692b43e6190
2012-10-09 09:41:58 +00:00
Alexandre Emsenhuber
caf5df17ab Per Aaron, fix for r108274: added canUseWikiPage() to context objects to know whether getWikiPage() can be safely called 2012-01-14 14:27:46 +00:00
Alexandre Emsenhuber
418b3503b1 * Added WikiPage to RequestContext and related so that it can be shared to avoid creating a new object each time and thus avoiding database queries to load the state of the object
* Added Article::getPage() as accessor to the WikiPage object so that it can be set in the context from MediaWiki::initializeArticle()
* Use it WikiPage::main() to call doViewUpdates()

I'm doing to this now so that I can revert r105790 and use the WikiPage object before the 1.19 release
2012-01-06 20:00:04 +00:00
Jeroen De Dauw
49cdca93be add missing deprecation notices and added deprecation version to existing ones 2011-12-13 05:19:05 +00:00
Daniel Friesen
b9e1326d30 Add missing @since tags for getLanguage and deal with this sanitizeLangCode fatal that no-one bothered to fix. 2011-12-05 18:56:09 +00:00
John Du Hart
51a6eadec1 Followup r103817, updating setLang usages 2011-11-23 10:28:21 +00:00
John Du Hart
216d661d3b Bug 29524 - Rename RequestContext::getLang to getLanguage
I'll be amazed if this doens't break any tests.
2011-11-21 16:13:21 +00:00
Sam Reed
f6300aaeae Leave a fixme comment on context stuff 2011-10-26 04:15:54 +00:00
Daniel Friesen
8dfa97ff0a Separate RequestContext.php into separate files inside of context/
Update the AutoLoader too. This is also a follow up to r97161 since I forgot to add the AutoLoader line.
2011-09-15 17:42:17 +00:00