| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
Additionally, use strtr which is more performant (suggestion by Tim
Starling).
Bug: T270852
Change-Id: Ie8c8fb603b33ff95c8f8d52f392227f147c528d8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Deprecating something means to say something nasty about it, or to draw
its character into question. For example, "this function is lazy and good
for nothing". Deprecatory remarks by a developer are generally taken as a
warning that violence will soon be done against the function in question.
Other developers are thus warned to avoid associating with the deprecated
function.
However, since wfDeprecated() was introduced, it has become obvious that
the targets of deprecation are not limited to functions. Developers can
deprecate literally anything: a parameter, a return value, a file
format, Mondays, the concept of being, etc. wfDeprecated() requires
every deprecatory statement to begin with "use of", leading to some
awkward sentences. For example, one might say: "Use of your mouth to
cough without it being covered by your arm is deprecated since 2020."
So, introduce wfDeprecatedMsg(), which allows deprecation messages to be
specified in plain text, with the caller description being optionally
appended. Migrate incorrect or gramatically awkward uses of wfDeprecated()
to wfDeprecatedMsg().
Change-Id: Ib3dd2fe37677d98425d0f3692db5c9e988943ae8
|
|
|
|
|
|
|
| |
Conveniently provide a HookRunner instance for the benefit of callers in
a static context.
Change-Id: I12e31c23de72a00099f336e9cabf18ad35cf4e11
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
New classes and modificatons to existing classes to support the new Hooks system. All changes are documented in RFC https://phabricator.wikimedia.org/T240307.
- HookContainer.php: Class for doing much of what Hooks.php has historically done, but enabling new-style hooks to be processed and registered. Changes include new ways of defining hook handler functions as an object with defined dependencies in extension.json, removing runWithoutAbort() and addit it to an $options parameter to be passed to HookContainer::run(), being able to decipher whether a hook handler is legacy or non-legacy style and run them in the appropriate way, etc.
- DeprecatedHooks.php: For marking hooks deprecated and verifying if one is deprecated
- DeprecatedHooksTest.php: Unit tests for DeprecatedHooks.php
- Hooks.php: register() will now additionally register hooks with handlers in new HooksContainer.php. getHandlers() will be a legacy wrapper for calling the newer HookContainer::getHandlers()
- MediaWikiServices.php: Added getHookContainer() for retrieving HookContainer singleton
- ExtensionProcessor.php: modified extractHooks() to be able to extract new style handler objects being registered in extension.json
- ServiceWiring.php: Added HookContainer to list of services to return
- HookContainerTest.php: Unit tests for HookContainer.php
- ExtensionProcessorTest.php: Moved file out of /unit folder and now extends MediaWikiTestCase instead of MediaWikiUnitTestCase (as the tests are not truly unit tests). Modified existing tests for ExtensionProcessor::extractHooks() to include a test case for new style handler
Bug: T240307
Change-Id: I432861d8995cfd7180e77e115251d8055b7eceec
|
|
|
|
| |
Change-Id: I746a69f6ed01c3ff000da125457df62b02d13b34
|
|
|
|
|
|
|
| |
PHP automatically creates the array when you try to append an item to
it. Really.
Change-Id: I73b1efe749a9311feeb0d14e1c76b5bbbc0265bd
|
|
|
|
| |
Change-Id: I9e720c44e6d6c9c5d726a8a147e07ee9b638913f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When used, any hook that tries to abort the event by returning something
other than true or null, will result in a run-time exception.
To make it easier to introduce this opt-in flag, still allow explicit
'true' returns from existing callers.
Also factor out the common code between these methods into a new
private method callHook().
Bug: T173615
Change-Id: I94c7ab656bd1a046410681a810c0a3fd4f72a2e5
|
|
|
|
|
|
|
| |
Iba0138a6 removed the custom error handler in Hooks::run(), but didn't
remove the comment describing it and left behind an unused variable.
Change-Id: I9b043fa8bd79625e63d35f95f2fa3ac1b214275c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Merge the PHPUnit parser test runner with the old parserTests.inc,
taking the good bits of both. Reviewed, pared down and documented the
setup code. parserTests.php is now a frontend to a fully featured
parser test system, with lots of developer options, whereas PHPUnit
provides a simpler interface with increased isolation between test
cases.
Performance of both frontends is much improved, perhaps 2x faster for
parserTests.php and 10x faster for PHPUnit.
General:
* Split out the pre-Setup.php global variable configuration from
phpunit.php into a new class called TestSetup, also called it from
parserTests.php.
* Factored out the setup of TestsAutoLoader into a static method in
Maintenance.
* In Setup.php improved "caches" debug output.
PHPUnit frontend:
* Delete the entire contents of NewParserTest and replace it with a
small wrapper around ParserTestRunner. It doesn't inherit from
MediaWikiTestCase anymore since integrating the setup code was an
unnecessary complication.
* Rename MediaWikiParserTest to ParserTestTopLevelSuite and made it an
instantiable TestSuite class instead of just a static method. Got rid
of the eval(), just construct TestCase objects directly with a
specified name, it works just as well.
* Introduce ParserTestFileSuite for per-file setup.
* Remove parser-related options from phpunit.php, since we don't
support them anymore. Note that --filter now works just as well as
--regex used to.
* Add CoreParserTestSuite, equivalent to ExtensionsParserTestSuite,
for clarity.
* Make it possible to call MediaWikiTestCase::setupTestDB() more than
once, as is implied by the documentation.
parserTests.php frontend:
* Made parserTests.php into a Maintenance subclass, moved CLI-specific
code to it.
* Renamed ParserTest to ParserTestRunner, this is now the generic
backend.
* Add --upload-dir option which sets up an FSFileBackend, similar
to the old default behaviour
Test file reading and interpretation:
* Rename TestFileIterator to TestFileReader, and make it read and buffer
an entire file, instead of iterating.
* The previous code had an associative array representation of test
specifications. Used this form more widely to pass around test data.
* Remove the idea of !!hooks copying hooks from $wgParser, this is
unnecessary now that all extensions use ParserFirstCallInit. Resurrect
an old interpretation of the feature which was accidentally broken: if
a named hook does not exist, skip all tests in the file.
* Got rid of the "subtest" idea for tidy variants, instead use a
human-readable description that appears in the output.
* When all tests in a file are filtered or skipped, don't create the
articles in them. This greatly speeds up execution time when --regex
matches a small number of tests. It may possibly break extensions, but
they would have been randomly broken anyway since there is no
guarantee of test file execution order.
* Remove integrated testing of OutputPage::addCategoryLinks() category
link formatting, life is complicated enough already. It can go in
OutputPageTest if that's a thing we really need.
Result recording and display:
* Make TestRecorder into a generic plugin interface for progress output
etc., which needs to be abstracted for PHPUnit integration.
* Introduce MultiTestRecorder for recorder chaining, instead of using
a long inheritance chain. All test recorders now directly inherit from
TestRecorder.
* Move all console-related code to the new ParserTestPrinter.
* Introduce PhpunitTestRecorder, which is the recorder for the PHPUnit
frontend. Most events are ignored since they are never emitted in the
PHPUnit frontend, which does not call runTests().
* Put more information into ParserTestResult and use it more often.
Setup and teardown:
* Introduce a new API for setup/teardown where setup functions return a
ScopedCallback object which automatically performs the corresponding
teardown when it goes out of scope.
* Rename setUp() to staticSetup(), rewrite. There was a lot of cruft in
here which was simply copied from Setup.php without review, and had
nothing to do with parser tests.
* Rename setupGlobals() to perTestSetup(), mostly rewrite. For
performance, give staticSetup() precedence in cases where they were
both setting up the same thing.
* In support of merged setup code, allow Hooks::clear() to be called
from parserTests.php.
* Remove wgFileExtensions -- it is only used by UploadBase which we
don't call.
* Remove wgUseImageResize -- superseded by MockMediaHandlerFactory which
I imported from NewParserTest.
* Import MockFileBackend from NewParserTest. But instead of
customising the configuration globals, I injected services.
* Remove thumbnail deletion from upload teardown. This makes glob
handling as in the old parserTests.php unnecessary.
* Remove math file from upload teardown, math is actually an extension
now! Also, the relevant parser tests were removed from the Math
extension two years ago in favour of unit tests.
* Make addArticle() private, and introduce addArticles() instead, which
allows setup/teardown to be done once for each batch of articles
instead of every time.
* Remove $wgNamespaceAliases and $wgNamespaceProtection setup. These were
copied in from Setup.php in 2010, and are redundant since we do
actually run Setup.php.
* Use NullLockManager, don't set up a temporary directory just for
this alone.
Fuzz tests:
* Use the new TestSetup class.
* Updated for ParserTestRunner interface change.
* Remove some obsolete references to fuzz tests from the two frontends
where they used to reside.
Bug: T41473
Change-Id: Ia8e17008cb9d9b62ce5645e15a41a3b402f4026a
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
Change-Id: I9cf80f2b701d6db8a6cfe884e4fd15d4e0482dda
|
|
|
|
|
|
|
|
|
|
|
| |
Installing a custom error handler on every hook invocation has a high overhead,
and does not even correctly achieves what it sets out to achieve, which is to
flag hook function signature errors (and only hook function signature errors).
The "PHP way" is to simply increase the error reporting level for development
environments, which we do already.
Bug: T117553
Change-Id: Iba0138a6d0a0ddf839bc5a36e03cadb012e06f3c
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, it would send all manor of warnings to the error
and error-json channels. This adds a lot of overhead due to
AbuseFilter parse/eval errors. By passing immediately instead
of after calling handleError(), that overhead is avoided. Since
it still passes (e.g. returns false), any default PHP warning
logging still applies.
Change-Id: I18e60c09c2a48f2e26abab5d451bb52ea4ba7961
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Split fatal error handling out of MWExceptionHandler::handleError() and
move to MWExceptionHandler::handleFatalError() which has been updated to
work as a dual purpose error handler and shutdown function. Under HHVM
it will be called as an error handler and receive a stacktrace via an
undocumented extension of the error handler callback data. Under PHP5 it
will be called as a shutdown handler and attempt to gather data via
error_get_last().
Also update the error handler installed by Hooks::run() to delegate to
MWExceptionHandler::handleError() for most errors. This will allow us to
properly handle errors raised from within hooks.
Bug: T89169
Change-Id: I0f1c66f203b91fff9069520169ecc4a3b55c43d0
|
|
|
|
|
|
|
|
| |
This seems to use 3.67% of index.php real time per xenon.
This reverts commit c4cd2399390f7922c88bb521c39bfbefe000338e.
Change-Id: I1eb8dfc72036493e430271f0db3f2f2f96b149c3
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Re-adds I6f807adc9cbf71c5d7b83c7eec43965dce1d2a16 and
Ic04daf475b936b942833362c7a979dde671b3ef4 (reverted in
35ccd9c2fe058ed76be905d9efe06c31c11fd696) with 1:1000 sampling
to avoid swamping the statsd hosts.
Also fixes query module logging.
Bug: T102079
Bug: T106450
Change-Id: I8b9366407c0d1713790d08e69aaa518130f01977
|
|
|
|
|
|
|
|
|
|
|
|
| |
Reverts I6f807adc9cbf71c5d7b83c7eec43965dce1d2a16 and
Ic04daf475b936b942833362c7a979dde671b3ef4
When this hit group1 wikis statsite went nuts with errors like:
* "Failed value conversion! Input: :moduleManager:1"
* "Failed value conversion! Input: :getMessagesFileName:1"
* "Failed value conversion! Input: :get:1"
Change-Id: If0237cdd0d66634d75b2bab8bc4292c0f3ef75ef
|
|
|
|
|
|
|
|
|
|
|
| |
We previously had counts for hooks and modules as a side-effect of having them
profiled. We removed the profiling for performance reasons, which left us
without counts also. But the performance of counters is not a concern, and
their signal value not insubstantial. So introduce them here.
Fix getModulePath() to not crash while we're at it.
Change-Id: Ic04daf475b936b942833362c7a979dde671b3ef4
|
|
|
|
|
|
| |
* This wastes 60-70ms and is not really needed with flame graphs anyway
Change-Id: Ifc20ee6fb6439128195b025c652fa29c6f9fc25e
|
|
|
|
| |
Change-Id: I09d0c13070f966fcf23d2638d8fc1328279a5995
|
|
|
|
|
|
|
| |
* Also made scopedProfileOut handle the case where the callback
was null (e.g. when there are no frame methods for xhprof).
Change-Id: Ife242bda8e046990d0d8ac27d628975b7b4a14d7
|
|
|
|
|
|
|
|
|
| |
When a hook function is not callable an exception is thrown.
This patch adds the name of the offensive hook function to
the exception message to improve its informative value.
Change-Id: I376d7f5590099620a4c11ff9a4967d6d8f6560cc
|
|
|
|
|
|
|
|
|
|
| |
- 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: I783e4dbfe5f6f98b32b9a03ccf6439e13e132bcc
|
|
|
|
|
|
|
| |
Callbacks can be given as a string or array, so the hint 'callable' is
used.
Change-Id: I3842606f74c8c3705dffc70bf13e31f44a37fa65
|
|
|
|
| |
Change-Id: Ib51381a2261d064988ba2f39b71c0252f2458faf
|
|
|
|
| |
Change-Id: I8fd29e97a2b5d02746b572a9c315fbe54faf36f2
|
|
|
|
| |
Change-Id: I27f5d11ea27f783eda71c2bfdba7e70695f5d53c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Most hook handlers are written with the intent of complementing or augmenting
core functionality rather than vetoing it, making it quite natural for a
developer to forget that the caller is waiting for permission to proceed. The
potential for confusion is magnified by the fact that DOM event handlers and
jQuery event handlers are not required to return an explicit value for the
handled event to continue propagating.
This change tolerates null return values (both implicit and explicit -- that
is, both 'return null' and no return statement at all) from hook handlers. To
abort processing, a hook function must return an explicit false or an error
string.
This change should not break any existing hook functions, as returning null is
currently an error.
Bug: 50134
Change-Id: I11deb2117ff9233c77868470f50e0d8f74053545
|
|
|
|
| |
Change-Id: Ie8adc00f4ee8ecec4554e584c18d5d2073415397
|
|
|
|
|
|
|
|
|
| |
Essentially rewrote Hooks::run() to get rid of the ridiculous
four levels of indentation. Also made some slight adjustments
to fix rare edge cases (for example, moved set_error_handler
after wfProfileIn in case Profiler triggers an error).
Change-Id: Iafdd4ceedac067b49ac597359ac456f4617da9e8
|
|
|
|
|
|
|
| |
Added spaces before if, foreach
Added some braces for one line statements
Change-Id: Ibb8dd102db045522d12ff939075ba7420d95ab6b
|
|
|
|
| |
Change-Id: I1d830da0597f19efd0b2ae48642389975e736e23
|
|
|
|
|
|
|
|
|
|
|
| |
* Removed spaces around array index
* Removed double spaces or added spaces to begin or end of function
calls, method signature, conditions or foreachs
* Added braces to one-line ifs
* Changed multi line conditions to one line conditions
* Realigned some arrays
Change-Id: Ia04d2a99d663b07101013c2d53b3b2e872fd9cc3
|
|
|
|
|
|
|
|
|
|
|
| |
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.
Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
|
|
|
|
|
|
|
|
| |
Added/removed spaces around logical/arithmetic operator
Reduced multiple empty lines to one empty line
Removed wrong tabs before comments at end of line
Removed too many spaces in assigments
Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b
|
|
|
|
|
|
| |
This is similar to profiloing for db queries.
Change-Id: I14051f8aff30d249f4197270337e4080adfa5417
|
|
|
|
| |
Change-Id: Iba868e82a75fef7c7d011bc5be192bf059d037c0
|
|
|
|
|
|
|
|
|
|
| |
Until now, Hooks::run() would execute hooks registered via $wgHooks, but
Hooks:isRegistered() would not consider them and Hooks::getHandlers() would
not return them. That is inconsistent and misleading. This change aims to
make the methods of the Hooks class behave consistently, and allows them
to be used as a generic way of interacting with hooks.
Change-Id: I39bd5de2bc8ccbe8df729446363960af9d29b0be
|
|
|
|
|
|
| |
Update some method documentation
Change-Id: If4913aab7d0f8c14d49ca8320e31b1b354145c83
|
|
|
|
| |
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/111163
|
|
|
|
|
|
|
|
|
| |
bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/111073
|
|
|
|
| |
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/108745
|
|
|
|
| |
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/108743
|
|
|
|
|
|
|
|
|
| |
other in TitleReadWhitelist hook. A handler can set $whitelisted to true to whitelist the page or it can set it to false and return false (most restrictive wins).
* Added some hook doc comments.
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/108193
|
|
|
|
|
|
|
| |
(on usage of $wgOut less)
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/102505
|
|
|
|
|
|
|
|
|
| |
Trimming trailing whitespace also
Doing in 3 commits, so hopefully reviewable in CR...
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/90280
|
|
|
|
|
|
|
| |
GlobalFunctions.php and removed its inclusion from Setup.php
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/89041
|
|
|
|
| |
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/88393
|
|
|
|
|
|
|
| |
* Fix one more PHP version requirement
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/85236
|