[wp-hackers] PHP compatibility

SoJ Web sojweb at indiana.edu
Fri Mar 27 14:46:40 GMT 2009


Just a thought about PHP and MySQL compatibility for the future. There  
was some talk on trac ticket 8701 about the deprecated warnings that  
PHP 5 is throwing about assigning the return value of new by  
reference, and then, with PHP 5.3, magic quotes are deprecated, and in  
6 will be removed (see trac ticket 9394).

There was talk in 8701 about adjusting the error reporting levels to  
account for the warnings, but I think this not a suitable fix. If  
backwards compatibility is to be maintained, there will only be more  
and more of this to deal with. Personally, I would branch off at this  
point with a version of WordPress for PHP < 5, and continue  
development requiring v5 or higher. I don't know that many would agree  
with me on that, though, so I have another idea.

It would be possible to read the user's configuration and rewrite  
certain core files to accommodate, using a method rather like IE's  
conditional code we use for loading IE version specific CSS. Any time  
in the code where there is break with compatibility between versions  
of PHP, you could put in conditional statements that would contain  
version appropriate code. During install (or update, or something  
similar), the file is read, the conditions checked, and the file  
rewritten with the conditions removed. If the file is, for whatever  
reason, not writable, it's just ignored, and acts as it would have  
otherwise.

I've implemented a rough functionality to this effect, and it works  
pretty well (files are attached here http://core.trac.wordpress.org/ticket/8701) 
. The conditions are only checked during install, but could  
conceivably run as an update any time the configuration changed (much  
as the DB update wizard runs with the schema changes). What I've  
implemented also checks for MySQLi functionality, as that is what I'm  
using on my server.

I realize this will complicate development, but complication in some  
form is unavoidable if backwards compatibility is to be maintained.  
Any thoughts on this approach?


-Jeff Johnson



More information about the wp-hackers mailing list