I'm in the process of migrating customer websites off an old legacy
server that's pushing EOL, and starting to show hardware failures.
One site is throwing errors on what, so far as I can tell, should be
perfectly working code.
The original code works fine on both CentOS 3 (PHP 4.3.2) and CentOS 4
(4.3.9); the "new" server is still a bit outdated (Debian etch plus
some backports and updates from lenny; PHP 5.2.0).
The site was designed by staff at a previous hosting company and uses a
combination of the Fusebox app framework (which seems to work OK, after
a few relatively minor fixes) and a custom OOP structure.
I'm not really sure what the actual problem is, but I've reached the
point where this:
class SelectBoxOption extends Tag {
function SelectBoxOption($name, $value, $selected=false) {
parent::Tag("option", $name);
$this->addAttribute("value", $value);
if($selected) {
$this->addAttribute("selected", '', false);
}
if ($name == "") { echo " missing name!<br>\n"; }
// else { print " name $name<br>\n"; }
if ($value == "") { echo " missing value!<br>\n"; }
}
will parse and execute, but:
- the page will contain "missing value!" for each <option> in the
<select> this is generating
- it will *not* contain "missing name!"
- the <option> tags in the final output don't have content or value
(they should have both).
If I uncomment that else, I get:
adding option <name1> with <value1>
name <value1>
Catchable fatal error: Object of class SelectBoxOption could not be
converted to string in
<webroot>/includes/classes/core/display/form/input/SelectBoxOption.php
on line 12
I found the place this object is created, and added some debugging
output before *and* after that call:
echo "adding option ".$row->$nameField." with ".
$row->$valueField."<br>\n";
$this->add(new SelectBoxOption($row->$nameField,
$row->$valueField, $selected));
echo "added option ".$row->$nameField." with ".
$row->$valueField."<br>\n";
which behaves correctly and spits out the name and value (retrieved from
a database - thankfully I haven't had to track *that* down... yet).
Can anyone explain why a string passed by value (apparently) would
suddenly mutate into a SelectBoxOption object? I've confirmed that this
is exactly what happens by adding this:
if (is_a($name,'SelectBoxOption')) {
print "name isn't a SelectBoxOption, silly rabbit!<br>\n";
}
as the very next set of lines after "function SelectBoxOption(....".
I wondered while typing this if $name and $value might have ended up as
special variables somewhere, but renaming them with an opt_ prefix
didn't change anything.
-kgd
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php