r/programming • • Jan 05 '11

Drupal 7 released.

http://drupal.org/drupal-7.0
222 Upvotes

259 comments sorted by

View all comments

Show parent comments

25

u/UnConeD Jan 05 '11 edited Jan 06 '11
  • Despite being a "content management framework", the core doesn't actually save you from writing code. You still have to write CRUD code, still have to manage validation, still have to define your own themables. That is, unless you use CCK/Views, which is pretty much developer-hostile lasagna and slow to boot. And it'll look like ass, unless you have an ubertalented designer who also knows PHP (i.e. a "themer", a role which doesn't exist elsewhere). And the one part that you would actually want to contextualize, i.e. the content UI, is shoehorned into the node/edit form with zero choice.

  • Despite the promises of the hook system, Drupal lacks the ability to swap out components. If you wish to leverage part of the page generation process for another purpose, you have to reimplement everything that comes after. Alter hooks are terrible tools for building reliable behavior, since they require you to actively fight against other parts of the system instead of just turning them off. If you don't share Drupal's assumptions about user accounts, you're fucked, unless you feel like trapping and erasing UI messages is a productive use of your time. And don't even try to maintain the resulting code.

  • Despite being billed as having a "solid core", Drupal's irreplaceable innards are actually pretty fragile. Form API is near impossible to debug and fails silently at the drop of a hat. The node system doesn't even let you reliably do programmatic saves. The user system is a terrible misdesign that mixes front-end presentation details ($category) with low level data manipulation. The global $user object is actually a useless fake, waiting to trip you up.

  • Entire portions of Drupal were created in a theoretical vacuum and released without any serious working implementations. For example, install profiles: they are executed in an incomplete pseudo-Drupal environment where it's actually impossible to do certain simple things due to static caches and dysfunctional APIs. Another example: Form API process functions with complex datatypes and dynamic AJAX manipulation. Theoretically possible, practically a nightmare.

The problem can be summarized quite effectively: out of the box, it is impossible to make a slick, modern website with Drupal, i.e. something that looks and feels like 2011 rather than 2001. It's only useful if you're already planning to write a lot of custom PHP/HTML/CSS. Otherwise you have to be happy with terribly designed contrib components that are insecure, don't scale and have bad usability. This is not surprising since Drupal has been in incremental-improvements-mode since 2002 (i.e. Drupal 4.0) and the few architectural improvements made since then were designed with only one purpose in mind: to support what Drupal already does, rather than being solid components of a CMF.

Doing Drupal will stunt you as a developer, overburden you as a designer and frustrate you as a user.

waves

1

u/[deleted] Jan 06 '11

Wow really really well written. I've got to save this for future reference. Those are all pretty major shortcomings of Drupal. The most frustrating is getting rid of the stock UI. That crap always finds a way to seep into your design.

Can you clarify what you mean about the node system not letting you do programmatic saves? Or was the key word 'reliably'? If so yeah I'd have to concur.

3

u/UnConeD Jan 06 '11

The problem is really the node_form and how it shapes the code around it. The idea is that you take the entire $node, you turn it into a $form structure with fields, which is then shown to the user. Then the submitted form values are serialized back into a new $node (which is made secure through Form API access control on fields).

This is dumb, because it elevates the form fields from just a UI implementation aspect into meaningful structure. It also means you need a comprehensive bidirectional translation scheme between $node and $form, which in practice means people get lazy and make forms that look like airplane cockpits.

But where it gets really problematic is that many contrib modules (out of ignorance) don't even bother translating back from $form to $node, and hardcore their node_save() callbacks to accept only the $form values. Passing in a vanilla $node will simply not work and result in data loss, aggravated by silent failure and those crazy type casts PHP is famous for.

I actually made a flowchart of this process for Drupal 6 to explain this to a coworker: http://acko.net/dumpx/why-drupal-nodes-suck.pdf

As far as I'm aware, the only way this has changed in 7 is that the $form fields are now automagically combined with the original $node, so that values not present in the $form are not lost. But otherwise, module authors are still expected to grasp MVC-related concepts in a system that has neither the vocabulary nor the grammar to express these ideas fluently.

5

u/mikey_p5151 Jan 06 '11 edited Jan 06 '11

While this does perfectly describe the problems with previous versions of Drupal, I think quite a bit has changed since you have been around and committing. Any entity that properly implements field_attach_* hooks has a consistent data structure that can be loaded, modified in place, and saved without concern over whether the $form fields match the structure that the saving function (and ultimately field_attach_insert and field_attach_update) expect. It just works. Seamlessly.

As to mapping form field to entity fields, of course that will never match and any system that claims to integrate those items ends up being what Drupal was, not what it is now. field_attach_form and field_attach_form_submit are what glues these two items in a default way, but keeps the data structure of the object 100% separate from the values of the form itself. I'd suggest anyone that has fought this code in the past, write their own entity module that is fieldable, and use these functions to understand how they actually work and how the data structures work.

But where it gets really problematic is that many contrib modules (out of ignorance) don't even bother translating back from $form to $node, and hardcore their node_save() callbacks to accept only the $form values.

This is just silly. We aren't talking about 4.7 and 5.x contrib modules. We're talking about Drupal core, and it's changed alot. Not to mention nothing prevented users from writing Drupal 5.x or 6.x modules that DID NOT have this problem. Project module (for all it's cruft) actually does an awesome job of putting it's metadata in consistent, repeatable, and sane places that work whether it's getting a form value or a $node object.

