Project

General

Profile

Actions

Bug #61256

closed

parseUserFuncArguments getting no single arguments to user_functions in conditions

Added by Michael Finkenthei over 9 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Could have
Assignee:
-
Category:
TypoScript
Target version:
-
Start date:
2014-08-28
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.4
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Example: installed version 1.0.0 of extension rgnewsimg, Typo3 6.2.4 on PHP 5.4.31 (ubuntu 12.4)
Typoscript code, as per extension manual, which is working fine with prior versions of Typo3 up to 6.1.7 . :

includeLibs.rgnewsimg = EXT:rgnewsimg/condition.php
[userFunc = user_rgnewsimg(0)]
...
[global]
[userFunc = user_rgnewsimg(1)]
...
[global]

Frontend Result is an Exception:

11 TYPO3\CMS\Core\Error\ErrorHandler::handleError(2, "Missing argument 1 for user_rgnewsimg()", "/httpdocs/typo3conf/ext/rgnewsimg/condition.php", 31, array)
10 user_rgnewsimg()
9 call_user_func_array("user_rgnewsimg", array)
8 TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::evaluateConditionCommon("userFunc", "user_rgnewsimg(0)")
...

Workaround:

Typoscript code:

includeLibs.rgnewsimg = EXT:rgnewsimg/condition.php
[userFunc = user_rgnewsimg(0,0)]

...
[global]
[userFunc = user_rgnewsimg(1,1)]
...
[global]

does work, so if more than one argument is given, only the 2nd and following are delivered to the user_function.


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #68132: It's not possible to use 0 as a TypoScript userfunc argumentClosedSascha Egerer2015-07-14

Actions
Has duplicate TYPO3 Core - Bug #61254: parseUserFuncArguments getting no single arguments to user_functions in conditions Closed2014-08-28

Actions
Actions #1

Updated by Markus Klein over 9 years ago

Any reason why you assigned Georg here?

Actions #2

Updated by Michael Finkenthei over 9 years ago

Nothing specific - he just wrote the cited extension rgnewsimg, and is a member of the core team, so I thought he might be interested.
Please feel free to assign it to anyone who might be interested.

By the way, this is my first time using this bugtracker, and I feel a bit clumsy about it - sorry for the duplicate.

Actions #3

Updated by Georg Ringer almost 9 years ago

  • Assignee deleted (Georg Ringer)
Actions #4

Updated by Markus Klein almost 9 years ago

  • Description updated (diff)
  • Status changed from New to Needs Feedback
Actions #5

Updated by Markus Klein almost 9 years ago

Is this still an issue?

We have unittests for those conditions and those seem to work fine without any warnings.

Actions #6

Updated by Michael Finkenthei almost 9 years ago

I just tested with php 5.5.9, TYPO3 6.2.12, tt_news 3.6.0 and yes, sorry, but still the same.

Actions #7

Updated by Markus Klein almost 9 years ago

Thanks for the fast response. I will take a look.

Actions #8

Updated by Markus Klein almost 9 years ago

Your TS example seems wrong

includeLibs.rgnewsimg = EXT:rgnewsimg/condition.php
[userFunc = user_rgnewsimg(0,0)]

includeLibs is loaded after the userFunc is called, hence this will result in FALSE due to the function not being defined at all.

You need to define the userFunc in a place, which is loaded before the TypoScript is executed.
The example in the docs [1] uses AdditionalConfiguration.php for that.

Since your userFunc is obviously executed, I suspect it is loaded in some other place already, eg ext_localconf.php of the extension.

I'm not able to reproduce your error though.

[1] http://docs.typo3.org/typo3cms/TyposcriptReference/Conditions/Reference/Index.html#id70

Actions #9

Updated by Michael Finkenthei almost 9 years ago

Markus Klein wrote:

includeLibs is loaded after the userFunc is called, hence this will result in FALSE due to the function not being defined at all.

You need to define the userFunc in a place, which is loaded before the TypoScript is executed.

Thanks for the hint, I just commented out the includeLibs line in the main typoscript template, which is where my code above comes from.
You were right, condition.php ist already required by ext_localconf.php of the extension. Which is loaded before the typoscript setup is executed, as "static template files are always included before this template" (per the last option on tab "Enthält").

user_rgnewsimg reads only one argument. Still, the funny effect we 're talking about exists.

I'm not able to reproduce your error though.

Well, I can reproduce it, i just don't understand why. :-)

[1] http://docs.typo3.org/typo3cms/TyposcriptReference/Conditions/Reference/Index.html#id70

I do think I've grasped this.

Maybe I should post the complete error trace:

Uncaught TYPO3 Exception
#1: PHP Warning: Missing argument 1 for user_rgnewsimg() in /srv/www/vhosts/kluetz/httpdocs/typo3conf/ext/rgnewsimg/condition.php line 31 (More information)

TYPO3\CMS\Core\Error\Exception thrown in file
/srv/www/sources/typo3_src-6.2.12/typo3/sysext/core/Classes/Error/ErrorHandler.php in line 101.

