I'm on the phone a lot lately and need some kind of brain-dead, yet soothing patches that I can do while I'm listening. ;) Here's one I thought of today.

When one opens up an .install file, it's typical that one is doing so to read something about the database structure for that module. Either because they're interested in a field description, or they want to copy/paste the field definition from something in core.

However, because hook_schema() was added well after others like hook_install() and such, it often ends up at the very bottom of the files, causing said developers needless scrolling. Furthermore, hook_install() doesn't really do much nowdays; in most modules it's just a drupal_install_schema() call. So there's no reason for that to be at the top.

So I propose the following:

Go through every .install file in core and format it as follows:

1. Make sure there's a @file line at the top, that says "Installation file for Module module." (aggregator.install, for one, is missing this.)
2. Put hook_schema() first.
3. Followed by hook_requirements().
4. Followed by hook_install().
5. Then, hook_uninstall().
6. And finally, the big glop of all hook_update_N() functions.
7. Make sure that there are nice @defgroups between core versions for each update_N function, like there are in system.install.

Sound good?

CommentFileSizeAuthor
#34 263956-combined.patch102.83 KBwretched sinner - saved by grace
#34 263956-combined.patch102.83 KBwretched sinner - saved by grace
#33 263956-upload.patch1.41 KBwretched sinner - saved by grace
#32 263956-update.patch2.02 KBwretched sinner - saved by grace
#31 263956-trigger.patch1.12 KBwretched sinner - saved by grace
#30 263956-taxonomy.patch1.25 KBwretched sinner - saved by grace
#29 263956-system.patch40.57 KBwretched sinner - saved by grace
#28 263956-statistics.patch1.74 KBwretched sinner - saved by grace
#27 263956-simpletest.patch9.15 KBwretched sinner - saved by grace
#26 263956-search.patch1.2 KBwretched sinner - saved by grace
#25 263956-profile.patch1.12 KBwretched sinner - saved by grace
#24 263956-poll.patch976 byteswretched sinner - saved by grace
#23 263956-openid.patch930 byteswretched sinner - saved by grace
#22 263956-menu.patch3.33 KBwretched sinner - saved by grace
#21 263956-locale.patch14.04 KBwretched sinner - saved by grace
#20 263956-forum.patch4.08 KBwretched sinner - saved by grace
#19 263956-field_sql_storage.patch1.08 KBwretched sinner - saved by grace
#18 263956-field.patch588 byteswretched sinner - saved by grace
#17 263956-dblog.patch965 byteswretched sinner - saved by grace
#16 263956-contact.patch1.19 KBwretched sinner - saved by grace
#14 263956-book.patch2.47 KBwretched sinner - saved by grace
#13 263956-blogapi.patch990 byteswretched sinner - saved by grace
#15 263956-comment.patch10.68 KBwretched sinner - saved by grace
#9 drupal.install-aggregator.patch2.2 KBsun
#4 263956_move_hook_schema.patch160.46 KBdeekayen

Comments

deekayen’s picture

Assigned: Unassigned » deekayen
lilou’s picture

deekayen’s picture

I'm in a mood to work on this, so I'll just leave out @file part.

deekayen’s picture

Status: Active » Needs review
StatusFileSize
new160.46 KB

I added a couple defgroups and moved hooks around.

lilou’s picture

Status: Needs review » Needs work

The last submitted patch failed testing.

lilou’s picture

Issue tags: +Coding standards

Add tag.

deekayen’s picture

Assigned: deekayen » Unassigned
sun’s picture

Status: Needs work » Needs review
StatusFileSize
new2.2 KB

@webchick: Less phone calls, less crazy ideas. :P

To get this done, I'd propose to do one file at a time. Equaling: One phone call of webchick.

sun’s picture

Issue tags: +Novice

.

wretched sinner - saved by grace’s picture

Assigned: Unassigned » wretched sinner - saved by grace

I'll try to look into this over the next couple of days

wretched sinner - saved by grace’s picture

