Bug #53573

FormDataTraverser::getFieldValueRecursive() might return NULL

Added by Markus Klein over 6 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Could have
Assignee:
-
Category:
Backend API
Target version:
Start date:
2013-11-12
Due date:
% Done:

100%

TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
easy
Is Regression:
No
Sprint Focus:

Description

This can cause WARNINGS in LanguageService, because of the calls in FormEngine::getPlaceholderValue.

Either check the $value in FormEngine::getPlaceholderAttribute() or ensure getFieldValueRecursive() behaves like documented and not returning NULL.


Related issues

Related to TYPO3 Core - Bug #52630: PlaceHolder Feature in TCEforms only works on first relation level Closed 2013-11-13 2013-11-13
Related to TYPO3 Core - Bug #53594: No placeholder attribute in backend forms Closed 2013-11-13

Associated revisions

Revision be3712e8 (diff)
Added by Oliver Hader over 6 years ago

[TASK] FormDataTraverser::getFieldValueRecursive() might return NULL

FormDataTraverser::getFieldValueRecursive() might return NULL or
any other type as well, as it has been provided by the database.
Thus, PHPdoc comments are modified to reflect the possible return
values as well.

Fixes: #53573
Releases: 6.2
Change-Id: Idcdbe21ccdcf694b8ceb5ecf0b4a192ad51c4871
Reviewed-on: https://review.typo3.org/25366
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn

History

#1 Updated by Oliver Hader over 6 years ago

  • Target version changed from next-patchlevel to 6.2.0

#2 Updated by Oliver Hader over 6 years ago

  • Status changed from New to Needs Feedback

Can you please add a proper testplan or complete stack trace for that? Which PHP version are you using?

#3 Updated by Markus Klein over 6 years ago

Testplan by reading:

Code in FormEngine::getPlaceholderAttribute() line 6493:

$value = $this->getPlaceholderValue($table, $field, $config, $row);

// Cleanup the string and support 'LLL:'
$value = htmlspecialchars(trim($this->sL($value)));

Call stack:
1: FormEngine::getPlaceholderAttribute()
2: FormEngine::getPlaceholderValue() -> called in FormEngine:6493
3: FormDataTraverser::getTraversedFieldValue() -> called in FormEngine:6519
4: FormDataTraverser::getFieldValueRecursive() -> called in FormDataTraverser:110

Since getFieldValueRecursive() might return NULL, $value in the code above can be NULL, therefore a call to $this->sL(NULL) can happen, which furthermore calls $GLOBALS['LANG']->sL($x), which access some array with $theArray[...][$x] -> PHP Warning

Besides that getFieldValueRecursive() should have NULL in the @return clause.

#4 Updated by Oliver Hader over 6 years ago

  • Assignee deleted (Oliver Hader)
  • Priority changed from Must have to Could have
  • Is Regression changed from Yes to No

Ok, so this is highly theoretical and there is way to reproduce your bug-report. Lets start nitpicking:

  • the documentation on FormDataTraverser::getTraversedFieldValue needs to be modified
    • this method shall return data/values from database, thus "mixed" would be a proper return value there, since there is no casting to string either
    • thus everything that can be interpreted as TRUE will be returned as delivered by the (individual) DatabaseConnection
  • the "undefined index" thingy is a PHP notice on PHP 5.3, that's why I asked for your PHP version, maybe it's different there
    • but I guess it's still just a PHP notice and not a warning and we already have a lots of notices in the whole system

Thus, I could easily close this report as "cannot reproduce" or just change the documentation.
Since there are lots of other calls to $LANG->sL() with NULL values and undefined index earlier in the whole system, I kindly ask you to not create reports and also not to assign them to me directly.

#5 Updated by Oliver Hader over 6 years ago

  • Subject changed from FormDataTraverser:: getFieldValueRecursive() might return NULL to FormDataTraverser::getFieldValueRecursive() might return NULL

#6 Updated by Gerrit Code Review over 6 years ago

  • Status changed from Needs Feedback to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25366

#7 Updated by Oliver Hader over 6 years ago

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

#8 Updated by Riccardo De Contardi over 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF