Easier PHP4 compatibility for Drupal modules
Hello, It seems many of us -if not most of us- are already developing modules and other stuff using PHP5. As a module maintainer I'm bothered from time to time with "PHP4 compatibility" feature requests and patches that are usually like this one: |if (!function_exists('array_diff_key')) { function array_diff_key() { .... } } |So most of the times, its just a few conditional function definitions that will make the module backwards compatible with PHP4. I'm thinking it would be really nice to have a 'php4' Drupal module that handles these simple cases. Then we can just tell people wanting our modules to work with PHP4 to go and try this other module. This module also wouldn't even need to use conditional function definitions as it is supossed to be enabled only for PHP4 sites so it would be even easier. So.. Anyone? PS: Yes, I know, "why don't you do it yourself?" But a) I am already maintaining a number of modules and I can hardly keep up with the issue queue - I've already added some to the "Abandoned modules" user - and b) I'm not using PHP4 for anything anymore so I won't even be able to test such a module.... So please, someone who needs PHP4 compatibility..... Jose A. Reyero ||
Quoting "Jose A. Reyero" <drupal@reyero.net>:
So.. Anyone?
I say just refer them to http://www.gophp5.org/ and add the banner to your project page. Drupal 7 will only support PHP5. Earnie -- http://for-my-kids.com/ -- http://give-me-an-offer.com/
Earnie Boyd schrieb:
I say just refer them to http://www.gophp5.org/ and add the banner to your project page.
How will that help small community sites with a cheap hosting company that refuses to upgrade to php5?
Drupal 7 will only support PHP5.
There should be a cut like this to encourage the upgrade, but all previous versions including contributed modules should support php4. Eric
Eric-Alexander Schaefer wrote:
Earnie Boyd schrieb:
I say just refer them to http://www.gophp5.org/ and add the banner to your project page.
How will that help small community sites with a cheap hosting company that refuses to upgrade to php5?
Drupal 7 will only support PHP5.
There should be a cut like this to encourage the upgrade, but all previous versions including contributed modules should support php4.
While Drupal 6 supports PHP4, there is absolutely no requirement for contrib modules for Drupal 6 to support PHP4.
Drupal 7 will only support PHP5. There should be a cut like this to encourage the upgrade, but all previous versions including contributed modules should support php4.
While Drupal 6 supports PHP4, there is absolutely no requirement for contrib modules for Drupal 6 to support PHP4.
And, in fact, contrib modules can specify which version of PHP they run under, and Drupal will properly stop you from enabling that module should you not meet those requirements. -- Morbus Iff ( take your rosaries off my ovaries ) Technical: http://www.oreillynet.com/pub/au/779 Enjoy: http://www.disobey.com/ and http://www.videounderbelly.com/ aim: akaMorbus / skype: morbusiff / icq: 2927491 / jabber.org: morbus
On Tue, 10 Jun 2008 16:22:01 +0200, Eric-Alexander Schaefer <eric.schaefer@eas-consulting.de> wrote:
Earnie Boyd schrieb:
I say just refer them to http://www.gophp5.org/ and add the banner to your project page.
How will that help small community sites with a cheap hosting company that refuses to upgrade to php5?
It gives them a nice long list of hosts who want their business and aren't hamstringing them. That's why GoPHP5 still has that list up. :-)
Drupal 7 will only support PHP5.
There should be a cut like this to encourage the upgrade, but all previous versions including contributed modules should support php4.
Eric
PHP 4 vs. 5 compatibility is a lot more than just what functions are available. What you're looking for is the PHP_Compat library, available in PEAR. It's user-space backports of most of the new functions in PHP 5. It's under the PHP License, but I believe the author said he was willing to relicense it for us under the GPL. I actually wrote a patch to add about 80% of PHP_Compat to Drupal 6 early last year, which Dries rejected. (In hindsight, I believe he was right to do so.) One of the key problems with it, I didn't realize until later, is that PHP parses and loads conditionally loaded functions *even if the condition is never met*. The condition being met just aliases the internal name of the function (some gobbldygook unique string) to the requested name. It eats up memory either way. However, many many modules don't support PHP 4 for other reasons. Frankly I think it's foolish for any module that deals with XML to even bother trying to support PHP 4; the XML processing system is completely different, and PHP 5's XML processing can save you 40K of source code over PHP 4's. (cf, Amazon Tools module.) The way object references are handled are different as well. SPL classes really have no capability to be backported. Proper timezone support didn't exist until PHP 5.2, much less 5.1. Plus, many of us, like the OP, don't even have access to a PHP 4 system anymore to test against. I don't even know if some of my modules work in PHP 4. I agree that a common php4.module is better than several modules re-implementing various PHP 4 utilities themselves and causing namespace collisions. However, Drupal 6 modules that depend on PHP 5 features should be declaring that fact in their info files to prevent themselves from being installed on unsupported versions. Having a "compat" module will mean users will have to edit (hack) the info files of those modules to remove the php requirement line, and then hope that the PHP 5 features it depends on are covered by the compat module. I do not see "hack the module and pray" as a viable recommendation to give anyone. The better solution is to make it as easy as possible for people to migrate off of hosts that are still running a version of PHP that is no longer supported anyway. Point them to GoPHP5, point them to "migrating to a new sever" instructions on drupal.org, etc. Helping extend the life of PHP 4 is doing people a disservice, just as much as keeping them on Windows 98 for longer would be. --Larry Garfield
It's user-space backports of most of the new functions in PHP 5. It's under the PHP License, but I believe the author said he was willing to relicense it for us under the GPL.
http://lists.drupal.org/pipermail/development/2006-November/020834.html
Jose A. Reyero schrieb:
So.. Anyone?
I was already thinking about something like this. We would probably only need to create the module with a couple of functions and let the crowd hand in patches for all the functions they need. I would give it a try, if no one else wants to do it. Eric
I can think of at least Date module which ships with a PHP4 compat module already. Having a centralised one would take the load off individual developers and IMO make it easier to drop PHP4 support later on (i.e. the module doesn't get upgraded to Drupal 7, and the modules which use it don't have to clear out a lot of PHP4 specific code when upgraded). Good idea. Nat
Eric-Alexander wrote:
need to create the module ... I would give it a try
I would recommend that we just add a new piece to the Helpers module, which already exists to help developers. Nancy -----Original Message----- From: development-bounces@drupal.org [mailto:development-bounces@drupal.org]On Behalf Of Schaefer Sent: Tuesday, June 10, 2008 10:26 AM To: development@drupal.org Subject: Re: [development] Easier PHP4 compatibility for Drupal modules Jose A. Reyero schrieb:
So.. Anyone?
I was already thinking about something like this. We would probably only need to create the module with a couple of functions and let the crowd hand in patches for all the functions they need. I would give it a try, if no one else wants to do it. Eric No virus found in this outgoing message. Checked by AVG. Version: 8.0.100 / Virus Database: 270.2.0/1494 - Release Date: 6/10/2008 7:22 AM
participants (9)
-
Earl Miles -
Earnie Boyd -
Eric-Alexander Schaefer -
Jose A. Reyero -
Karoly Negyesi -
Larry Garfield -
Morbus Iff -
Nancy Wichmann -
Nathaniel Catchpole