Commit graph

119 commits

Author SHA1 Message Date
Umherirrender f73e6a24c4 Improve some parameter docs
Change-Id: Ia21866f266bbd6fad4876485798370764ae13500
2017-09-25 18:07:03 +00:00
Brad Jorsch ff9d5bc171 Remove long-obsolete ScribuntoEngineBase::getLimitsReport()
In 925045a66 the method was renamed from getLimitsReport() to
getLimitReport(), but this instance was overlooked. Since every existing
subclass implements getLimitReport(), that wasn't noticed.

Therefore, when Idffd2d78 deprecated getLimitReport() it too missed this
instance (and, in fact, added its own copy of a base-class
getLimitReport() so it could mark that deprecated instead), and
I0e8e1d56 similarly missed removing it.

So let's kill it now, like it should have been long ago.

Change-Id: I9aa71b4a90b9e7cdda08ce171b3bb004c8ccd8c2
2017-09-25 11:51:37 -04:00
Kunal Mehta 3b20423ff7 build: Updating mediawiki/mediawiki-codesniffer to 0.11.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected
* MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic
* MediaWiki.Commenting.FunctionComment.MissingParamComment
* MediaWiki.Commenting.FunctionComment.MissingParamName
* MediaWiki.Commenting.FunctionComment.MissingParamTag
* MediaWiki.Commenting.FunctionComment.MissingReturn
* MediaWiki.Commenting.FunctionComment.ParamNameNoMatch
* MediaWiki.Commenting.FunctionComment.WrongStyle

The following sniffs now pass and were enabled:
* MediaWiki.Commenting.FunctionComment
* MediaWiki.Usage.ReferenceThis.Found

Change-Id: I1074884ab6810dd082b1baebb25d02b997424818
2017-08-11 00:28:16 -04:00
Umherirrender 18b22b3a3d build: Updating mediawiki/mediawiki-codesniffer to 0.10.0
Change-Id: I92b9fb936cb8fa8411850b97804e2aacf3984322
2017-07-08 15:42:23 +02:00
Kunal Mehta 31820c673a Move tests into tests/phpunit and remove UnitTestsList hook
This takes advantage of extension.json's unit tests autodiscovery
mechanism.

Bug: T142120
Change-Id: Id526f3368fc73ba7e6ef1d793ea70ab05fbd9517
2017-07-07 13:50:39 -07:00
Kunal Mehta 11cf41c74c Automatically detect if luasandbox is installed
This makes it easier for people to use luasandbox and brings it in line
with how we currently take advantage of other PHP extensions if they're
available (e.g. wikidiff2). People can still explicitly use
luastandalone if they want to.

Bug: T128144
Change-Id: I585019be4dfeb0e2614d91dc3fb7eac0a3bd4bab
2017-06-29 18:24:11 +00:00
Kunal Mehta 246df8d427 Convert to use extension.json
The CanonicalNamespaces hook is no longer necessary as extension.json
handles it automatically, and was removed.

This sets the minimum requirement to MediaWiki 1.30.

Bug: T87969
Change-Id: Id00a2a00bddf72f5c8716f21226695456b3a32c6
2017-06-27 10:48:02 -07:00
Kunal Mehta e17a3118a5 Remove support for deprecated ParserLimitReport hook
It was deprecated in 1.22, which Scribunto no longer supports.

Change-Id: I0e8e1d56062f0cba1749d2a3e64df400d6a46f27
2017-06-23 17:42:15 -07:00
Umherirrender 4abed1d7c7 Use short array syntax
Done by phpcbf over composer fix

Change-Id: I9b7419e025ef499ff68be79789d76ad4b886d256
2017-06-16 13:26:30 +00:00
jenkins-bot ab66a83b81 Merge "Make use of the …::class feature" 2017-06-01 11:06:43 +00:00
Thiemo Mättig 07000b37c9 Make use of the …::class feature
Change-Id: I198e34d12aa2a1ee92b644d726ac6564e78a2957
2017-05-31 12:09:48 +02:00
Florian Schmidt b598cf35ae Remve usage of RequestContext::getStats()
Bug: T156810
Change-Id: I571aa4afed577e10be8b417cf1a3bf134a130739
2017-04-18 19:25:28 +00:00
Bartosz Dziewoński b8bf159e5d Do not use deprecated EditPageBeforeEditChecks hook
We don't actually add any checkboxes, so there's no reason to use it.
(We used to, but that was removed in 9b0060c8.)

