I am using a database to store sessions and ran into a conflict
between Zend_Db_Adapter_Sqlsrv and Zend_Session. I am testing version
1.1 of the SQL Server Driver for PHP to see how it works with UTF-8
text, and added CharacterSet = 'UTF-8' to the driver_options array.
However, Zend_Db_Adapter_Sqlsrv attempts to resolve the configuration
value as a constant first, and if undefined then to use the value as a
string. This is achieved by using the error control operator to
suppress warnings when calling constant() on line 150:
$constantValue = @constant(strtoupper($value));
The problem is that Zend_Session registers a custom error handler so
it can convert PHP errors into exceptions, which means that it catches
the warning even though it should be suppressed. Since it's an
exception, it bubbles up and kills the page. I think I can handle the
exception, but I think a better solution would be to change the logic
in Zend_Db_Adapter_Sqlsrv to first check if the constant has been
defined before calling constant() rather than running the function
with the error control operator to ignore the warning in the case a
constant with that name has not been defined.
Instead of this:
<?php
$constantValue = @constant(strtoupper($value));
if ($constantValue === null) {
$connectionInfo[$option] = $value;
} else {
$connectionInfo[$option] = $constantValue;
}
?>
How about this:
<?php
$connectionInfo[$option] =
defined(strtoupper($value)) ? constant(strtoupper($value)) : $value;
?>
Andrew