Bug #36644

Invalid variable type during PHP-peg parsing

Added by Adrian Föder over 3 years ago. Updated about 3 years ago.

Status:Resolved Start date:2012-04-27
Priority:Must have Due date:
Assigned To:Sebastian Kurfuerst % Done:

100%

Category:-
Target version:-

Description

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

1    function store(&$result, $subres, $storetag = NULL) {
2        $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

1<!-- 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.

Associated revisions

Revision 0e3cb904
Added by Christopher Hlubek about 3 years ago

[BUGFIX] Fix Fizzle grammar string offset access

The Fizzle grammar used a string for the result of a parsing expression
which caused a notice in the packrat implementation of php-peg with
PHP 5.4. This change fixes this to use an array for the result.

Change-Id: I8087c959f96b84daa6ff2e0ae6f7cdc4a1b0db5d
Resolves: #36644

History

#1 Updated by Christopher Hlubek over 3 years ago

  • Status changed from New to Accepted
  • Assigned To set to Christopher Hlubek

#2 Updated by Peter Niederlag about 3 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 about 3 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 about 3 years ago

  • Status changed from Accepted to Under Review
  • Assigned To 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: Maybe you can quickly review the change. Unit tests and functional tests pass for me.

#5 Updated by Gerrit Code Review about 3 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 about 3 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 about 3 years ago

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

Also available in: Atom PDF