Paladox has uploaded a new change for review.
https://gerrit.wikimedia.org/r/259277
Change subject: Test
......................................................................
Test
Change-Id: Ied673063f4fe94a44c5d35d3403a9113ef908d9e
---
M docs/RELEASE-NOTES.md
M includes/datavalues/SMW_DV_Record.php
M includes/parserhooks/RecurringEventsParserFunction.php
M includes/parserhooks/SubobjectParserFunction.php
M includes/storage/SMW_ResultArray.php
M languages/SMW_LanguageDe.php
M src/Error.php
M src/Query/Parser/DescriptionProcessor.php
M src/Serializers/QueryResultSerializer.php
A tests/phpunit/Integration/ByJsonScript/Fixtures/p-0302 [#1299,en] failed
subobject.json
A tests/phpunit/Integration/ByJsonScript/Fixtures/p-0409 record in record.json
A tests/phpunit/Integration/ByJsonScript/Fixtures/p-0902 [en] ask and failed
queries.json
R tests/phpunit/Integration/ByJsonScript/Fixtures/q-1104 record type field
property redirect.json
A tests/phpunit/Integration/ByJsonScript/Fixtures/q-1105 named subobject with
record.json
M tests/phpunit/Unit/ErrorTest.php
M tests/phpunit/includes/parserhooks/ShowParserFunctionTest.php
M tests/phpunit/includes/parserhooks/SubobjectParserFunctionTest.php
17 files changed, 421 insertions(+), 32 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticMediaWiki
refs/changes/77/259277/1
diff --git a/docs/RELEASE-NOTES.md b/docs/RELEASE-NOTES.md
index 9dfe8a0..b905512 100644
--- a/docs/RELEASE-NOTES.md
+++ b/docs/RELEASE-NOTES.md
@@ -12,6 +12,7 @@
* #1257 Changed import of recursive annotations (#1068) from the format to a
query level using the `import-annotation` parameter
* #1291 Added support for range queries such as `[[>AAA]] [[<AAD]]`
* #1293 Added `_ERRC` and `_ERRT` as pre-defined properties to aid error
analysis
+* #1299 Added check for named identifier in subobject do not to contain a dot
(`foo.bar` used by extensions)
## Bug fixes
diff --git a/includes/datavalues/SMW_DV_Record.php
b/includes/datavalues/SMW_DV_Record.php
index b4ec178..4e70701 100644
--- a/includes/datavalues/SMW_DV_Record.php
+++ b/includes/datavalues/SMW_DV_Record.php
@@ -1,4 +1,5 @@
<?php
+
/**
* @ingroup SMWDataValues
*/
@@ -81,7 +82,8 @@
$empty = true;
foreach ( $this->getPropertyDataItems() as $diProperty ) {
- if ( !array_key_exists( $valueIndex, $values ) ) {
+
+ if ( !array_key_exists( $valueIndex, $values ) ||
$this->getErrors() !== array() ) {
break; // stop if there are no values left
}
@@ -107,7 +109,7 @@
++$propertyIndex;
}
- if ( $empty ) {
+ if ( $empty && $this->getErrors() === array() ) {
$this->addError( wfMessage( 'smw_novalues' )->text() );
}
@@ -240,6 +242,12 @@
if ( is_null( $this->m_diProperties ) ) {
$this->m_diProperties = self::findPropertyDataItems(
$this->m_property );
+ foreach ( $this->m_diProperties as $property ) {
+ if ( strpos( $property->findPropertyTypeID(),
'_rec' ) !== false ) {
+ $this->addError( wfMessage(
'smw-datavalue-record-invalid-property-declaration', $property->getLabel()
)->text() );
+ }
+ }
+
if ( count( $this->m_diProperties ) == 0 ) { // TODO
internalionalize
$this->addError( 'The list of properties to be
used for the data fields has not been specified properly.' );
}
diff --git a/includes/parserhooks/RecurringEventsParserFunction.php
b/includes/parserhooks/RecurringEventsParserFunction.php
index eb535ab..ac552f7 100644
--- a/includes/parserhooks/RecurringEventsParserFunction.php
+++ b/includes/parserhooks/RecurringEventsParserFunction.php
@@ -71,9 +71,9 @@
// @see
SubobjectParserFunction::addDataValuesToSubobject
// Each new $parameters set will add an additional
subobject
// to the instance
- $this->addDataValuesToSubobject( $parameters );
-
- $this->parserData->getSemanticData()->addSubobject(
$this->subobject );
+ if ( $this->addDataValuesToSubobject( $parameters ) ) {
+
$this->parserData->getSemanticData()->addSubobject( $this->subobject );
+ }
// Collect errors that occurred during processing
$this->messageFormatter->addFromArray(
$this->subobject->getErrors() );
@@ -82,7 +82,9 @@
// Update ParserOutput
$this->parserData->pushSemanticDataToParserOutput();
- return $this->messageFormatter->getHtml();
+ return $this->messageFormatter
+ ->addFromArray( $this->parserData->getErrors() )
+ ->getHtml();
}
}
diff --git a/includes/parserhooks/SubobjectParserFunction.php
b/includes/parserhooks/SubobjectParserFunction.php
index 0d7558e..8d36330 100644
--- a/includes/parserhooks/SubobjectParserFunction.php
+++ b/includes/parserhooks/SubobjectParserFunction.php
@@ -90,12 +90,11 @@
*/
public function parse( ParserParameterProcessor $parameters ) {
- $this->addDataValuesToSubobject( $parameters );
-
- if ( !$this->subobject->getSemanticData()->isEmpty() ) {
+ if ( $this->addDataValuesToSubobject( $parameters ) &&
!$this->subobject->getSemanticData()->isEmpty() ) {
$this->parserData->getSemanticData()->addSubobject(
$this->subobject );
- $this->parserData->pushSemanticDataToParserOutput();
}
+
+ $this->parserData->pushSemanticDataToParserOutput();
return $this->messageFormatter
->addFromArray( $this->subobject->getErrors() )
@@ -108,7 +107,20 @@
$subject = $this->parserData->getSemanticData()->getSubject();
- $this->subobject->setEmptyContainerForId(
$this->createSubobjectId( $parameters ) );
+ // Named subobjects containing a "." in the first five
characters are reserved to be
+ // used by extensions only in order to separate them from user
land and avoid them
+ // accidentally to refer to the same named ID
+ // (i.e. different access restrictions etc.)
+ if ( strpos( mb_substr( $parameters->getFirst(), 0, 5 ), '.' )
!== false ) {
+ return $this->addErrorWithMsg(
+ $subject,
+ wfMessage(
'smw-subobject-parser-invalid-naming-scheme', $parameters->getFirst()
)->escaped()
+ );
+ }
+
+ $this->subobject->setEmptyContainerForId(
+ $this->createSubobjectId( $parameters )
+ );
foreach ( $this->transformParametersToArray( $parameters ) as
$property => $values ) {
@@ -132,6 +144,8 @@
$this->subobject->addDataValue( $dataValue );
}
}
+
+ return true;
}
private function createSubobjectId( ParserParameterProcessor
$parameters ) {
@@ -159,4 +173,21 @@
return $parameters->toArray();
}
+ private function addErrorWithMsg( $subject, $errorMsg ) {
+
+ $error = new Error( $subject );
+
+ $this->parserData->getSemanticData()->addPropertyObjectValue(
+ $error->getProperty(),
+ $error->getContainerFor(
+ new DIProperty( '_SOBJ' ),
+ $errorMsg
+ )
+ );
+
+ $this->parserData->addError( $errorMsg );
+
+ return false;
+ }
+
}
diff --git a/includes/storage/SMW_ResultArray.php
b/includes/storage/SMW_ResultArray.php
index 5e7b5ae..14bbaf3 100644
--- a/includes/storage/SMW_ResultArray.php
+++ b/includes/storage/SMW_ResultArray.php
@@ -140,8 +140,9 @@
if ( $di === false ) {
return false;
}
+
if ( $this->mPrintRequest->getMode() ==
PrintRequest::PRINT_PROP &&
- $this->mPrintRequest->getTypeID() == '_rec' &&
+ strpos( $this->mPrintRequest->getTypeID(), '_rec' ) !==
false &&
$this->mPrintRequest->getParameter( 'index' ) !== false ) {
// Not efficient, but correct: we need to find the
right property for
// the selected index of the record here.
@@ -224,7 +225,7 @@
// Print one component of a multi-valued string.
// Known limitation: the printrequest still is
of type _rec, so if printers check
// for this then they will not recognize that
it returns some more concrete type.
- if ( ( $this->mPrintRequest->getTypeID() ==
'_rec' ) &&
+ if ( strpos( $this->mPrintRequest->getTypeID(),
'_rec' ) !== false &&
( $this->mPrintRequest->getParameter(
'index' ) !== false ) ) {
$pos =
$this->mPrintRequest->getParameter( 'index' ) - 1;
$newcontent = array();
diff --git a/languages/SMW_LanguageDe.php b/languages/SMW_LanguageDe.php
index 36df772..b101992 100644
--- a/languages/SMW_LanguageDe.php
+++ b/languages/SMW_LanguageDe.php
@@ -85,8 +85,8 @@
'_ASKDU'=> 'Abfragedauer',
'_MEDIA'=> 'Medientyp',
'_MIME' => 'MIME-Typ',
- '_ERRC' => 'Has processing error',
- '_ERRT' => 'Has processing error text'
+ '_ERRC' => 'Verarbeitungsfehler',
+ '_ERRT' => 'Verarbeitungsfehlerhinweis'
);
protected $m_SpecialPropertyAliases = array(
diff --git a/src/Error.php b/src/Error.php
index be2dbb4..7a3c72e 100644
--- a/src/Error.php
+++ b/src/Error.php
@@ -51,14 +51,21 @@
$property = new DIProperty( $property->getKey() );
}
- $subWikiPage = new DIWikiPage(
+ $errorMsg = is_array( $errorMsg ) ? implode( ' ', $errorMsg ) :
$errorMsg;
+
+ $subject = new DIWikiPage(
$this->subject->getDBkey(),
$this->subject->getNamespace(),
$this->subject->getInterwiki(),
- '_ERR' . md5( $property !== null ? $property->getKey()
: 'UNKNOWN' )
+ '_ERR' . md5( ( $property !== null ?
$property->getKey() : 'UNKNOWN' ) . $errorMsg )
);
- $containerSemanticData = new ContainerSemanticData(
$subWikiPage );
+ // Encode brackets to avoid an annotion is created/included
+ return $this->newDiContainer( $subject, $property, str_replace(
'[', '[', $errorMsg ) );
+ }
+
+ private function newDiContainer( $subject, $property, $errorMsg ) {
+ $containerSemanticData = new ContainerSemanticData( $subject );
if ( $property !== null ) {
$containerSemanticData->addPropertyObjectValue(
@@ -66,8 +73,6 @@
$property->getDiWikiPage()
);
}
-
- $errorMsg = is_array( $errorMsg ) ? implode( ' ', $errorMsg ) :
$errorMsg;
$containerSemanticData->addPropertyObjectValue(
new DIProperty( '_ERRT' ),
diff --git a/src/Query/Parser/DescriptionProcessor.php
b/src/Query/Parser/DescriptionProcessor.php
index 9f98036..de12217 100644
--- a/src/Query/Parser/DescriptionProcessor.php
+++ b/src/Query/Parser/DescriptionProcessor.php
@@ -85,7 +85,7 @@
array_shift( $params );
$message = new \Message( $msgKey, $params );
- $this->addError( str_replace( array( '[' ), array( ':' ),
$message->inContentLanguage()->text() ) );
+ $this->addError( str_replace( array( '[' ), array( '['
), $message->inContentLanguage()->text() ) );
}
/**
@@ -125,11 +125,8 @@
$dataValue = $this->dataValueFactory->newTypeIDValue( '_wpg',
'QP_WPG_TITLE' );
$description = null;
- if ( $dataValue->isValid() ) {
- $description = $dataValue->getQueryDescription( $chunk
);
- } else {
- $this->addError( $dataValue->getErrors() );
- }
+ $description = $dataValue->getQueryDescription( $chunk );
+ $this->addError( $dataValue->getErrors() );
return $description;
}
diff --git a/src/Serializers/QueryResultSerializer.php
b/src/Serializers/QueryResultSerializer.php
index e6c20f2..44e6f6c 100644
--- a/src/Serializers/QueryResultSerializer.php
+++ b/src/Serializers/QueryResultSerializer.php
@@ -69,7 +69,7 @@
case DataItem::TYPE_WIKIPAGE:
// Support for a deserializable _rec type with
0.6
- if ( $printRequest !== null &&
$printRequest->getTypeID() === '_rec' ) {
+ if ( $printRequest !== null && strpos(
$printRequest->getTypeID(), '_rec' ) !== false ) {
$recordValue =
DataValueFactory::getInstance()->newDataItemValue(
$dataItem,
$printRequest->getData()->getDataItem()
diff --git "a/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0302
\133\0431299,en\135 failed subobject.json"
"b/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0302 \133\0431299,en\135
failed subobject.json"
new file mode 100644
index 0000000..19b7b46
--- /dev/null
+++ "b/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0302
\133\0431299,en\135 failed subobject.json"
@@ -0,0 +1,87 @@
+{
+ "description": "Subobjects to fail, #1299",
+ "properties": [
+ {
+ "name": "Has page",
+ "contents": "[[Has type::Page]]"
+ }
+ ],
+ "subjects": [
+ {
+ "name": "Example/P0302/1",
+ "contents": "{{#subobject:abc.name
|@category=ABC;123|+sep=;}}"
+ },
+ {
+ "name": "Example/P0302/2",
+ "contents": "{{#subobject:|Modification date= 1 Jan
1970 }}"
+ },
+ {
+ "name": "Example/P0302/3",
+ "contents": "{{#subobject:|Date= InvalidValue }}"
+ },
+ {
+ "name": "Example/P0302/4",
+ "contents":
"{{#set_recurring_event:some.foo|property=Has date |start=June 8, 2010
|unit=day |period=1 |limit=10 }}"
+ }
+ ],
+ "parser-testcases": [
+ {
+ "about": "#0 dot scheme not permitted for user-defined
named identifiers",
+ "subject": "Example/P0302/1",
+ "store": {
+ "semantic-data": {
+ "strict-mode-valuematch": false,
+ "propertyCount": 3,
+ "propertyKeys": [ "_ERRC", "_SKEY",
"_MDAT" ],
+ "propertyValues": []
+ }
+ }
+ },
+ {
+ "about": "#1 restricted property",
+ "subject":
"Example/P0302/2#_a0017273b0d05dedf1e2ca22e2035490",
+ "store": {
+ "semantic-data": {
+ "strict-mode-valuematch": false,
+ "propertyCount": 2,
+ "propertyKeys": [ "_ERRC", "_SKEY" ],
+ "propertyValues": []
+ }
+ }
+ },
+ {
+ "about": "#2 invalid value",
+ "subject":
"Example/P0302/3#_d1e1d8ef8b81b9275dee98ab6795b179",
+ "store": {
+ "semantic-data": {
+ "strict-mode-valuematch": false,
+ "propertyCount": 2,
+ "propertyKeys": [ "_ERRC", "_SKEY" ],
+ "propertyValues": []
+ }
+ }
+ },
+ {
+ "about": "#3 recurring events invalid name",
+ "subject": "Example/P0302/4",
+ "store": {
+ "semantic-data": {
+ "strict-mode-valuematch": false,
+ "propertyCount": 3,
+ "propertyKeys": [ "_ERRC", "_SKEY",
"_MDAT" ],
+ "propertyValues": []
+ }
+ }
+ }
+ ],
+ "settings": {
+ "wgContLang": "en",
+ "wgLang": "en",
+ "smwgPageSpecialProperties": [ "_MDAT" ]
+ },
+ "meta": {
+ "version": "0.1",
+ "is-incomplete": false,
+ "debug": false
+ }
+}
\ No newline at end of file
diff --git a/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0409 record in
record.json b/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0409 record in
record.json
new file mode 100644
index 0000000..17de552
--- /dev/null
+++ b/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0409 record in
record.json
@@ -0,0 +1,67 @@
+{
+ "description": "Record in record is not permitted",
+ "properties": [
+ {
+ "name": "Has text",
+ "contents": "[[Has type::Text]]"
+ },
+ {
+ "name": "Has number",
+ "contents": "[[Has type::Number]]"
+ },
+ {
+ "name": "Has record one",
+ "contents": "[[Has type::Record]] [[Has fields::Has
text;Has number]]"
+ },
+ {
+ "name": "Has record two",
+ "contents": "[[Has type::Record]] [[Has fields::Has
text;Has record one]]"
+ }
+ ],
+ "subjects": [
+ {
+ "name": "Example/P0409/1",
+ "contents": "[[Has record two::Foo;abc;12]]"
+ },
+ {
+ "name": "Example/P0409/2",
+ "contents": "{{#subobject: |Has record two=Foo;abc;12
}}"
+ }
+ ],
+ "parser-testcases": [
+ {
+ "about": "#0 no exception just a plain error message",
+ "subject": "Example/P0409/1",
+ "store": {
+ "semantic-data": {
+ "strict-mode-valuematch": false,
+ "propertyCount": 3,
+ "propertyKeys": [ "_ERRC", "_SKEY",
"_MDAT" ],
+ "propertyValues": []
+ }
+ }
+ },
+ {
+ "about": "#1 no exception just a plain error message",
+ "subject":
"Example/P0409/2#_679c1c67364994d58c9d9e51bbdfc026",
+ "store": {
+ "semantic-data": {
+ "strict-mode-valuematch": false,
+ "propertyCount": 2,
+ "propertyKeys": [ "_ERRC", "_SKEY" ],
+ "propertyValues": []
+ }
+ }
+ }
+ ],
+ "settings": {
+ "wgContLang": "en",
+ "wgLang": "en"
+ },
+ "meta": {
+
+ "version": "0.1",
+ "is-incomplete": false,
+ "debug": false
+ }
+}
\ No newline at end of file
diff --git "a/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0902 \133en\135
ask and failed queries.json"
"b/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0902 \133en\135 ask and
failed queries.json"
new file mode 100644
index 0000000..b3e614e
--- /dev/null
+++ "b/tests/phpunit/Integration/ByJsonScript/Fixtures/p-0902 \133en\135 ask
and failed queries.json"
@@ -0,0 +1,47 @@
+{
+ "description": "Move/redirect output",
+ "properties": [
+ {
+ "name": "HasPropertyForMove",
+ "contents": "[[Has type::Page]]"
+ }
+ ],
+ "subjects": [
+ {
+ "name": "Example/P0902/1",
+ "contents": "{{#ask:[[Help:]] |format=ul |link=none
|headers=show }}"
+ }
+ ],
+ "parser-testcases": [
+ {
+ "about": "#0 failed NS query",
+ "subject": "Example/P0902/1",
+ "store": {
+ "semantic-data": {
+ "strict-mode-valuematch": false,
+ "propertyCount": 4,
+ "propertyKeys": [ "_MDAT", "_SKEY",
"_ASK", "_ERRC" ]
+ }
+ },
+ "expected-output": {
+ "to-contain": [
+ ">"Help:" cannot be used as a
page name in this wiki."
+ ]
+ }
+ }
+ ],
+ "settings": {
+ "wgContLang": "en",
+ "wgLang": "en",
+ "smwgPageSpecialProperties": [ "_MDAT" ],
+ "smwgNamespacesWithSemanticLinks": {
+ "NS_MAIN": true,
+ "SMW_NS_PROPERTY": true
+ }
+ },
+ "meta": {
+ "version": "0.1",
+ "is-incomplete": false,
+ "debug": false
+ }
+}
\ No newline at end of file
diff --git a/tests/phpunit/Integration/ByJsonScript/Fixtures/q-1103 record type
field property redirect.json
b/tests/phpunit/Integration/ByJsonScript/Fixtures/q-1104 record type field
property redirect.json
similarity index 100%
rename from tests/phpunit/Integration/ByJsonScript/Fixtures/q-1103 record type
field property redirect.json
rename to tests/phpunit/Integration/ByJsonScript/Fixtures/q-1104 record type
field property redirect.json
diff --git a/tests/phpunit/Integration/ByJsonScript/Fixtures/q-1105 named
subobject with record.json
b/tests/phpunit/Integration/ByJsonScript/Fixtures/q-1105 named subobject with
record.json
new file mode 100644
index 0000000..6ba9578
--- /dev/null
+++ b/tests/phpunit/Integration/ByJsonScript/Fixtures/q-1105 named subobject
with record.json
@@ -0,0 +1,68 @@
+{
+ "description": "_rec / subobject / T49472",
+ "properties": [
+ {
+ "name": "Has text",
+ "contents": "[[Has type::Text]]"
+ },
+ {
+ "name": "Has number",
+ "contents": "[[Has type::Number]]"
+ },
+ {
+ "name": "Has record text",
+ "contents": "[[Has type::Record]] [[Has fields::Has
text;Has number]]"
+ }
+ ],
+ "subjects": [
+ {
+ "name": "Example/Q1105/1",
+ "contents": "{{#subobject: Test|Has text=Foo|Has record
text=abc;123}} {{#subobject: Test|Has text=Bar}}"
+ },
+ {
+ "name": "Example/Q1105/2",
+ "contents": "{{#subobject: Test|Has text=Bar}}
{{#subobject: Test|Has text=Foo|Has record text=abc;456}}"
+ }
+ ],
+ "query-testcases": [
+ {
+ "about": "#0 declaration order does not matter (oppose
to T49472)",
+ "store" : {
+ "clear-cache" : true
+ },
+ "condition": "[[Has record text::abc;?]]",
+ "printouts" : [ "Has record text" ],
+ "parameters" : {
+ "limit" : "10"
+ },
+ "queryresult": {
+ "count": 2,
+ "results": [
+ "Example/Q1105/1#0##Test",
+ "Example/Q1105/2#0##Test"
+ ],
+ "datavalues": [
+ {
+ "property": "Has record text",
+ "value": "abc;123"
+ },
+ {
+ "property": "Has record text",
+ "value": "abc;456"
+ }
+ ]
+ }
+ }
+ ],
+ "settings": {
+ "smwStrictComparators": false,
+ "wgContLang": "en",
+ "wgLang": "en"
+ },
+ "meta": {
+
+ "version": "0.1",
+ "is-incomplete": false,
+ "debug": false
+ }
+}
\ No newline at end of file
diff --git a/tests/phpunit/Unit/ErrorTest.php b/tests/phpunit/Unit/ErrorTest.php
index 926ed11..eecbcbd 100644
--- a/tests/phpunit/Unit/ErrorTest.php
+++ b/tests/phpunit/Unit/ErrorTest.php
@@ -104,4 +104,36 @@
);
}
+ public function testErrorContainerForSamePropertyAndMsg() {
+
+ $instance = new Error( DIWikiPage::newFromText( 'Foo' ) );
+ $property = new DIProperty( 'Foo' );
+
+ $container = $instance->getContainerFor(
+ $property,
+ array( 'Some error' )
+ );
+
+ $this->assertSame(
+ $container->getHash(),
+ $instance->getContainerFor( $property, array( 'Some
error' ) )->getHash()
+ );
+ }
+
+ public function testErrorContainerForSamePropertyButDifferentMsg() {
+
+ $instance = new Error( DIWikiPage::newFromText( 'Foo' ) );
+ $property = new DIProperty( 'Foo' );
+
+ $container = $instance->getContainerFor(
+ $property,
+ array( 'Some error' )
+ );
+
+ $this->assertNotSame(
+ $container->getHash(),
+ $instance->getContainerFor( $property, array(
'Different error' ) )->getHash()
+ );
+ }
+
}
diff --git a/tests/phpunit/includes/parserhooks/ShowParserFunctionTest.php
b/tests/phpunit/includes/parserhooks/ShowParserFunctionTest.php
index bda6481..536a945 100644
--- a/tests/phpunit/includes/parserhooks/ShowParserFunctionTest.php
+++ b/tests/phpunit/includes/parserhooks/ShowParserFunctionTest.php
@@ -213,9 +213,18 @@
'propertyKeys' => array( '_ERRP', '_ERRT' ),
);
+ $errorID = null;
+
+ foreach ( $parserData->getSemanticData()->getSubSemanticData()
as $subSemanticData ) {
+ if ( strpos(
$subSemanticData->getSubject()->getSubobjectName(), '_ERR' ) !== false ) {
+ $errorID =
$subSemanticData->getSubject()->getSubobjectName();
+ break;
+ }
+ }
+
$this->semanticDataValidator->assertThatPropertiesAreSet(
$expected,
- $parserData->getSemanticData()->findSubSemanticData(
'_ERR6fd39e1d9c9c36a9cf917bdb3d80e0fb' )
+ $parserData->getSemanticData()->findSubSemanticData(
$errorID )
);
}
diff --git a/tests/phpunit/includes/parserhooks/SubobjectParserFunctionTest.php
b/tests/phpunit/includes/parserhooks/SubobjectParserFunctionTest.php
index 0f7e3b1..9462d83 100644
--- a/tests/phpunit/includes/parserhooks/SubobjectParserFunctionTest.php
+++ b/tests/phpunit/includes/parserhooks/SubobjectParserFunctionTest.php
@@ -83,10 +83,12 @@
$instance = $this->acquireInstance( $subobject );
$instance->parse( new ParserParameterFormatter( $parameters ) );
- $this->assertContains(
- $expected['identifier'],
- $subobject->getSubobjectId()
- );
+ if ( $expected['identifier'] !== null ) {
+ $this->assertContains(
+ $expected['identifier'],
+ $subobject->getSubobjectId()
+ );
+ }
}
/**
@@ -365,6 +367,38 @@
)
);
+ // Has dot restriction
+ #10 {{#subobject:foo.bar
+ // |Bar=foo Bar
+ // |Date=Foo
+ // }}
+ $provider[] = array(
+ array( 'foo.bar', 'Date=Foo' ),
+ array(
+ 'hasErrors' => true,
+ 'identifier' => null,
+ 'strict-mode-valuematch' => false,
+ 'propertyCount' => 1,
+ 'propertyKeys' => array( '_ERRC' )
+ )
+ );
+
+ // Not dot restriction
+ #11 {{#subobject:foobar.bar
+ // |Bar=foo Bar
+ // }}
+ $provider[] = array(
+ array( 'foobar.bar', 'Bar=foo Bar' ),
+ array(
+ 'hasErrors' => false,
+ 'identifier' => 'foobar.bar',
+ 'strict-mode-valuematch' => false,
+ 'propertyCount' => 1,
+ 'propertyKeys' => array( 'Bar' ),
+ 'propertyValues' => array( 'Foo Bar' )
+ )
+ );
+
return $provider;
}
--
To view, visit https://gerrit.wikimedia.org/r/259277
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ied673063f4fe94a44c5d35d3403a9113ef908d9e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticMediaWiki
Gerrit-Branch: master
Gerrit-Owner: Paladox <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits