[mapguide-internals] Supporting PHP 5.3
Bruce Dechant
bruce.dechant at autodesk.com
Fri Mar 19 16:37:20 EDT 2010
Hi All,
In updating to support PHP 5.3 I have been playing in the sandbox/adsk/2.2gp code base and have run into some API issues that are a result of the changes to how exceptions work in PHP 5.3.
In particular all exception classes must be derived from the PHP Exception base class.
Changing this causes more issues - namely a side effect of having to have the PHP Exception class as the base class is that it becomes the base class of MgObject which almost everything in our API derives from.
This causes an API naming conflict with existing MapGuide APIs because PHP is case insensitive - ie: getMessage() and GetMessage() are the same in the PHP world.
The PHP Exception class is defined as follows: (These are the APIs with which we can have conflicts with)
const static zend_function_entry default_exception_functions[] = {
ZEND_ME(exception, __clone, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
ZEND_ME(exception, __construct, arginfo_exception___construct, ZEND_ACC_PUBLIC)
ZEND_ME(exception, getMessage, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(exception, getCode, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(exception, getFile, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(exception, getLine, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(exception, getTrace, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(exception, getPrevious, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(exception, getTraceAsString, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(exception, __toString, NULL, 0)
{NULL, NULL, NULL}
};
Of the above APIs only the getMessage() and getCode() APIs are currently causing conflicts with MapGuide APIs.
What I have had to do in order to get around this is to change some of the existing MapGuide APIs so that they no longer conflict with PHP. The changes are as follows:
MgException class changes:
Change GetMessage() to GetExceptionMessage()
MgResources class changes:
Change GetMessage() to GetResourceMessage()
MgCoodinateSystem class changes:
Change GetCode() to GetCsCode()
I also changed SetCode() to SetCsCode() for consistency.
MgCoodinateSystemDatum class changes:
Change GetCode() to GetCsCode()
I also changed SetCode() to SetCsCode() for consistency.
MgCoodinateSystemEllipsoid class changes:
Change GetCode() to GetCsCode()
I also changed SetCode() to SetCsCode() for consistency.
MgWebInvokeScriptCommand class changes:
Change GetCode() to GetScriptCode()
I also changed SetCode() to SetScriptCode() for consistency.
Of course with these changes any existing .NET, Java or PHP applications would also have to be updated to use these renamed APIs.
I would like to get community feedback on this now in order to make any needed changes before this is officially adopted into the trunk code stream.
Thanks,
Bruce
More information about the mapguide-internals
mailing list