Bug #36644

Invalid variable type during PHP-peg parsing

Added by Adrian Föder over 9 years ago. Updated over 9 years ago.

Status:
Resolved
Priority:
Must have
Target version:
-
Start date:
2012-04-27
Due date:
% Done:

100%

Estimated time:

Description

during processing, in php-peg\Parser.php there' the following lines of code:

    function store(&$result, $subres, $storetag = NULL) {
        $result['text'] .= $subres['text'];

a var_dump of the $subres variable has the following ouput ending:

(...many similar arrays)

array(4) {
  ["_matchrule"]=>
  string(11) "Disjunction" 
  ["name"]=>
  string(11) "Disjunction" 
  ["text"]=>
  string(47) "context.children(this.getNodePath()).children()" 
  ["code"]=>
  string(164) "$context->getAndWrap('context')->callAndWrap('children', array($context->getAndWrap('this')->callAndWrap('getNodePath', array())))->callAndWrap('children', array())" 
}
array(3) {
  ["_matchrule"]=>
  string(10) "Identifier" 
  ["name"]=>
  string(10) "Identifier" 
  ["text"]=>
  string(6) "teaser" 
}
string(6) "teaser" 

(end of processing)

you see, the last occurence is a string; maybe due to a recursive call to the preceding Identifier/teaser thing.

Due to the fact $subres is in the very last case a string, $subres['text'] finally results in

<!-- Exception while rendering page&lt;TYPO3.TYPO3:Page&gt;/body&lt;TYPO3.TypoScript:FluidRenderer&gt;/sections/teaser : Warning: Illegal string offset 'text' in C:\Users\afoeder\FLOW3\Flow3Org\Packages\Application\TYPO3.Eel\Resources\Private\PHP\php-peg\Parser.php line 171 -->

This kind of warning seems to be a PHP 5.4 issue only, but it's logically incorrect however.

#1

Updated by Christopher Hlubek over 9 years ago

  • Status changed from New to Accepted
  • Assignee set to Christopher Hlubek
#2

Updated by Peter Niederlag over 9 years ago

    function store(&$result, $subres, $storetag = NULL) {
        if (isset($result['text']) && isset($subres['text'])) { 
            $result['text'] .= $subres['text'];
        } else {
            //var_dump($result);
            var_dump($subres);
            die('fehler');
            return;
        }

reveales:

string 'secondary' (length=9)

for me (php 5.4.x)

#3

Updated by Gerrit Code Review over 9 years ago

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/12232

#4

Updated by Christopher Hlubek over 9 years ago

  • Status changed from Accepted to Under Review
  • Assignee changed from Christopher Hlubek to Sebastian Kurfuerst

Looks like this is caused by the Fizzle Grammar that stores an expression result as a string and not an array (which is expected by php-peg). I fixed that by using ab array for the expression result.

Sebastian Kurfuerst: Maybe you can quickly review the change. Unit tests and functional tests pass for me.

#5

Updated by Gerrit Code Review over 9 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/12232

#6

Updated by Gerrit Code Review over 9 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/12232

#7

Updated by Christopher Hlubek over 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF