PHP Very Fast At Infinite Loops

Fixing bugs in Drupal PHP modules does not count as one of my favourite activities. Or as much as wading through a sewer system does.

Maybe it is just me, but I always get the feeling that the PHP programmer is on the verge of a complexity breakdown. Everything seems to take enormous efforts, there is no sign of airiness.

If there is then a whole infrastructure like Drupal together with the many different ways to install it, then the path issue (a.k.a. where are things) becomes insane.

And to fight that you will find amazing code:

while (!@stat('./includes/bootstrap.inc')) {
  chdir('..');
}
require_once './includes/bootstrap.inc';

Now assume that the current position of the PHP script does not give access to ./includes/bootstrap.inc. And also none of the directory nodes above it, as the includes might be installed somewhere completely else.

In that case this loop will loop ... indefinitely; or until the PHP builtin max_execution_time kicks in (with a timeout).

3 hours of my life just to get Brilliant Gallery running.

Brilliant.

Posted In

It depends

Hmm, is there some Perl project that doesn't have shitty code? :)

Drupal carries a lot of legacy from the olden days of PHP3&4. PHP5 has been around for at least 4 years where there's an autoloader mechanism for all these things, which is quite elegant and solid.

Don't judge PHP by shitty developers and old legacy crap they haven't bothered cleaning up yet. You'll find this exact problem in any programming language / environment on the planet.

Ugh, I'm defending PHP. I feel dirty now. Time for coffee.

Alex (not verified) | Mon, 10/12/2009 - 00:21

Re: It depends

Hmm, is there some Perl project that doesn't have shitty code? :)

Unamazingly, there is:

http://kill.devc.at/node/261

Don't judge PHP by shitty developers and old legacy crap ...

This is (a) rather new code and (b) happens in actually a few Drupal modules.

You'll find this exact problem in any programming language / environment on the planet.

Maybe. But the moaning noises always seem to come from PHP. :-)

It seems that it is just to easy to produce something. Perl has exactly the same problem and I am being criticized that I criticize.

Yeah, we are all a happy family and everything gets well by itself.

rho | Mon, 10/12/2009 - 01:56

It depends

Well, you're right in that there is a lot of crap, but hey, even if there is new code in Drupal, that doesn't mean the people in charge knows what they're doing. Or, rather, that the people who did that were sane. Even with new features and better improvements in the language available doesn't even mean people will use them, know of them, change their old thinking, and whatsnot.

I don't see PHP any different from other languages in terms of the crap you can create, but yes, it is very easy to make something in PHP; it is deployed everywhere, and is fairly easy to slop something together and make it do stuff. The barrier of entry is quite low, and that usually means there's a lot of bottom dreck.

Shouldn't we address the reasons for people creating crap, though? And the poor focus on modeling in general? :) Just sayin'

Alex (not verified) | Thu, 10/15/2009 - 13:15