Bug #15795
closedSome notices and warnings in class.t3lib_cs.php (2 things)
0%
Description
1.- Notices: Using the specCharsToASCII() function, we have detected that the initUnicodeData() function has lines like this:
if (is_array($this->caseFolding['utf-8'])) return 1;
And they throw some notices. To avoid them we have used something like:
if (!empty($this->caseFolding['utf-8']) && is_array($this->caseFolding['utf-8']))
Trivial hack.
2.-Warnings: More strange (under our opinion) is that type of loop (found more than once):
for($i=0; strlen($str{$i}); $i++) {
that throws one warning always (we think). Shouldn't it better to change it to something like:
for($i=0; $i < strlen($str); $i++) {
(we haven't been able to find any reason for your loop syntax)
Not critical at all, you know! ;-)
(issue imported from #M2814)
Updated by Martin Kutschker over 18 years ago
What kind of notices appear in case 1.?
As for 2.: The idea is to avoid a strlen call on the complete string.
Updated by Eloy Lafuente over 18 years ago
1 returns: Notice: Undefined index: utf-8 in /srv/www/htdocs/moodle/head/lib/typo3/class.t3lib_cs.php on line 1008
2 returns: Notice: Uninitialized string offset: 4 in /srv/www/htdocs/moodle/head/lib/typo3/class.t3lib_cs.php on line 1843
I can see that executing strlen($str) for each loop iteration it too much but it also could be calculated once before the for loop, avoiding the notice.
We are using your library in Moodle from one wrapper library and, for now, we are switching the error reporting level before using specCharsToASCII(), so it isn't a real problem but, as a common habit we prefer not to play with the error level here and there but to see everything always displayed instead ;-)
Updated by Clemens Riccabona over 15 years ago
I can confirm this behaviour on a fresh and clean 4.2.6.
With php 5.2.6 on a linux.
New line information:
1. PHP Notice Line 1046
2. PHP Notice Line 1881
Seems that this hasn't been fixed until now. ;)
Updated by Chris topher over 14 years ago
Seeing the outcome of the discussion in #15025 I think we don't fix the notice.
A warning should be fixed - but it seems like there also only is a notice in case 2.