Nothing is stopping (other than lack of time and motivation) fixing the node preview issue once and for all, the object I get back from field_attach_form_submit() has all the fields in the exact same place they are when they are returned by entity_load() and field_attach_load().

6

u/UnConeD Jan 06 '11

I've actually dug through quite a lot of D7 code. And noticed all the "Fix this in D8" comments that show the issues I've raised are still there.

Besides, you're focusing on the minor complaints and ignoring the big ones I started out with. But since you insist, take a look at node.pages.inc:90-99 ($node being stateful, in direct contradiction with how Form API is designed) and session.inc:106-127 (global $user is a fake) and tell me these are the hallmarks of a well-designed system. None of these things matter for vanilla stuff, it only comes out when you try to push the system into more advanced ways of interaction. You know, doing experimental development, pushing the edge, what Drupal used to pride itself on?

As for core vs contrib...as the rest of this thread shows, you can't look at Drupal core in isolation. In practice, the vast majority of people do rely on contrib modules, and Drupal.org does not make any effort to suggest doing otherwise. It is dishonest to pretend that the ultra strict principles of Drupal core, which only arise as a result of a strict vetting process, will spontaneously radiate outward to contrib modules and the sites that use them. It has never happened, and it won't change any time soon.

As for your accusations about "poor taste"... I'm posting technical arguments in response to a direct challenge about Drupal weaknesses, on a site that isn't Drupal.org. If that somehow offends you, tough luck.

1

u/mikey_p5151 Jan 06 '11

I should back up a bit and acknowledge that Node module is mess with it's revision handling and the fake 'hooks' of hook_insert, etc, that are really just named callbacks. And beyond that user.module is even worse with the fake user global, the abomination that is users.data and so on. Comment.module is even worse, and has led to some of the worse "WTF" moments I've ever seen in Drupal code.

Despite this, I do feel that serious changes are being made that facilitate good, clean separation between in new code (I've been working on new modules that define their own entities, and it's about at least 100x cleaner than node.module so far). This is the type of change that shows that Drupal is (slowly) moving in the right direction. While I didn't work personally on any of the issues you mentioned for Drupal 7, I can see that there is the possibility and groundwork laid for fixing them in a proper way in the future.

As far as core vs. contrib, I guess on some level I understand that frustration with crappy contrib, and there sure is plenty of it, but I don't see that Drupal core itself is responsible for it. In some ways with the node hooks sure, but if I want to define my own objects, write my HTML and form, and write my own SQL, nothing is stopping me. For a long time Views has been an excellent example of this, (the editing and saving of a view, not the function of views itself) separating CRUD from forms very well, and introducing exportables to the mix as well.