wfSuppressWarnings() and wfRestoreWarnings() were split out into a
separate library. All usages in core were replaced with the new
functions, and the wf* global functions are marked as deprecated.
Additionally, some uses of @ were replaced due to composer's autoloader
being loaded even earlier.
Ie1234f8c12693408de9b94bf6f84480a90bd4f8e adds the library to
mediawiki/vendor.
Bug: T100923
Change-Id: I5c35079a0a656180852be0ae6b1262d40f6534c4
Also:
* Update wfHttpError() to use uppercase DOCTYPE, to match other code
such as Html.php, wfThumbError(), HttpError.php, etc.
Change-Id: I4027e7fe1a138b03f78797b6d1bfe7bd1064d360
The warning occurs when gmp_init() tries to convert the empty string
that came from ltrim(). This is causing tests to fail under HHVM 3.6.1.
Follows-up 5957856c46.
Bug: T98882
Change-Id: Ica86c91d7897db979e09d7cfc82fb3a20b95d4ce
Also sets default paths immediately (not in Setup.php) so
they are available before extensions register.
Bug: T98319
Change-Id: I41a8aec7a3e9c576ec7344abf51f8106248ade4b
A user just logged on to the #mediawiki channel to ask for help because his
webhost disallowed php_uname(), causing wfIsWindows() to crash. Google
autocompletes 'php_uname()' to 'php_uname() has been disabled for security
reasons', so it is probably not uncommon. Consulting the PHP_OS constant
instead side-steps the problem nicely.
Change-Id: I8d63826db4fc5d142eac53717d4f9fbbf9928de9
* Previously if it was called before a DB_SLAVE connection, it would not
be set. This is fixed now.
* Also set mLaggedSlaveMode in LoadBalancer as appropriate. Before, it
was only set in the "too lagged for ChronologyProtector" case.
Change-Id: Ic4dc555cf762653f157df1795f53f3577c1e587a
Move the MWLogger PSR-3 logging related classes into the
MediaWiki\Logger namespace. Create shim classes to ease migration of
existing MWLoggerFactory usage to the namespaced classes.
Bug: T93406
Change-Id: I359cc81fbd2dcf8937742311dcc7d3dee08747b0
* Associate Profiler objects with a request context by adding a $context
property with a getter and a setter.
* Introduce ProfilerOutputStats, which writes profiling data to the stats
buffer associated with the current request context.
* Make it the Profiler class's responsibility to enforce $wgProfilerLimit.
* Deprecate $wgProfilerLimit in favor of the (more aptly named, IMO)
$wgProfiler['threshold'] config setting.
* Tidy up Profiler instance creation code in Profiler::instance().
* Add Profiler::getOutputs, which returns an array of ProfilerOutput instances
which are configured for the current profiler and whose canUse() method
returns true.
* Make ProfilerStub not log by creating a stub ProfilerStub::logData() method
which does not call the parent. Previously the parent class checked if $this
was an instance of ProfilerStub and returned early if so.
Task: T90623
Task: T85641
Change-Id: Icf644ad3435c1f30d0a49957a97b481808a3153d
* Deprecate $wgRequestTime in favor of $_SERVER['REQUEST_TIME_FLOAT'], which is
more accurate. Because $_SERVER['REQUEST_TIME_FLOAT'] is only set for PHP
5.4+, set it to microtime( true ) in WebStart.php for back-compatibility.
* Add a 'requestTime' property to WebRequest objects, set to
$_SERVER['REQUEST_TIME_FLOAT'] for WebRequest or the instance creation time
for FauxRequest instances.
* Use that to provide WebRequest::getElapsedTime(), which gets the time since
the request was initiated.
* In wfLogProfilingData(), get the user and request objects from the context
object rather than from global scope.
Opportunistic clean-up: move the magic quotes check to WebStart.php and make
the error message more helpful.
Change-Id: I7e07e22eaf16b5141b80ad9f843285c542a127b7
Right now wfLoadExtension() and related functions explicitly load
extensions immediately, bypassing the queue. This was done to be
extremely backwards-compatible with the old require_once style of
loading which does the same.
However, for a future configuration database to work, we need to be able
to reliably load extensions after configuration (LocalSettings.php) is
loaded, which is currently at the top of Setup.php. Rather than doing
this later, we should do this now to make sure the registration system
will be able to handle it.
In Wikimedia production, excentions are currently being loaded with
direct calls to:
ExtensionRegistry::getInstance()->queue(...);
so we know that this should work, but that is not a nice API for sysadmins
and developers to be entering into LocalSettings.php.
If for some reason an extension really needs to be loaded immediately,
they can still call:
ExtensionRegistry::getInstance()->loadFromQueue();
But that should be the exception, not the norm.
Change-Id: I72672e5c9541ede02d09f548c39ef6c8df0ec78a
This function is backwards:
* The stated purpose is to generate a list of differences for callers to parse,
however we already have DiffEngine that returns a list of differences that you
don't need to parse manually shooting your feet off in process.
* With improvements in PHP performance in the last 10 years, shelling out instead of using
a pure-PHP diff has a doubtful performance benefit.
* Even in configurations where it's faster on predominant diffs (which have to be huge),
shelling out has its own security implications.
This function is not used in core. The only extensons using it are Echo (which just parses
its output so would be better off with DiffEngine) and AbuseFilter, let's not add more users
by tolerating this function.
Also, add error checking while I'm at it.
Change-Id: Ia67debce39de8252312fd887ebfbe6fb89f9edc9
Refactor out 'infinity' vartiant values which used in blocking and
protecting actions. This patchset adds GlobalFunction wfIsInfinity.
Bug: T68646
Change-Id: I60cc55a5bbd43c72916a1c2ea3807457d4e33765
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
wfEscapeShellArg() can handle multiple params, escaping each.
This patch changes wfShellExec() to call wfEscapeShellArg() directly
instead of doing the gluing itself.
This patch also extends wfEscapeShellArg() to accept an array parameter
optionally instead of as separate args, which is often useful.
Added also unit test cases for single, multiple args, and single array args.
Change-Id: I7a0761cc2ba98c210a9eacadd12da407d933e42a
Instead of instantiating this on every single request. Removes
wfGetLangConverterCacheStorage() and $wgLangConvMemc which were
otherwise unused.
Change-Id: Ic500944a92c2a94bc649e1b492c33714d81dca00
If $wgResponsiveImages is on, include the 1.5x and 2x multipliers
in the wfThumbIsStandard() standard image size comparisons.
Change-Id: I79d866387730cdd4d7c7a976e691192b2335b7ce
Time wounds all heels. During the code review for the PSR-3 logging
introduction, several people asked me why we needed a wrapper
for Psr\Log\LoggerInterface if the point was to use the standard. At the
time I was convinced that it would be better to introduce the dependency
via a wrapper class so that we could use the wrapper to patch over any
deficiencies that we might find in the PSR-3 API. After going on to work
on a project to disentangle other MediaWiki components from internal
project dependencies I have suddenly and clearly seen the error of my
ways.
We still need a logger factory as PSR-3 does not specify
a standard mechanism for creating Psr\Log\LoggerInterface instances. My
solution is to convert MWLogger into MWLoggerFactory to retain a static
factory interface for creating PSR-3 loggers but remove the MWLogger
wrapper class itself in favor of direct exposure of
Psr\Log\LoggerInterface to the MediaWiki consumer classes.
Change-Id: Ie47467657dcf341991ada00827dca5e8eff95438
For example, if the database cannot be connected to, the language is
something other than 'en', and the l10n cache is LCStoreDB, then the
call to Language::factory() in Setup.php line 604 will do it when it's
trying to get the fallback list.
Bug: T86398
Change-Id: Ia0e9ea440dcc4c8ab7bab1f33802aeff487eb3f0
Introduces wfLoadExtension()/wfLoadSkin() which should be used in
LocalSettings.php rather than require-ing a PHP entry point.
Extensions and skins would add "extension.json" or "skin.json" files
in their root, which contains all the information typically
present in PHP entry point files (classes to autoload, special pages,
API modules, etc.) A full schema can be found at
docs/extension.schema.json, and a script to validate these to the
schema is provided. An additional script is provided to convert
typical PHP entry point files into their JSON equivalents.
The basic flow of loading an extension goes like:
* Get the ExtensionRegistry singleton instance
* ExtensionRegistry takes a filename, reads the file or tries
to get the parsed JSON from APC if possible.
* The JSON is run through a Processor instance,
which registers things with the appropriate
global settings.
* The output of the processor is cached in APC if possible.
* The extension/skin is marked as loaded in the
ExtensionRegistry and a callback function is executed
if one was specified.
For ideal performance, a batch loading method is also provided:
* The absolute path name to the JSON file is queued
in the ExtensionRegistry instance.
* When loadFromQueue() is called, it constructs a hash
unique to the members of the current queue, and sees
if the queue has been cached in APC. If not, it processes
each file individually, and combines the result of each
Processor into one giant array, which is cached in APC.
* The giant array then sets various global settings,
defines constants, and calls callbacks.
To invalidate the cached processed info, by default the mtime
of each JSON file is checked. However that can be slow if you
have a large number of extensions, so you can set $wgExtensionInfoMTime
to the mtime of one file, and `touch` it whenever you update
your extensions.
Change-Id: I7074b65d07c5c7d4e3f1fb0755d74a0b07ed4596
Xhprof generates this data now. Custom profiling of various
sub-function units are kept.
Calls to profiler represented about 3% of page execution
time on Special:BlankPage (1.5% in/out); after this change
it's down to about 0.98% of page execution time.
Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
When a logging service other than MWLoggerLegacySpi is used, the
behavior of wfErrorLog is not guaranteed.
Change-Id: I8543bfd556aa752665f7a3daa855d3c2f7fc8956
Notice: Undefined index: line in
/var/www/wiki/includes/GlobalFunctions.php on line 1840
Caused by fc2e6df64f, previous versions
used isset here.
Change-Id: Ie9434f09e0905346ace19909fb316d47c75e0440
* It will also no longer call getReaderIndex( false, ... ) twice
* Removed various related ampersands
Change-Id: Ia79e2007dbf84e7437f9439aa6371333aa3e1b23