jenkins-bot has submitted this change and it was merged.
Change subject: Revert "Preprocess text arguments"
......................................................................
Revert "Preprocess text arguments"
This reverts commit 13a10a79aa36c6374a518231fe5938fa8cda222a.
Per comments on bug #69540, this wasn't really a good idea to
do in the first place.
Bug: 69540
Change-Id: I35c6a2581991137215cf53aaa084a06d2d8e1f1a
---
M includes/lua/Infobox.lua
M tests/phpunit/output/BasicRowTest.lua
M tests/phpunit/output/BasicRowTest.php
M tests/phpunit/output/BasicTest.lua
M tests/phpunit/output/BasicTest.php
5 files changed, 40 insertions(+), 87 deletions(-)
Approvals:
Hoo man: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/lua/Infobox.lua b/includes/lua/Infobox.lua
index f29ad0d..1254ab6 100644
--- a/includes/lua/Infobox.lua
+++ b/includes/lua/Infobox.lua
@@ -35,19 +35,6 @@
end
end
-local function preprocess( val )
- if val == nil then
- return nil
- elseif mw.getCurrentFrame() ~= nil then
- return mw.getCurrentFrame():preprocess( val )
- else
- -- In unit tests there's no frame available, thus we can't
- -- preprocess values. That wont happen in production or in the
- -- integration tests.
- return val
- end
-end
-
-- Gets an mw.html table representing the infobox
function methodtable.getHtml( t )
local html = mw.html.create( '' )
@@ -82,11 +69,8 @@
t.args.subHeaders = t.args.subHeaders or {}
local i = #t.args.subHeaders + 1
- t.args.subHeaders[i] = {
- text = preprocess( text ),
- style = style,
- class = class
- }
+ t.args.subHeaders[i] =
+ { text = text, style = style, class = class }
return t;
end
@@ -102,10 +86,8 @@
t.args.rows = t.args.rows or {}
local i = #t.args.rows + 1
- t.args.rows[i] = {
- header = preprocess( header ),
- class = class
- }
+ t.args.rows[i] =
+ { header = header, class = class }
return t;
end
@@ -125,12 +107,8 @@
t.args.rows = t.args.rows or {}
local i = #t.args.rows + 1
- t.args.rows[i] = {
- data = preprocess( data ),
- label = preprocess( label ),
- rowClass = rowClass,
- class = class
- }
+ t.args.rows[i] =
+ { data = data, label = label, rowClass = rowClass, class =
class }
return t;
end
@@ -152,9 +130,8 @@
t.args.rows = t.args.rows or {}
local i = #t.args.rows + 1
- t.args.rows[i] = {
- wikitext = preprocess( text )
- }
+ t.args.rows[i] =
+ { wikitext = text }
return t
end
@@ -172,11 +149,8 @@
t.args.images = t.args.images or {}
local i = #t.args.images + 1
- t.args.images[i] = {
- image = preprocess( image ),
- caption = preprocess( caption ),
- class = class
- }
+ t.args.images[i] =
+ { image = image, caption = caption, class = class }
return t;
end
@@ -200,12 +174,12 @@
box.args.isSubbox = options.isSubbox and true
-- Title
- box.args.title = preprocess( verifyStringNumNil(
options.title, 'title' ) )
+ box.args.title = verifyStringNumNil( options.title,
'title' )
box.args.titleClass = verifyStringNumNil(
options.titleClass, 'titleClass' )
box.args.titleStyle = verifyStringNumNil(
options.titleStyle, 'titleStyle' )
-- Top text
- box.args.top = preprocess( verifyStringNumNil(
options.top, 'top' ) )
+ box.args.top = verifyStringNumNil( options.top,
'top' )
box.args.topClass = verifyStringNumNil( options.topClass,
'topClass' )
box.args.topStyle = verifyStringNumNil( options.topStyle,
'topStyle' )
@@ -215,7 +189,7 @@
box.args.imageClass = verifyStringNumNil(
options.imageClass, 'imageClass' )
-- Bottom text
- box.args.bottom = preprocess( verifyStringNumNil(
options.bottom, 'bottom' ) )
+ box.args.bottom = verifyStringNumNil( options.bottom,
'bottom' )
box.args.bottomClass = verifyStringNumNil( options.bottomClass,
'bottomClass' )
box.args.bottomStyle = verifyStringNumNil( options.bottomStyle,
'bottomStyle' )
diff --git a/tests/phpunit/output/BasicRowTest.lua
b/tests/phpunit/output/BasicRowTest.lua
index 8e8c7f3..88f10c9 100644
--- a/tests/phpunit/output/BasicRowTest.lua
+++ b/tests/phpunit/output/BasicRowTest.lua
@@ -1,16 +1,9 @@
-local p = {}
+local capiunto = require 'capiunto'
+local box = capiunto.create( {
+ title = 'Infobox Data Test!'
+} )
+box
+ :addHeader( 'A header' )
+ :addRow( 'An item', 'with a value' )
-p.run = function()
- local capiunto = require 'capiunto'
- local box = capiunto.create( {
- title = 'Infobox Data Test!'
- } )
- box
- :addHeader( 'A header' )
- :addRow( 'An item', 'with a value' )
- :addRow( 'Lable', '{{urlencode:This should get processed}}' )
-
- return tostring( box:getHtml() )
-end
-
-return p
+return tostring( box:getHtml() )
diff --git a/tests/phpunit/output/BasicRowTest.php
b/tests/phpunit/output/BasicRowTest.php
index 1d7661f..6e3d7ec 100644
--- a/tests/phpunit/output/BasicRowTest.php
+++ b/tests/phpunit/output/BasicRowTest.php
@@ -1,7 +1,6 @@
<?php
namespace Capiunto\Test;
-use Title;
/**
* A basic Infobox output test
@@ -19,14 +18,13 @@
public function testOutput() {
$engine = $this->getEngine();
- $frame = $engine->getParser()->getPreprocessor()->newFrame();
+ $interpreter = $engine->getInterpreter();
- $title = Title::makeTitle( NS_MODULE, 'RowInfobox' );
- $this->extraModules[ $title->getPrefixedDBkey() ] =
file_get_contents( __DIR__ . '/BasicRowTest.lua' );
+ $lua = file_get_contents( __DIR__ . '/BasicRowTest.lua' );
- $module = $engine->fetchModuleFromParser( $title );
-
- $box = $module->invoke( 'run', $frame->newChild() );
+ list( $box ) = $interpreter->callFunction(
+ $interpreter->loadString( $lua, 'Basic infobox
integration test' )
+ );
$this->assertValidHtmlSnippet( $box );
@@ -42,9 +40,5 @@
"Basic row infobox integration test didn't create
expected html"
);
- $this->assertTrue(
- strpos( $box, "<td>\nThis+should+get+processed</td>" )
!== false,
- 'Arguments should be preprocessed'
- );
}
}
diff --git a/tests/phpunit/output/BasicTest.lua
b/tests/phpunit/output/BasicTest.lua
index 84fd7a2..2c618de 100644
--- a/tests/phpunit/output/BasicTest.lua
+++ b/tests/phpunit/output/BasicTest.lua
@@ -1,17 +1,11 @@
-local p = {}
+local capiunto = require 'capiunto'
+local box = capiunto.create( {
+ name = 'Foo bar',
+ top = 'Text in uppermost cell of infobox',
+} )
-p.run = function()
- local capiunto = require 'capiunto'
- local box = capiunto.create( {
- name = 'Foo bar',
- top = 'Text in uppermost cell of infobox',
- } )
+box
+ :addSubHeader( 'Subheader of the infobox' )
+ :addSubHeader( 'Second subheader of the infobox' )
- box
- :addSubHeader( 'Subheader of the infobox' )
- :addSubHeader( 'Second subheader of the infobox' )
-
- return tostring( box:getHtml() )
-end
-
-return p
+return tostring( box:getHtml() )
diff --git a/tests/phpunit/output/BasicTest.php
b/tests/phpunit/output/BasicTest.php
index beedaf3..ea78541 100644
--- a/tests/phpunit/output/BasicTest.php
+++ b/tests/phpunit/output/BasicTest.php
@@ -1,7 +1,6 @@
<?php
namespace Capiunto\Test;
-use Title;
/**
* A basic Infobox output test
@@ -19,14 +18,13 @@
public function testOutput() {
$engine = $this->getEngine();
- $frame = $engine->getParser()->getPreprocessor()->newFrame();
+ $interpreter = $engine->getInterpreter();
- $title = Title::makeTitle( NS_MODULE, 'BasicTest' );
- $this->extraModules[ $title->getPrefixedDBkey() ] =
file_get_contents( __DIR__ . '/BasicTest.lua' );
+ $lua = file_get_contents( __DIR__ . '/BasicTest.lua' );
- $module = $engine->fetchModuleFromParser( $title );
-
- $box = $module->invoke( 'run', $frame->newChild() );
+ list( $box ) = $interpreter->callFunction(
+ $interpreter->loadString( $lua, 'Basic infobox
integration test' )
+ );
$this->assertValidHtmlSnippet( $box );
--
To view, visit https://gerrit.wikimedia.org/r/163325
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I35c6a2581991137215cf53aaa084a06d2d8e1f1a
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Capiunto
Gerrit-Branch: master
Gerrit-Owner: Jackmcbarn <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits