Drupal Core, a much forgotten API

Let's start with a little Jeoporday quiz!

Answer: There's a module for that, just look it up on d.o.
Question: How can I get this functionality on my website ?

More and more posts on the web are showing up with 'The top x modules you should always install', someone else even created a website for the answer. It's hard to keep up with the new releases everyday, it's sometimes even harder to find out the exact use case why a new module even gets released - although I respect the author because he's contributing, don't get me wrong on that one.

The selection criteria

There are many reasons to pick a module:

  • Deadlines: the functionality is there and the project has to be delivered on time.
  • Workflow: development teams try to work as uniform as possible on every project.
  • Lazyness: why bother writing a functionality yourself (even it you only need one function from a giant module).
  • Strong API: it helps the developer in custom modules or in deployment strategies.
  • PM has found it on the web. I'm dead serious on this one. I've had cases where I had to start on a site where I got the modules picked for me, without even consulting me.

There are other reasons obviously, but what strikes me is that from experience (I'm guilty too) and from a lot of discussions with all kinds of people (developers, project managers, etc), the gap between what the developer needs and the client actually wants has become bigger and bigger. I'm not sure why this is exactly happening, but it can have serious consequences when going live with a project.

The kitten paradox

The Drupal world has this paradigm that you shouldn't hack Drupal core or God kills a kitten. Even worse, Dries too nowadays. This somehow extends to Contrib too, since well, everytime you need to update, you'll have to make sure you have your patches ready. But what about this: every time you're using more than a 100 modules, mankind has killed a lot of kittens by having to install additional load balancers, reverse proxies, web and database servers for keeping the site up if it's a really busy one, especially with authenticated users. Adding hardware because the site is not performing well is - in a lot of cases - not the right answer.

Back to basics

Every project is unique and building a big project should really be evaluated before and - even more important - during the development process, with great care on how the site behaves in a real life situation, investigating the amount of queries, PHP memory, generation time and so on. That's not something you can do at the end. It's simply too late at that point and a lot of kittens have died already. There are great profiling tools in Devel and Xdebug should be your friend all the time. Be sure to use them all the time.

So, depending on the needs, it might be more interesting to write a simple custom module and write PHP yourself again, using either PHP or API functions available in Drupal core. Every developer should've least opened up the includes folder and scanned every file in it. I'm still amazed now and then, even after all those years. Even with Drupal 7 almost out, a lot of people seem scared because Contrib is not entirely ready yet. That's a pity, because there is some amazing stuff under the hood and you'd be pretty surprised how much you can pull off with only Drupal core, PHP and - especially - a lot of developing fun.

Answer: That should be api.drupal.org and php.net.
Question: Which bookmarks should I really have ?

Comments

Submitted by Jamie on December 22, 2010 - 05:36

I couldn't agree more with your post. I have taken over projects where they have incorporated views, panels, context and a dozen or more other modules just to achieve a couple of pages that could be done in 100 lines of code or less.

I would also add that while it might seem like a lot more work to create a custom module, in fact it comes out easier a lot of times. You end up achieving what you want quicker without having to constantly adjust settings in modules and search for other modules.

Submitted by John H on December 22, 2010 - 06:45

I am a self-admitted cycles weenie. I absolutely hate bloat. Why install a big-ass module when sometimes the only thing need is a snippet of inline code or a small custom module? And I don't believe in throwing more hardware to compensate for an over-inflated poorly conceived and built application.

I always let the content drive the technology. People sometimes ask me, "What modules do you start every project with?" and the answer is "none" (with the possible exception now-a-days of Views and CCK, but even these are sometimes unnecessary for small brochure web sites.)

Anyway, good read.

Submitted by Vingborg on December 22, 2010 - 10:16

I never hack core. I do project-specific forks ...

No, seriously, I agree with your basic tenet. Too often the module spread becomes a ravioli deluge, not only from a general performance perspective, but also with regards to development and maintenance.

The enormous variety of modules is a huge asset, but it's also a significant blind spot.

Submitted by Anonymous jackass on December 22, 2010 - 19:20

Performance is only one side of the story, and not even the most important one. By installing a third-party module you more or less assume responsibility for the bugs and misfitting features contained in it now and tomorrow (after you update) and potential huge upgrade problems when a new major version comes out.

Generally, the idea of having to deal with fifty different suppliers when building a product is stupid unless all those suppliers deliver easily exchangeable, mostly isolated, well-tested, well-documented parts (neither of that is true for so many contrib modules). Yes, you can possibly get support from each module's maintainer or from the "community", but why even bother, if you have the resources to support your product yourself?

Accept these words of wisdom from an anonymous jackass who has recently migrated a 50+ module site from D5.

You are here