Drupal

On empty return values

Submitted by Larry on 28 March 2013 - 8:31pm

Earlier today, I posted a brief tweet (isn't that redundant?) about return values in PHP (or really, any language). Originally it was about return values from functions (such an exciting topic, I know), but it ended up generating a fair bit of lively conversation, as well as a patch against Drupal 8. So lively, in fact, that I think it deserves more than 140 characters.

New rule:

If your function returns a collection, its null value return must also be a collection.

Getting off the island in 2013

Submitted by Larry on 31 December 2012 - 12:13am

And so 2012 draws to a close. The world didn't end, to the disappointment of many. In some ways it was an eventful year, in others rather ho-hum follow-ups to the excitement of 2011.

In the Drupal world, though, 2012 will go down as the year Drupal finally began replacing NIH with PIE. Compare Drupal's 8.x branch a year ago with it today. A year ago, we had one class of 3rd party PHP code, in an uninteresting corner of the update system. Today, it contains 3rd party code from no less than five different projects: Symfony, Doctrine, Guzzle, Assetic, and Twig. Those libraries are included via Composer, the new and ground-breaking PHP-library-management-system-that-actually-finally-works. Code from at least one more should be landing soon.

Drupal developers, working on Drupal, have contributed to a number of other projects, including Symfony and Symfony CMF, and because of the degree of code sharing happening in the PHP world now have indirectly contributed to a half-dozen other major projects, too. Drupal 8, aside from the technological advances it will offer over Drupal 7, also represents perhaps the largest cultural shift in Drupal or PHP history.

Are you ready for 2013, Drupal? Really?

The danger of privates, and composition vs. inheritance

Submitted by Larry on 11 December 2012 - 10:43pm

The private variables debate is going around the PHP world again. Brandon Savage posted a pair of articles pointing out the perils of private variables, boiling down mostly to them making extension infesible or impossible. Anthony Ferrara replied with his own article, arguing that the real problem is using inheritance in the first place rather than composition. I figured I'd weigh in on my own blog rather than in a comment. :-)

As an academic matter, I agree with Anthony. Composition and interfaces are more flexible than inheritance. I've been preaching the interface gospel within Drupal almost as long as I've been preaching Dependency Injection.

Up with which I will not PUT

Submitted by Larry on 17 October 2012 - 10:35pm

For Drupal 8, we want to bake REST support directly into the core system. It's unclear if we'll be able to go full-on hypermedia by the time we ship, but it should be possible to add via contributed modules. For the base system, though, we want to at least follow REST/HTTP semantics properly.

One area we have questions about is PUT, in particular the details of its idempotence requirements. For that reason, I'm reaching out to the Interwebs to see what the consensus is. Details below.

Conference Season - Fall 2012

Submitted by Larry on 18 July 2012 - 12:44am

That moment when you realize just how much awesome you have coming up that you're not sure you're going to survive it? Yeah, that.

It's nearly time for the second half of the year conference season, and it looks like my schedule is starting to fill up. I've three conferences and 5 speaking engagements in the coming weeks, so for those interested in Stalking Crell here's where you'll be able to find me:

Midwest Developers Summit: 26-28 July

Supporting Aaron Winborn

Submitted by Larry on 16 July 2012 - 8:52pm

Aaron Winborn is a longtime Drupal contributor and friend to the community. Since his diagnosis with Amyotrophic lateral sclerosis (ALS), Aaron has been trying to enjoy time with his family, to remain productive in his work and to live as normal a life as possible.

As time passes, however, the disease has made his life increasingly difficult as it attacks his nervous system. To cope with the mounting costs of treating his condition, Aaron has set up a special needs trust, and you can make a direct donation from his web site.

As a show of support for Aaron and his family, for the rest of this year, my co-authors and I intend to donate all of our royalties from sales of Drupal 7 Module Development to the special needs trust. You can read reviews and order a copy at Amazon.com.

Not only can you get one of the top books on Drupal 7 development, in so doing you can help out one of the people that has helped to make Drupal as powerful as it is.

readfile() not considered harmful

Submitted by Larry on 3 May 2012 - 9:12pm

If you're like me, you've probably read a dozen or two articles about PHP performance in your career. Many of them are quite good, but some are simply flat out wrong, or misinformed.

One of the old truisms that has been repeated for as long as I can recall is "don't use readfile() if you have big files, because it reads the whole file into memory and your server will explode." The usual advice is to manually stream a file, like so:

<?php
$fp
= fopen('bigfile.tar', 'rb');
while (!
feof($fp)) {
 print
fread($fp, 1024);
}
fclose($fp);
?>

There's just one problem with that age-old truism: It's not true.

Refocusing WSCCI

Submitted by Larry on 20 February 2012 - 9:18pm

As Dries has already reported, we held a summit meeting at the Acquia offices in Boston last week. It was a good sprint for a couple of reasons. For one, a large number of leading core developers got more clearly on the same page about the direction of Drupal core. For another, we were able to break the "too big to swallow" logjam that has been plaguing the Web Services and Context Core Initiative (WSCCI).