Bug: T161813
Change-Id: Ia6c9df9cadb81387d4e00210d293d4d66bed8cd8
2017-03-30 19:07:47 +02:00
Tim Starling 0cf603ca9d Make the maximum language cache size configurable
Make the language cache size configurable, and increase the default from
20 to 30. It needs to be fairly small on default installations, but can
be essentially unlimited if $wgLocalisationCacheConf['manualRecache'] is
true.

Bug: T85461
Change-Id: Idb17691b30b0d2565a1624e5159df7d9b795764d
2017-03-23 15:24:00 +11:00
Brad Jorsch c69e2e5049 Update for API error i18n
See Iae0e2ce3.

Change-Id: I1642929fa48e5354217e0c6de19b4f80b38d94f0
2016-11-14 12:48:25 -05:00
Kunal Mehta edb1b51f8b Use EditFilterMergedContent hook
Bug: T147565
Change-Id: I37bc43392ffa950e230fbff6a902c061ca04b970
Depends-On: I1f0e463841298b8c59ed8bd898c8a4661c5e3aa4
2016-10-15 06:28:22 +00:00
Brad Jorsch db07787390 Cleanup backwards-compatibility code
https://www.mediawiki.org/wiki/Extension:Scribunto says that master
requires 1.25+, so let's remove checks for stuff that was added before
that.

* PPFrame::getTTL() was in 1.24.
* PPFrame::setTTL() was in 1.24.
* PPFrame::isVolatile() was in 1.24.
* Parser::fetchCurrentRevisionOfTitle() was in 1.24.
* ObjectCache::getLocalServerInstance() was added in 1.27, so restore the call to ObjectCache::newAccelerator() as BC.

This also removes BC with the php-luasandbox extension older than 1.6, which
was released before MediaWiki 1.22.

Bug: T148012
Change-Id: I36e37f3b65d0f167e1d28b00e0842d9721feee31
2016-10-13 11:07:44 -04:00
Aaron Schulz 3660ec17ba Clean up ObjectCache calls
Change-Id: I95b2d4d0f94a2e7f42372615ea9c612845502b30
2016-10-11 14:06:38 -07:00
jenkins-bot 32b91bb6f7 Merge "Use ParserOutput::addTrackingCategory()" 2016-09-14 19:47:05 +00:00
Kunal Mehta 44ccde4861 Use ParserOutput::addTrackingCategory()
Change-Id: I2989df0e689df69a0c9cf2ec6001a568fe4f635d
2016-09-14 12:34:21 -07:00
jenkins-bot cd32961367 Merge "Improve validation of ScribuntoContent" 2016-09-14 19:27:29 +00:00
Kunal Mehta 48748a6046 Improve validation of ScribuntoContent
Implement Content::prepareSave() to ensure that any content
directly passed to WikiPage::doEditContent() that doesn't run edit
filters will still be validated. We have to use prepareSave() instead of
Content::isValid() because validation depends upon the current Title.

Create a ScribuntoContent::validate() convenience function to hold the
logic for that and add a todo to use it in the EditFilterMerged hook.

Also, remove a parser test that depended upon being able to save invalid
modules directly, as what it is testing is no longer possible (unless it
pre-dates making valid syntax a requirement).

Bug: T145548
Change-Id: Ie57eff36100963f02899d669df7375577f7375e1
2016-09-14 11:50:07 -07:00
Kunal Mehta b21cecbac1 ApiScribuntoConsole: Don't use $wgUser
Change-Id: I41d9b0961e98d7836e8d5e8236ec2503f30713b1
2016-09-13 17:11:11 -07:00
Kunal Mehta 8a347d5680 Use context from EditPage/Article instead of global objects
Change-Id: Ieae2e92e248da32818f26649caaa7e70192f969b
2016-08-31 18:25:11 +00:00
jenkins-bot ef659a146a Merge "Add mw.hash to Scribunto" 2016-08-18 15:35:49 +00:00
Marius Hoch 0f4db74148 Add mw.hash to Scribunto
Provides a simple wrapper for PHP's hash() and
hash_algos() functions.

