Bug #38969
PHP Warning: str_pad() expects parameter 2 to be long, string given
| Status: | Accepted | Start date: | 2012-07-15 | |
|---|---|---|---|---|
| Priority: | Should have | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | Frontend | |||
| Target version: | - | |||
| TYPO3 Version: | 4.5 | Complexity: | ||
| PHP Version: | 5.3 | |||
| Votes: | 0 |
Description
Core: Error handler (FE): PHP Warning: str_pad() expects parameter 2 to be long, string given in /Users/peter/Sites/typo3_src-4.5.17/typo3/sysext/cms/tslib/class.tslib_content.php line 3588
only php 5.3.
PHP: string str_pad ( string $input , int $pad_length ....) 2. option should be a integer.
function prefixComment($str, $conf, $content) {
$parts = explode('|', $str);
$output = LF . str_pad('', $parts[0], TAB) . .....
...
}
$parts[0] is interpreted as string. when i add a type cast the warning disappears:
$output = LF . str_pad('', (int)$parts[0], TAB) . .....
History
Updated by Philipp Gampe 10 months ago
Do you mind pushing a patch go gerrit?
http://wiki.typo3.org/Contribution_Walkthrough_Tutorials
Updated by Ernesto Baschny 10 months ago
- Status changed from New to Needs Feedback
The problem is not the PHP code, but that you somewhere have a Typoscript snippet which does not conform to the documentation:
"Prefixes content with an HTML comment with the second part of input string (divided by "|") where first part is an integer telling how many trailing tabs to put before the comment on a new line."
So you probably have something like that in your Typoscript:
prefixComment = string
When it should be (for example):
prefixComment = 1 | string
I cannot find any wrong use in the TYPO3 Core, so it might be either an extension or your own Typoscript.
This being said, the prefixComment (in future) could of course "fall back" to "0 tabs" if there is no "|" divider. But this would be a new feature (for 6.0 if you want to contribute).
Updated by Peter Linzenkirchner 10 months ago
Hi Ernesto,
you are right ... :-( i found this line in the typoscript:
tt_content.stdWrap.prefixComment =
after commenting out the problem is gone ...
I am very sorry for the noise and for causing unnecessary work!!
Updated by Philipp Gampe 10 months ago
No problem.
@Ernesto please leave this open ... I would like to improve the error detection an graceful fallback once done with my tests (read next week)
Updated by Ernesto Baschny 10 months ago
- Status changed from Needs Feedback to Accepted
@Philipp, fine with me! Better handling (i.e. TS message in the admin panel) would be of course much better than "PHP warnings", if the behaviour (in the frontend) doesn't change. We could even backport that to 4.5 as a BUGFIX.