Commit graph

74 commits

Author SHA1 Message Date
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 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
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
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 8a347d5680 Use context from EditPage/Article instead of global objects
Change-Id: Ieae2e92e248da32818f26649caaa7e70192f969b
2016-08-31 18:25:11 +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 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
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
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
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
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
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
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
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
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
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
jenkins-bot a85275592c Merge "Add text module" 2013-03-27 16:55:07 +00:00
Brad Jorsch 5989d28678 (bug 39655) Add Lua version info to Special:Version
Use the SoftwareInfo hook to add the versions of LuaSandbox and Lua to
Special:Version.

Bug: 39655
Change-Id: I912197efee0211066677c4d46e638fb546a410c6
2013-03-25 04:07:30 +00:00
Brad Jorsch 0db3d7c6d2 Add text module
This exists for some common text-processing functions that aren't
included in string (and therefore also aren't in mw.ustring), as well as
a logical place for the "unstrip" function requested in bug 45085.

Bug: 45085
Change-Id: I47356215fcc8ddeed5f901cd933a30021394bd78
2013-03-20 10:10:15 -04:00
Brad Jorsch ded331ddc9 (bug 45845) Allow for docs at non-subpages
It has been claimed that some wiki might want to place module
documentation at a location other than as a subpage of the module, for
example under "Project:Module documentation/$1". It's possible to
support this, so we may as well.

This also involves renaming the "scribunto-doc-subpage-*" messages to
"scribunto-doc-page-*", since the interpretation of
scribunto-doc-subpage-name would be drastically changed.

Note that any wiki that has customized scribunto-doc-subpage-name will
need to re-customize scribunto-doc-page-name, the old value will not be
transferred.

Bug: 45845
Change-Id: Ic453561691e04b5250d219cc7d871c17e60b9912
2013-03-12 14:33:40 -04:00
Brad Jorsch 7617f25a8b (bug 46031) scribunto-doc-subpage-name needs to be in the content language
Bug: 46031
Change-Id: I6e3c2c244f85258838774491d3bcc6ebd6a2c8c3
2013-03-12 14:18:28 -04:00
Brad Jorsch 04a0a580e3 Add mw.title library
Note that fetching any title besides the one for the current page is
considered "expensive". It also records the title fetched in the
ParserOutput so it will be listed in pagelinks, just like #ifexists.

This also moves the ToString test formatter into TestFramework.lua, so
TitleLibraryTests.lua can use it too.

Change-Id: I799f3289a37fe1349b6bca5758829acf82cb718f
2013-02-28 11:57:11 -08:00
Brad Jorsch ba09ba3fde Add mw.message library
Change-Id: I12ca84f848c34f1227ee8acdc8bc04bdfd0b2d97
2013-02-26 22:20:04 -08:00
Brad Jorsch 30a75fb0f1 Add module documentation support
Add the ability for modules to be documented using a /doc subpage, which
is automatically transcluded onto the module page.

To get the transcluding to work right, I wound up having to change from
the deprecated-in-1.21 ArticleViewCustom hook to ContentHandler, as
there didn't seem to be any other way to get the ParserOutput into the
links tables. Which means Scribunto now needs MediaWiki 1.21 rather
than 1.20.

Change-Id: Id487097c2a505c11f92a3404f5d3ee98beb2570c
2013-02-22 05:01:29 +00:00
Brad Jorsch 0a8757baba Lua ustring implementation
This is a reimplementation of Lua's string library with support for
UTF-8.

The entire ustring library is implemented in pure Lua. PHP callbacks are
also available for overrides: in LuaSandbox these are used for almost
all functions, while in LuaStandalone they are used only for the pattern
matching. Also, ustring.upper and ustring.lower are overridden using
mw.language's .uc and .lc if available.

It also includes a bunch of unit tests.

Note that if you download the normalization tests, they may fail under
LuaSandbox if you have PHP's intl extension installed and libicu on your
system is too old.

Change-Id: Ie76fdf8d3a85d0a3d2a41b0d3b7afe433f247af0
2013-02-12 14:26:29 -05:00