I will add docs to the Lua reference manual once
this is merged.

Bug: T142585
Change-Id: I6697463974a175e99f9b77428a1085247165ebc9
2016-08-18 04:39:04 +02:00
Brad Jorsch 31d53b4a40 ScribuntoContent: Use base class preSaveTransform()
Bug: T142805
Change-Id: I0228c8f9c09504001bb5e1d27b5482af1786c17e
2016-08-15 11:22:14 -04:00
Kunal Mehta 98436e2008 Have ScribuntoContentHandler extend CodeContentHandler
Change-Id: I8d99ba9db7f804e898a74a47d9e4e02cac45e945
2016-07-26 00:38:47 +00:00
Brad Jorsch aa4d72e3ff Fix uncontroversial phpcs errors
The following continue to be ignored:
* Generic.Arrays.DisallowLongArraySyntax.Found, because I'm not sure
  Scribunto is ready to abandon old version support in master.
* MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures,
  because it's overly strict for its purpose.

Squiz.Classes.ValidClassName.NotCamelCaps isn't ignored globally, we
just ignore it explicitly every place it's needed.

Change-Id: I307668da6ef7b3e23da19b1fd1e08914239b99b3
2016-05-18 16:31:28 -04:00
Brad Jorsch dd0c6e7668 Use ParserOutput::getRawText() where available
This is unlikely to be a cause of the cache corruption since this isn't
calling setText() on any wikitext ParserOutputs, but let's fix it just
in case.

