PHP Notice: Undefined offset: 1 in misc.functions.php
Posted: Thu Jan 28, 2010 6:50 pm
Looking at the php error logs I've seen an isolated entry that I can't account for. It's on an 1.6.5 installation but 1.6.6. seems to share the potential 'problem code'.
Looking at the code with non-expert eyes...
... I'd guess that this happens when $vals[1] is undefined - when $one has no comma. I haven't looked at what calls the function and I don't know how to trigger the notice but is it a bug? Does it matter?
PHP 5.2.6
MySQL 5.0.45
Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.8b DAV/2 PHP/5.2.6 mod_perl/2.0.4 Perl/v5.8.8
Linux 2.6.18-92.1.6.el5 On i686
EDIT 28 Feb 2010: Follow-up.
I've also seen the notice with 1.6.6 and 1.6.7 (now misc.functions.php line 1648). I'm not sure how relevant this is but /tmp/cache/csshash.dat line 1 is "," followed by separate lines with id/hash for all associated css entries - except for the news module.
EDIT 12 Dec 2010
The behaviour continued across all installed releases until an upgrade from 1.8.2 to 1.9.1 - so I'm going to mark the thread '[SOLVED]'.
Code: Select all
PHP Notice: Undefined offset: 1 in [...] /htdocs/lib/misc.functions.php on line 1614
Code: Select all
function csscache_csvfile_to_hash($filename)
{
if( !is_readable($filename) ) return false;
$tmp = @file($filename);
if( !is_array($tmp) || !count($tmp) ) return false;
$result = array();
foreach( $tmp as $one )
{
$vals = explode(',',trim($one));
$result[$vals[0]] = $vals[1];
}
return $result;
}
PHP 5.2.6
MySQL 5.0.45
Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.8b DAV/2 PHP/5.2.6 mod_perl/2.0.4 Perl/v5.8.8
Linux 2.6.18-92.1.6.el5 On i686
EDIT 28 Feb 2010: Follow-up.
I've also seen the notice with 1.6.6 and 1.6.7 (now misc.functions.php line 1648). I'm not sure how relevant this is but /tmp/cache/csshash.dat line 1 is "," followed by separate lines with id/hash for all associated css entries - except for the news module.
EDIT 12 Dec 2010
The behaviour continued across all installed releases until an upgrade from 1.8.2 to 1.9.1 - so I'm going to mark the thread '[SOLVED]'.