When this test was added in Ifb2e392d3, it did not pass the correct
number of arguments to ApiFormatXml::recXmlPrint().
Bug: T182368
Change-Id: I63aee08307054137c6b50b6fbd271e03f6d4e45f
MWDebug::init() is currently irreversible -- once MWDebug is enabled, it cannot
be disabled in that execution context. This means that the MWDebug test suite
(which enables MWDebug) has a nasty side-effect -- all the tests that run after
it run with MWDebug enabled. So add an MWDebug::deinit(), and call it on test
teardown.
Ostensibly this is a great use-case for services and dependency injection. The
reason I am not going that route is that it's not entirely clear to me what the
MWDebug class is supposed to represent. If I were going to spend any
substantial amount of time on this, I would be trying to move it out of core
and into an extension, not converting it into a service.
Change-Id: I52c511be049bc276d203d07283e3aa0944f22d34
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
ApiResult was a mess: some methods could only be used with an array
reference instead of manipulating the stored data, methods that had both
array-ref and internal-data versions had names that didn't at all
correspond, some methods that worked on an array reference were
annoyingly non-static, and then the whole mess with setIndexedTagName.
ApiFormatXml is also entirely annoying to deal with, as it liked to
throw exceptions if certain metadata wasn't provided that no other
formatter required. Its legacy also means we have this silly convention
of using empty-string rather than boolean true, annoying restrictions on
keys (leading to things that should be hashes being arrays of key-value
object instead), '*' used as a key all over the place, and so on.
So, changes here:
* ApiResult is no longer an ApiBase or a ContextSource.
* Wherever sensible, ApiResult provides a static method working on an
arrayref and a non-static method working on internal data.
* Metadata is now always added to ApiResult's internal data structure.
Formatters are responsible for stripping it if necessary. "raw mode"
is deprecated.
* New metadata to replace the '*' key, solve the array() => '[]' vs '{}'
question, and so on.
* New class for formatting warnings and errors using i18n messages, and
support for multiple errors and a more machine-readable format for
warnings. For the moment, though, the actual output will not be changing
yet (see T47843 for future plans).
* New formatversion parameter for format=json and format=php, to select
between BC mode and the modern output.
* In BC mode, booleans will be converted to empty-string presence style;
modules currently returning booleans will need to use
ApiResult::META_BC_BOOLS to preserve their current output.
Actual changes to the API modules' output (e.g. actually returning
booleans for the new formatversion) beyond the use of
ApiResult::setContentValue() are left for a future change.
Bug: T76728
Bug: T57371
Bug: T33629
Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678f
Strings like "5.6.99-hhvm" are not version numbers but merely
a way for HHVM to pass version checks. They should not be
displayed in the UI.
This affects Special:Version, the API (action=query&meta=siteinfo),
the installer welcome page, and the debug toolbar.
Follows-up d09ab9001f.
Change-Id: Ia99dca64779e9c4eaddf5f0e0101674d029b8d55
- Added/removed spaces around parenthesis
- Added space after switch/if/foreach
- changed else if to elseif
Change-Id: I99cda543e0e077320091addd75c188cb6e3a42c2
Some class extending MediaWikiTestCase did not call its setUp method. We
most probably always want to do it since MediaWikiTestCase::setUp() does
garbage collection and might do more in the future.
Change-Id: I68dde370a62c8f4a779836ca0c4ad06844fdc916
This commit depends on the introduction of
MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4.
Various tests already set their globals, but forgot to restore
them afterwards, or forgot to call the parent setUp, tearDown...
Either way they won't have to anymore with setMwGlobals.
Consistent use of function characteristics:
* protected function setUp
* protected function tearDown
* public static function (provide..)
(Matching the function signature with PHPUnit/Framework/TestCase.php)
Replaces:
* public function (setUp|tearDown)\(
* protected function $1(
* \tfunction (setUp|tearDown)\(
* \tprotected function $1(
* \tfunction (data|provide)\(
* \tpublic static function $1\(
Also renamed a few "data#", "provider#" and "provides#" functions
to "provide#" for consistency. This also removes confusion where
the /media tests had a few private methods called dataFile(),
which were sometimes expected to be data providers.
Fixes:
TimestampTest often failed due to a previous test setting a
different language (it tests "1 hour ago" so need to make sure
it is set to English).
MWNamespaceTest became a lot cleaner now that it executes with
a known context. Though the now-redundant code that was removed
didn't work anyway because wgContentNamespaces isn't keyed by
namespace id, it had them was values...
FileBackendTest:
* Fixed: "PHP Fatal: Using $this when not in object context"
HttpTest
* Added comment about:
"PHP Fatal: Call to protected MWHttpRequest::__construct()"
(too much unrelated code to fix in this commit)
ExternalStoreTest
* Add an assertTrue as well, without it the test is useless
because regardless of whether wgExternalStores is true or false
it only uses it if it is an array.
Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
- Group common code in one instead of doing checks one
time in GlobalFunctions.php and another time in Debug.php
- Remove the code catching the fact that a warning is due
to a deprecation warning, no longer needed
- Pass the caller offset from wfDeprecated() to
MWDebug::deprecated(); this was breaking deprecation
notices for global objects.
- Changed PHP error level for deprecation notices (when
$wgDevelopmentWarnings is set to true) from E_USER_NOTICE
to E_USER_DEPRECATED since we now require PHP 5.3+
- Added E_USER_DEPRECATED to wfSuppressWarnings() and
removed the check for the E_DEPRECATED constant being set
now that we require PHP 5.3+
- Fixed MWDebugTest by calling wfSuppressWarnings() and
wfRestoreWarnings() in setUp() and tearDown()
Change-Id: I6810b57c90d384de55a2cf177047767cdb734f79
which we weren't treating right.
* $limit in wfDebugBacktrace() is the number of returned frames,
we thus need to take into account the wfDebugBacktrace() frame, which
is sliced from debug_backtrace().
* wfGetCaller() needs to add a level for itself.
* MWDebug::warning() was logging itself as the warning issuer,
which is useless (the call a few lines before was right, though)
MWDebugTest.php changed accordingly.
* Removed double call to wfGetCaller( $callerOffset + 1 )
* Documented the meaning of wfGetCaller() parameter
* Added unit test
Change-Id: Ief50f4c810bad8b03bb2bf9dc6d945d9acb29851
Some other test could have added their own logs, for example
deprecated notice. In that case, the first test will fail because
the log array already has some content :-b
The first ones were failing because the test suite ran on gallium without
MWDebug being initialized. This is now the case since r109033.
The second part was failling because PHPUnit on gallium does not have
the assertCount() method. Use a assertEquals() / count() workaround instead.
Tests added by 108873
Reverts r108877