Bug: T124356
Change-Id: Ic34c654af86385dede843009d89df6f442ddc915
2016-01-25 12:39:23 -05:00
Ori Livneh f3558e489d When logging perf stats, include wfWikiId() in metric key
...so that modules are easily locatable in multi-wiki environments (like
Wikimedia's).

Change-Id: I60b9eb6177294eedceaacd5398545a30ad896f11
2015-10-29 20:53:06 -07:00
Ori Livneh a5d97eaa90 Make the percentile threshold for slow function stats configurable
Introduce $wgScribuntoSlowFunctionThreshold, which is a float value between 0
and 1 (defaults to 0.9), specifying the percentile threshold for slow function
invocation reporting.

Change-Id: I3bd862347c21ba68d2f2f0729a834c4f7be3cd43
2015-10-30 00:16:03 +00:00
Ori Livneh 605b5ed742 Keep stats on slow function calls
Report timing data for the top 1% of Lua function invocations, measured by CPU
time. Use the PSquare class from RunningStat (Ibbd3925aa) to keep an online
estimate of the 99th percentile without storing observations.

Depends on Ibbd3925aa (and on a follow-up patch to bump the RunningStat version
in core's composer.json.)

Change-Id: I0d39920733fe719f87698f03408698ed032c9849
2015-10-28 21:34:50 -07:00
Ori Livneh 930421d242 Add ScribuntoEngineBase::getResourceUsage()
Introduce a method, ScribuntoEngineBase::getResourceUsage(), which may be
overridden by script engine implementations to provide CPU and memory usage
data.

Change-Id: I6a4ed03c1261f43a7ce7de6f274c32c450e66abb
2015-10-29 03:59:07 +00:00
jenkins-bot 3cd5e80036 Merge "Add mw-scribunto-console placeholder to view source page" 2015-09-01 16:46:02 +00:00
Derk-Jan Hartman 7e5d5759b4 Add mw-scribunto-console placeholder to view source page
Add a placeholder in the HTML to have a more reliable position in the
HTML structure of the View source page.

Depends On: Ia03265a907212ee7bac1b839dcdd4d2f24c79bbe

Bug: T110050
Change-Id: I10ff67b359f04c0decd38fae750cc264e6bce50a
2015-09-01 16:37:41 +00:00
Derk-Jan Hartman 87bc426b6b Don't override other content added to the edit page
Per the comment in EditPage.php:
extensions should take care to _append_ to the present value

Change-Id: Icaf3f250b5f65768e50b7983b5f018c38a13490a
2015-08-24 22:38:46 +02:00
Brad Jorsch b630ecdd3a Re-restrict the Scribunto content handler to NS_MODULE
I94ae07bc arbitrarily removed this restriction, which seems liable to
result in confusion where non-Module-namespace pages can be marked as
modules but can't be #invoked.

Change-Id: Ia80f49d14b1f5cded0d3f5bffb6b450fb26cd986
2015-07-24 10:17:45 -04:00
Jackmcbarn bd5e46b941 Check content model instead of title
Make Scribunto compatible with storing content model in the database, by
checking for it directly instead of guessing it based on the title.

Change-Id: I94ae07bc47273fbf65d64b2909e5895c1c3fd7e9
2015-07-19 22:16:21 -04:00
Jackmcbarn ca7a84b5b2 Fix some PHPCS issues
Change-Id: I5a44d07553d45bc01db070c99856b35a3d275bd1
2015-06-30 13:14:58 -04:00
Kunal Mehta ddfd65b790 Replace deprecated wfRunHooks by Hooks::run
Change-Id: Ie6f3280aa740304a0dadd6d00ca388c5ad6a648e
2015-06-21 15:34:10 +00:00
Ori Livneh d426627c9b lint: 'if(' => 'if ('
Change-Id: I056ff6bbc5f992bddfd7e3bd82803de107651b80
2015-06-20 21:38:56 -07:00
Mormegil a5ea880567 Allow Lua console on protected module pages
Lua debugging console is useful even if the module page is protected,
so we should display it on read-only edit pages.

However, the `EditPage::showReadOnlyForm::initial` hook does not allow
to insert HTML below the textarea, so we let the JS do it client-side.
(In fact, it might be a good idea to do the same in the base case
and never send the HTML from server, I guess.)

Bug: T93902
Change-Id: I953c4313fc67c6e708b5ef68db5380991a75b363
2015-03-28 23:28:27 +01:00
Brad Jorsch 3d51662881 Rewrite error handling to avoid OutputPage::addInlineScript
This is apparently unofficially deprecated, and we can do things a bit
more straightforwardly by using ParserOutput::addJsConfigVars() to
communicate the error messages to the JS.

This also takes the opportunity to move "ext.scribunto", which is mostly
about errors, to "ext.scribunto.errors".

Bug: T75618
Change-Id: I1577dab2dab1bd79cb127879de141fdbb8963aeb
2015-03-16 16:08:44 -04:00
Chad Horohoe beb8b63683 Remove obvious function-level profiling
Change-Id: I94654fc0f72d0953c618a9e0a9b73f4a387df8b7
2015-02-12 11:53:18 -08:00
Thiemo Mättig 93579c7363 Add more comments and type hints
Change-Id: I8c4b91d3a6695cc33c9c3d3fb427af5412323ff7
2014-12-19 19:25:53 +00:00
Mr. Stradivarius 98f25aa9a1 Improve error messages in mw.html
Add more information to error messages in mw.html. This includes the
error level, the function name, and the position of the argument in the
argument list. Where possible, use the functions in libraryUtil.lua to
do this.

Some functions in mw.html accept multiple types, so add a checkTypeMulti
function to libraryUtil.lua to make these kinds of functions easy to check.
And while we're at it, add test cases for libraryUtil.lua as well.

Change-Id: If9cf9a52bd4b1bb42cc7f9f1f1096828710cbc52
2014-12-08 17:01:31 +00:00
jenkins-bot 398713b1a7 Merge "Use Parser::SFH_OBJECT_ARGS class const" 2014-11-18 20:30:06 +00:00
umherirrender 30c38929d2 Use Parser::SFH_OBJECT_ARGS class const
Instead of the global const

Change-Id: Iaf557f0f56964c8b545a4cd1582a852c12183def
2014-11-18 20:56:33 +01:00
Thiemo Mättig 55fe0b69d0 Add missing visibility keywords everywhere
Change-Id: I270d1dd9b6545e15398c2f8b8e9ae533844cc998
2014-11-14 10:10:23 +01:00