Ok. From running through the files:

  • Block module already conforms
  • Blog module has no install file
  • Color module already conforms (Only has color_requirements)
  • Of the Field submodules, only field_sql_storage has an install file
  • Filter module has no install() or uninstall()
  • Help module has no install file
  • Node module has no install() or uninstall()
  • Path module has no install file
  • PHP module already conforms
  • Syslog module has no install file
  • Tracker module has no install file
  • Translation module has no install file
  • User module already conforms

I will attach individual patches - I can't attach multiple files to one comment!

wretched sinner - saved by grace’s picture

StatusFileSize
new990 bytes

Blog API module

wretched sinner - saved by grace’s picture

StatusFileSize
new2.47 KB

Book Module

wretched sinner - saved by grace’s picture

StatusFileSize
new10.68 KB

Comment Module

wretched sinner - saved by grace’s picture

StatusFileSize
new1.19 KB

Contact Module

wretched sinner - saved by grace’s picture

StatusFileSize
new965 bytes

DB Log Module

wretched sinner - saved by grace’s picture

StatusFileSize
new588 bytes

Field Module

wretched sinner - saved by grace’s picture

StatusFileSize
new1.08 KB

Field SQL Storage Module

wretched sinner - saved by grace’s picture

StatusFileSize
new4.08 KB

Forum Module

wretched sinner - saved by grace’s picture

StatusFileSize
new14.04 KB

Locale Module

wretched sinner - saved by grace’s picture

StatusFileSize
new3.33 KB

Menu Module

wretched sinner - saved by grace’s picture

StatusFileSize
new930 bytes

Open ID Module

wretched sinner - saved by grace’s picture

StatusFileSize
new976 bytes

Poll Module

wretched sinner - saved by grace’s picture

StatusFileSize
new1.12 KB

Profile Module

wretched sinner - saved by grace’s picture

StatusFileSize
new1.2 KB

Search Module

wretched sinner - saved by grace’s picture

StatusFileSize
new9.15 KB

SimpleTest Module

wretched sinner - saved by grace’s picture

StatusFileSize
new1.74 KB

Statistics Module

wretched sinner - saved by grace’s picture

StatusFileSize
new40.57 KB

System Module

wretched sinner - saved by grace’s picture

StatusFileSize
new1.25 KB

Taxonomy Module

wretched sinner - saved by grace’s picture

StatusFileSize
new1.12 KB

Trigger Module

wretched sinner - saved by grace’s picture

StatusFileSize
new2.02 KB

Update Module

wretched sinner - saved by grace’s picture

StatusFileSize
new1.41 KB

Upload Module

wretched sinner - saved by grace’s picture

StatusFileSize
new102.83 KB
new102.83 KB

Ye Grand Olde Massive rollup patch. Includes all my patches above, plus suns patch to Aggregator in #9

sun’s picture

Wooohooo! :)

@wretched sinner: Unfortunately, there is one thing missing in your patches - the leading @file and the @ingroup PHPDoc statements (both and after a set of updates - have a look at my Aggregator patch to see what I mean).

Another important thing is that we also want to move hook_requirements from the .module into the .install file, if existent.

@webchick: By the way, what about hook_enable()/_disable() ?

lilou’s picture

@sun patch : don't change @file description in aggregator module (see #320011: Add doxygen @file for all .install, http://drupal.org/node/224333#afile and coding standard)

 /**
  * @file
- * Install, update and uninstall functions for the aggregator module.
+ * Installation functions for Aggregator module.
  */
wretched sinner - saved by grace’s picture

If webchick can chime in on whether we want to have the hook_enable() and hook_disable() merged in, then I will look to re-roll with the comments above.

wretched sinner - saved by grace’s picture

Status: Needs review » Needs work
sun’s picture

Status: Needs work » Closed (won't fix)

There are several other issues in the queue that tackle this now: http://drupal.org/project/issues/search/drupal?issue_tags=coding%20stand...