Compatibility IssuesThis page describes certain compatibility issues come across throughout the development of the project. Developers should be aware of this page to avoid the same issues re-occuring in the future. defined() Return ValueThe PHP defined() function changed its return value from an integer to a boolean value throughout the PHP 4.3 development cycle.
The return value of the defined() function does not change the execution of the following logic: <?php
if (defined('CONSTANT')) {
...
}
?>
It does however reflect certain functions of osCommerce where the value of a custom function is stored in a variable, and the type of the variable is being used in an if statement. For example: <?php
class osC_Class {
function isInstalled() {
return defined('CONSTANT');
}
}
$osC_Class = new osC_Class();
$installed = $osC_Class->isInstalled();
if ($installed === true) {
...
}
?>
Similar logic is being used for the modules administration page. Due to the coding standards stating that boolean variables being checked in an if statement should also include a verification of the variable type, the above will fail for PHP versions 4.3.4 and below due to the return value of defined() being an integer and not a boolean value. This behaviour is fixed by forcing the osC_Class::isInstalled() method to return a boolean value, which is the expected return value of the method anyway. <?php
class osC_Class {
function isInstalled() {
return (bool)defined('CONSTANT');
}
}
?>
The exact return value of functions and class methods can be defined (and enforced) when phpDocumentation styled documentation is applied to the source files. SimpleXML Namespace BugPHP 5 versions up to and including 5.1.2 contain a bug with the simplexml_load_string() and simplexml_load_file() functions in the SimpleXML implementation, where the functions fail to properly parse the XML data if the root element contains a namespace. Related bug report: http://bugs.php.net/bug.php?id=37035 This problem was experienced during the development of osCommerce 3.0 Alpha 3 with the PayPal IPN payment module. |