Commit graph

90 commits

Author SHA1 Message Date
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
Brad Jorsch 9443fda132 Add i18n for API module help and mark ApiScribuntoConsole as internal
MediaWiki core change I04b1a384 added support for i18n of API module
help. This takes advantage of that while still maintaining backwards
compatibility with earlier versions of MediaWiki.

Once support for MediaWiki before 1.25 is dropped, the methods marked
deprecated in this patch may be removed.

Change-Id: I67395aff48185f3e09da31b51a08aa2541fe6a17
2014-11-03 21:10:19 +00:00
Thiemo Mättig d7c173b521 Add missing PHPDoc comments and type hints
There are like a billion things missing in the inline documentation
of this extension. Wow. This is what I can do for now.

Change-Id: I019c24d13cf5cb22dde4d710b86ef8f976e1ec96
2014-10-09 23:23:05 +02:00
jenkins-bot 1fa52ef583 Merge "Allow for dynamically-loaded PHP libraries" 2014-10-03 14:01:46 +00:00
Brad Jorsch df38a296bf Allow for dynamically-loaded PHP libraries
Scribunto currently supports libraries with PHP callbacks that are
loaded on startup, and pure-Lua libraries that may be loaded from the
module with require().

This change allows for libraries with PHP callbacks to also be loaded
with require().

Change-Id: Ibdc1f4ef51b1c8644c3d4c98d57755b5c06447a5
2014-10-03 09:27:23 -04:00
Jackmcbarn 9b0060c89a Remove "Allow saving code with errors"
This was never really a good idea. If you really want to save incomplete
code, you can put it all in a block comment. Since some modules may still
have errors from before this change, the tracking category for them has
not been removed.

Change-Id: Icb3da00a86b9773287dcd0c9277ad61446ec07ce
2014-09-30 04:05:12 +00:00
Yuri Astrakhan 66ac157c12 Use single quotes for <pre> (easier to read)
Change-Id: Ib666f56471fc8ea7dac36367c962788d1a304100
2014-09-21 22:51:46 -04:00
Jackmcbarn c5959b56e7 Display the full error message in wikitext
Instead of just displaying "Script error" in wikitext, display the actual
error string. Currently, many users don't see meaningful error messages
generated by modules, and instead just assume that "Script error" means
the module itself has a bug.

Bug: 71038
Change-Id: Ie5358049975352e0fef92088a06b97ad94717000
2014-09-19 12:11:38 +00:00
Jackmcbarn ece8cc5e82 Only set indexOffset when the function name is indexed
If a function name contains an equals sign, it doesn't increase the index,
so indexOffset=1 makes Lua see arguments as starting with 0. This change
fixes that, so that indexOffset is only set to 1 if the function name has
an index.

Change-Id: Ifa2dfad4d2f7228c3fd5721ccfc4c235576b663d
2014-09-06 15:42:13 -04:00
addshore e29c8eda63 Use public instead of var in classes
Change-Id: I0c059515cbf0fa8ef3846526a989f1a322fcd8ae
2014-08-17 22:11:26 +01:00
Jackmcbarn 2295009729 Add 2 tests to unitTestsList
Change-Id: I839515927e66a046d7b3e7b00d7d24efad3eacb5
2014-08-09 21:34:12 -04:00
Jackmcbarn 40b8bd2caa Add comments and remove trailing whitespace
Clean up trailing whitespace from all of our code, and add comments
indicating that apparently unused variables are ScopedCallbacks.

Change-Id: I8e5997797cc7b1c64c5351ec112a18f30edc8fef
2014-07-07 14:46:59 -04:00
Brad Jorsch c44d576b78 Update GeSHi integration
Idf4ad439 deprecated SyntaxHighlight_GeSHi::buildHeadItem in favor of
ResourceLoader. We may as well follow along.

To avoid breaking things if people don't update their
SyntaxHighlight_GeSHi in sync with Scribunto, test for the RL class used
in GeSHi's ResourceLoader integration and continue using buildHeadItem
if it's not found.

Change-Id: Id93530dce7c8c5a70a98fca58844adf9b5c6a23f
2014-07-03 14:50:50 -04:00
Jackmcbarn ec42679913 Show ScribuntoExceptions in content language
Messages from ScribuntoException are cached and stored with the page, so
they need to be output in the content language.

