Commit graph

65 commits

Author SHA1 Message Date
Umherirrender fa7481b6f6 Start showing warning for deprecated PHP entry point
Change-Id: I2aa3c8fa4b04618b7b50e27858cfcb28ce468c66
2018-10-30 16:39:24 +00:00
Kunal Mehta d245edbb94 Add phan configuration
Manually import LuaSandbox's git repository as a composer dependency to
provide the PHP stubs for phan.

Change-Id: I6226b9211f31d829da5a2775c6f5cf3599dd8ebc
2018-05-14 18:41:59 -07:00
Gergő Tisza 2664e63038
Use CodeEditor and SyntaxHighlight when available
There is no reason not to default to using these when they are there.

Bug: T191737
Change-Id: Id1b918a538a45c1279e3e4ad87b2a40f8d41478d
2018-04-09 11:28:34 +02: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 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
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
Umherirrender 1d5355f190 Remove entry from ExtensionMessagesFiles
Scribunto.i18n.php is not part of this repo

Change-Id: Id016f163fcebf8f94197968c45c2189a25cb7c2e
2017-01-12 21:47:57 +01: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
Brad Jorsch 7d676c3bd2 Specify license and add COPYING file
Bug: T123943
Bug: T128586
Change-Id: I5cb16829bb8a4debe4b0e6ca7d891a0c98591f9a
2016-09-16 01:38:15 +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
Anomie 581ca1111f Revert "Add license information"
This reverts commit 4c29dba5e8.

Change-Id: I3c15b4b93355322de80cb1c3ede83bd048b4c94d
2016-01-23 15:27:39 +00:00
victorbarbu 4c29dba5e8 Add license information
Bug: T123943
Change-Id: Ib8de2c84e7e962efce656530021a44617a9dcb8a
2016-01-23 13:04:40 +02: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
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
jenkins-bot d167e19501 Merge "Add Brad Jorsch (Anomie) to extension credits" 2015-06-22 22:41:34 +00:00
Ori Livneh d426627c9b lint: 'if(' => 'if ('
Change-Id: I056ff6bbc5f992bddfd7e3bd82803de107651b80
2015-06-20 21:38:56 -07:00
Kunal Mehta 590c00f9ca Add Brad Jorsch (Anomie) to extension credits
Change-Id: Ibb87ef7c190bcb72815f26e578fca5039e550895
2015-06-16 16:36:26 +00: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
Jackmcbarn 85ac0ae4bb Make Jenkins tests pass
Something apparently changed in core, and now we need some additional
autoload classes to make tests pass.

Change-Id: I1d4c764d3836b7207831cceca8daacd735288c38
2014-12-18 22:40:33 -05:00
Brian Wolff bf22c69263 Follow-up I7d4bb9062. Register tracking categories used.
This allows them to appear in the newly added
[[Special:TrackingCategories]].

Change-Id: I6f31298e4b215c905b133b893de5c6dd514997ba
2014-03-30 21:28:21 -03:00
Siebrand Mazeland eb4706125c Migrate to JSON i18n
Procedure per https://www.mediawiki.org/wiki/Manual:GenerateJsonI18n.php
with shim.

Change-Id: I6da0ed01298e6f13046415827c6d5619ad2cfeb9
2014-03-28 21:46:41 +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
Brad Jorsch e4575c0b7c Use jquery.spinner when console is pending
This makes it more obvious to the user that something is going on.

Bug: 56472
Change-Id: I80938e0e48bd01eece4a99b8bda632a4b1375333
2013-12-10 13:07:54 -05: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 6d1c1e63ec (bug 45887) Improve error popup discoverability
The Scribunto "Script error" can be clicked, which is indicated by a CSS
cursor:pointer style. To make it more discoverable, also have it show an
underline on hover (as links do by default).

And while we're messing with it, let's remove that "style" attribute and
use the already-existing CSS class to assign the styles.

Bug: 45887
Change-Id: Ibbbf0ed268efd78e4b7844cc2639fe154ee3ab8a
2013-03-08 11:16:26 -05: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 d20af1dce4 Enable subpages
Subpages should probably be enabled by default for the Module namespace,
considering that we're planning on using /doc subpages for
documentation.

Change-Id: Ie9d192f807e8d5cd04484f6418fd5fa64e0d3117
2013-02-20 21:53:47 -05:00
Brad Jorsch 2d36fbc492 Scribunto language library
Added a language library. Introduced functions which are easy and safe,
most of them already have parser function interfaces.

Change-Id: I4465150f3e16493a15a056f7ddb7787bdf3b0373
2013-02-18 10:41:12 +11:00
Tim Starling 2d9e3c74ba Merge "Lua ustring implementation" 2013-02-13 03:32:43 +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
Brad Jorsch e878314048 Handle session loss in the console
If the session data gets lost, the console forgets the content and
previous commands. Detect this situation and handle it.

Change-Id: I82fb5e111c09091d4f9a87d2e1b1c245eced1420
2013-02-11 13:23:10 -05:00
Brad Jorsch db9fd2b39b Add mw.uri library
Change-Id: I1d94a8c288537ada038f24f2ec26922d95f14785
2013-02-07 13:31:24 -05:00
Brad Jorsch bd03237246 Add mw.site library
Contains various constants and functions to access site info.

Change-Id: I944938f9af0203c16d1a3fb2046f332045dec4d9
2013-02-06 09:20:59 -05:00
Brad Jorsch 337abb295f Make Lua engine tests modular
Rework the LuaEngine tests to be entirely modular, so that every library
need not add itself to one monolithic file. This also allows other
extensions that add Lua modules to make unit tests without having to
somehow inject them into a test class owned by Scribunto.

The approach taken is similar to that used for Selenium for running
tests against multiple browsers.

Change-Id: I294b2a8195759c0e4fa211f879305a8eb66d9c9a
2013-02-06 09:10:57 -05:00
Brad Jorsch 4c69b1350e Lua library support functions
Adds a base class for libraries with some utility functions in PHP, and a
Lua library with utility functions for use from Lua.

Change-Id: I3d67b1de8bc50488fe3a722e4e2de5849285d127
2013-01-31 12:40:39 -05:00
Tim Starling 2b4b42288c Allow the profiler to be configured or disabled
Because bugs were found in it.

Change-Id: I2737bad8663af3c8afec8a0ea4cca5d0f5b13714
2013-01-07 06:26:02 +00:00