Commit graph

38 commits

Author SHA1 Message Date
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
Umherirrender
ace44e2064 Use correct variable name in @param documentation
For some varargs a variable name is added with suffix ,... as seen for
many other varargs

Some @param are swapped, because there are in the wrong order

Enable Sniff MediaWiki.Commenting.FunctionComment.ParamNameNoMatch

Change-Id: I60fec6025bce824d5c67563ab7b65ad6cd628ad8
2017-08-11 19:27:19 +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
WMDE-Fisch
7b5f08e703 Replace deprecated Context::getStats() with MWServices::getStatsdDataFactory()
Change-Id: I1756f69ca2ebd301a5049bf758d1a87c37771fe6
2017-03-17 12:07:03 +01:00
Timo Tijhof
3a2a707546 Clean up remaining get_class() uses
* get_class()        -> __CLASS__ (same as self::class)
* get_called_class() -> static::class
* get_class($this)   -> static::class

Change-Id: I1888a1897ecf4548a2e5a67a942e5c080dd7e3d3
2017-03-07 22:03:47 +00:00
Max Semenik
068e0e6ca0 Remove/actualize unused imports
Change-Id: I6ef19d5d982aa45dbf5554107ad9ee720442f466
2016-09-26 17:03:26 -07:00
addshore
029ee57a8a Add getStatsdDataFactory to MediawikiServices
Change-Id: Iaf89d5d7887f766064266874ea7ba73362531ed2
2016-04-19 13:11:38 +01:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
umherirrender
54c1e18eec Remove various double empty newlines
The double empty newline is not needed between functions, variable or at
end of file

Change-Id: Ib866a95084c4601ac150a2b402cfa184ebc18afa
2015-12-27 18:55:12 +00: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
Aaron Schulz
bd963865b6 Fixed some RequestContext IDEA errors with msg() callers
Change-Id: I2a382ee8498eafd9fe045550dd9c1f61a8933926
2015-08-25 04:35:34 +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
Kunal Mehta
41f159e372 ContextSource::getContext() can return any IContextSource
Change-Id: Ie5866ce42accf87a2bfb1bc1a24c8966a0d3c20d
2014-07-12 21:41:45 -07:00
withoutaname
e45e0b1a66 Removed getLang() from IContextSource and subclasses
Change-Id: I94c3df814c06c54c071f371101882dcc71c99417
2014-06-20 11: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
umherirrender
9c614ac02d Fixed some @params documentation
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.

Change-Id: I8c9f30128b46086064326708a4878228ba459447
2014-04-14 19:52:18 +00: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
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
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
Aaron Schulz
f31a0463aa Fixed importScopedSession() and moved exportUserSession() to RequestContext.
* Renamed WebRequest::exportUserSession -> RequestContext::exportSession.
  Updated the only callers of this new function.
* Init the user with User::newFromId() instead of relying on the session
  (which breaks when things like CentralAuth are enabled).
* Made RequestContext::exportSession() include the user ID.
* Removed now-redundant user ID checks in upload jobs.
* Added unit tests for the session import function.

Change-Id: I543e6766f7a8a828ea5d270328c3bc7738c6fe94
2013-03-15 12:49:54 -07:00
Siebrand Mazeland
f741f6c092 Update doc comments and code formatting.
Change-Id: I1896d7b1ab5d11d3a609fd97db7c503ad6c590e5
2013-01-11 16:56:04 +01:00
umherirrender
85d8ee1f87 Remove a bunch of trailing spaces and unneeded newlines
Change-Id: I00f369641320acd7f087427ef031f3ee7efa0997
2012-10-10 20:14:40 +02: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
c65cceab1f doc++ 2011-12-18 21:29:41 +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
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
450814de00 More documentation updates 2011-10-28 18:11:47 +00:00
Platonides
97ab876991 Fix fatal: Fatal error: func_get_args(): Can't be used as a function parameter in includes/context/ContextSource.php on line 121 2011-10-21 22:18:02 +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