Change-Id: Ic8bd5cef2c49118ccb258592ca515c0e71f210e3
2014-06-28 17:59:05 -04:00
Reedy 4d0665dbd8 Parameter type hints
Change-Id: I3d578ab6fb65917ef0fa65767089b01ca7c4e96d
2014-06-18 18:19:07 +01:00
Marius Hoch 186212cfe6 Fix return doc for ScribuntoEngineBase::fetchModuleFromParser
Change-Id: I5c16c18ee4667adcb76fd647f55713ef227466e8
2014-06-18 18:51:09 +02:00
Derk-Jan Hartman fd295c3b71 Convert Scribunto to use fillParserOutput
Followup-to: Idf4ad4397101a4d19be2ac773cd4bad52188d903
Change-Id: I7e18d57f231716127028dafe44e61cee7d89d4d9
2014-05-10 17:31:26 +02:00
Amir E. Aharoni a8a17a8bb0 Show module doc with the correct direction formatting
* Add mw-content-(ltr|ltr) class to the documentation <div>.
* Rewrite the div code as Html::rawElement instead of
  concatenating a string.

Done in pairing with Niklas Laxström.

Change-Id: I4d68d53df9dcf3556885552b738f2c327aaa8607
2014-05-08 17:48:14 +02:00
Jackmcbarn d74c81c233 Add name to nosuchfunction and nosuchmodule errors
When displaying a nosuchfunction or nosuchmodule error, include the name
of the nonexistent function or module.

Change-Id: I17fc2c68dc8267302a82eee3cb2c5df9b5a3c46c
2014-04-13 21:29:05 -04:00
Marius Hoch 08de37719d Don't try to inline load ext.scribunto on mobile
This module doesn't exist on mobile, so don't try to load it there
(which will produce an exception).

Bug: 59808
Change-Id: Ifad7edb508c1f740a109e8f5c1656e4c7841ab13
2014-03-21 03:00:42 +01:00
Brad Jorsch b58ee1da94 Use the new limit report hooks
Change Ie065c7b5 added an option to show profiling data at the bottom of
preview pages, and with it new hooks to gather and format this data in a
more structured way than is possible with ParserLimitReport. This change
adds support for the new hooks.

Depends-On: I7799616a602d90e1b8d3f0ece35811ca387bade7
Change-Id: Idffd2d78f9a0217c99c07cbbfc844d6daf0172f7
2014-02-10 04:11:35 +00:00
Brad Jorsch 1397351289 Add newlines around scribunto-doc-page-show wikitext
Change I15c10379 wrapped the scribunto-doc-page-show message in a div,
which is breaking things when the content of that message starts with
start-of-line-sensitive wikitext. So add a newline inside the div.

Bug: 60664
Change-Id: If596bed72f779f5980348ac111b63e7876d21ff4
2014-02-10 00:41:03 +00:00
Marius Hoch ac62e34952 Add mw.html to Scribunto
A module for building complex HTML from Lua using a
fluent interface. The module is originally from enwiki,
but the authors allowed us to reuse it under GPLv2+
(as stated in the file).
The module will be loaded per default and comes with
unit tests.

As discussed on wikitech-l:
http://lists.wikimedia.org/pipermail/wikitech-l/2013-December/073320.html

Change-Id: I7c8d4378091c13d5ace0dd1fcbb4e27163e8c896
2014-01-03 00:04:34 +01:00
Brad Jorsch 628c8b60ca Tracking category for modules saved with errors
When the "Allow saving code with errors" checkbox is used, an
automatically-added tracking category would be useful. And we may as
well also include the error message that would have been displayed when
trying to save without that checkbox checked.

Bug: 39605
Change-Id: Ideb72a58887fb1187b9adba80b7245cdca070ce4
2013-12-09 12:00:16 -05:00
jenkins-bot 9ded458c28 Merge "Modules should be in English (while docs are not)" 2013-10-01 16:57:25 +00:00
Brad Jorsch 349fbb2daa Fix possible fatal error
If an invalid title is entered into MediaWiki:Scribunto-doc-page-name,
it could cause "attempt to call function on a non-object" fatal errors
all over the place. Let's avoid that.

Bug: 52404
Change-Id: Id5c6e7cd01b13547095553358310605dd02e90aa
2013-08-22 10:16:06 -04:00
Brad Jorsch e12d743986 Handle bogus entries in MediaWiki:Scribunto-doc-page-name
If someone puts something broken in MediaWiki:Scribunto-doc-page-name,
it may not be possible to determine which module the page is a doc page
for. In that case, just pretend it's not a doc page.

Bug: 49322
Change-Id: Ia4421576b372e188cf7e3dfe2c0b8ce213d026d4
2013-06-07 18:21:31 -04:00
Liangent 1050d29845 Modules should be in English (while docs are not)
Change-Id: I15c10379ab2282a508322df3914d82e1fc463a22
2013-05-29 15:08:31 +00:00
Brad Jorsch 1e02fad924 Fix content format for ScribuntoContentHander
We had intended to use the constant CONTENT_FORMAT_TEXT, but
accidentally used that as a string instead.

Change-Id: I93a2c02d48d3fd7b73530562165d817965e272d1
2013-04-30 14:28:14 -04:00
jenkins-bot a85275592c Merge "Add text module" 2013-03-27 16:55:07 +00:00