11 TYPO3\CMS\Core\Error\ErrorHandler::handleError(2, "Missing argument 1 for user_rgnewsimg()", "/srv/www/vhosts/kluetz/httpdocs/typo3conf/ext/rgnewsimg/condition.php", 31, array)

/srv/www/vhosts/site1/httpdocs/typo3conf/ext/rgnewsimg/condition.php:

00029:  */
00030:  

00031:   function user_rgnewsimg($cmd) {

00032: 
00033:   $vars = t3lib_div::_GET('tx_ttnews');

10 user_rgnewsimg()

9 call_user_func_array("user_rgnewsimg", array)

/srv/www/sources/typo3_src-6.2.12/typo3/sysext/core/Classes/Configuration/TypoScript/ConditionMatching/AbstractConditionMatcher.php:

00409:     $funcName = $matches[1][0];
00410:     $funcValues = $matches[2][0] ? $this->parseUserFuncArguments($matches[2][0]) : array();

00411:     if (is_callable($funcName) && call_user_func_array($funcName, $funcValues)) {

00412:      return TRUE;
00413:     }

8 TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::evaluateConditionCommon("userFunc", "user_rgnewsimg(0)")

/srv/www/sources/typo3_src-6.2.12/typo3/sysext/frontend/Classes/Configuration/TypoScript/ConditionMatching/ConditionMatcher.php:

00033:  protected function evaluateCondition($string) {
00034:   list($key, $value) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('=', $string, FALSE, 2);

00035:   $result = parent::evaluateConditionCommon($key, $value);

00036:   if (is_bool($result)) {
00037:    return $result;

7 TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher::evaluateCondition("userFunc = user_rgnewsimg(0)")

/srv/www/sources/typo3_src-6.2.12/typo3/sysext/core/Classes/Configuration/TypoScript/ConditionMatching/AbstractConditionMatcher.php:

00172:     $andParts = explode(']&&[', $orPart);
00173:     foreach ($andParts as $andPart) {

00174:      $result = $this->evaluateCondition($andPart);

00175:      // If condition in AND context fails, the whole block is FALSE:
00176:      if ($result === FALSE) {

6 TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::match("[userFunc = user_rgnewsimg(0)]")

/srv/www/sources/typo3_src-6.2.12/typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php:

00233:      $this->sections[md5($pre)] = $pre;
00234:     }

00235:     if (is_object($matchObj) && $matchObj->match($pre) || $this->syntaxHighLight) {

00236:      if ($specificSection) {
00237:       $this->sectionsMatch[md5($pre)] = $pre;

5 TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::parse("↵[GLOBAL]↵↵↵[GLOBAL]↵#############################…5127352673445009204" rel="publisher">Google+</a>        ", TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher)

/srv/www/sources/typo3_src-6.2.12/typo3/sysext/core/Classes/TypoScript/TemplateService.php:

00997:   }
00998:   // Finally parse the Setup field TypoScript code (where constants are now substituted)

00999:   $config->parse($all, $matchObj);

01000:   // Read out parse errors if any
01001:   $this->parserErrors['config'] = $config->errors;

4 TYPO3\CMS\Core\TypoScript\TemplateService::generateConfig()

/srv/www/sources/typo3_src-6.2.12/typo3/sysext/core/Classes/TypoScript/TemplateService.php:

00496: 
00497:     // Make configuration

00498:     $this->generateConfig();

00499:     // This stores the template hash thing
00500:     $cc = array();

3 TYPO3\CMS\Core\TypoScript\TemplateService::start(array)

/srv/www/sources/typo3_src-6.2.12/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php:

02559:    $this->tmpl->forceTemplateParsing = $this->forceTemplateParsing;
02560:    // Start parsing the TS template. Might return cached version.

02561:    $this->tmpl->start($this->rootLine);

02562:    $GLOBALS['TT']->pull();
02563:    if ($this->tmpl->loaded) {

2 TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::getConfigArray()

/srv/www/sources/typo3_src-6.2.12/typo3/sysext/cms/tslib/index_ts.php:

00171: // Get config if not already gotten
00172: // After this, we should have a valid config-array ready

00173: $TSFE->getConfigArray();

00174: // Setting language and locale
00175: $TT->push('Setting language and locale', '');

1 require("/srv/www/sources/typo3_src-6.2.12/typo3/sysext/cms/tslib/index_ts.php")

/srv/www/sources/typo3_src-6.2.12/index.php:

00026:  ->redirectToInstallerIfEssentialConfigurationDoesNotExist();
00027: 

00028: require(PATH_tslib . 'index_ts.php');

Actions #10

Updated by Sascha Egerer almost 9 years ago

  • Assignee set to Michael Finkenthei

Is that issue fixed by #68132?

Actions #11

Updated by Alexander Opitz over 8 years ago

  • Status changed from Needs Feedback to Closed
  • Assignee deleted (Michael Finkenthei)
  • Priority changed from -- undefined -- to Could have

No feedback within the last 90 days => closing this issue.

If you think that this is the wrong decision or experience this issue again, then please write to the mailing list typo3.teams.bugs with issue number and an explanation or open a new ticket and add a relation to this ticket number.

Actions

Also available in: Atom PDF