Coding Standards / Hook_requirements
I've just taken another quick run through the Coding standards because of a module I looked at last night. The new module states right on its project page that it requires PHP 5 (as more and more modules are doing). Yet, in looking through the code, it does not include a hook_requirements. I propose adding to the Coding Standards: "Any module that has requirements over and above base Drupal standards (e.g. PHP 5 vs. 4.3.5 for D6) must include a hook_requirements implementation to verify and/or warn users of this requirement." Unfortunately, I don't think Coder would be able to check this. Nancy
On Mon, May 19, 2008 at 3:14 PM, Nancy Wichmann <nan_wich@bellsouth.net> wrote:
I've just taken another quick run through the Coding standards because of a module I looked at last night. The new module states right on its project page that it requires PHP 5 (as more and more modules are doing). Yet, in looking through the code, it does not include a hook_requirements. I propose adding to the Coding Standards:
"Any module that has requirements over and above base Drupal standards (e.g. PHP 5 vs. 4.3.5 for D6) must include a hook_requirements implementation to verify and/or warn users of this requirement."
Unfortunately, I don't think Coder would be able to check this.
Drupal 6+ modules can depend on PHP 5 with their .info file (I think "php = 5.x"), so there is no need for actual coding. Gabor
On Monday 19 May 2008, Gábor Hojtsy wrote:
Drupal 6+ modules can depend on PHP 5 with their .info file (I think "php = 5.x"), so there is no need for actual coding.
Correct, although the actual format is php=5 to indicate any PHP 5 version, php=5.1 to indicate a 5.1.x minimum, php=5.2.3 to indicate a PHP 5.2.3 minimum, etc. As of Drupal 6, modules really should be using that if they have a version requirement. (As should themes.) -- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson
Hmm. In my module.info file, I've got "php = 5.0" - does that need to be changed to "php = 5"? And I'd never heard of hook_requirements before - let me go have a look at it. On Mon, May 19, 2008 at 7:54 AM, Larry Garfield <larry@garfieldtech.com> wrote:
On Monday 19 May 2008, Gábor Hojtsy wrote:
Drupal 6+ modules can depend on PHP 5 with their .info file (I think "php = 5.x"), so there is no need for actual coding.
Correct, although the actual format is php=5 to indicate any PHP 5 version, php=5.1 to indicate a 5.1.x minimum, php=5.2.3 to indicate a PHP 5.2.3 minimum, etc. As of Drupal 6, modules really should be using that if they have a version requirement. (As should themes.)
-- Larry Garfield AIM: LOLG42 larry@garfieldtech.com ICQ: 6817012
"If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson
-- John Fiala
php=5.0 should work, I think. It's validated using http://us.php.net/manual/en/function.version-compare.php So whatever works according to that should be acceptable. --Larry Garfield On Mon, 19 May 2008 08:47:09 -0600, "John Fiala" <jcfiala@gmail.com> wrote:
Hmm. In my module.info file, I've got "php = 5.0" - does that need to be changed to "php = 5"?
And I'd never heard of hook_requirements before - let me go have a look at it.
On Mon, May 19, 2008 at 7:54 AM, Larry Garfield <larry@garfieldtech.com> wrote:
On Monday 19 May 2008, Gábor Hojtsy wrote:
Drupal 6+ modules can depend on PHP 5 with their .info file (I think "php = 5.x"), so there is no need for actual coding.
Correct, although the actual format is php=5 to indicate any PHP 5 version, php=5.1 to indicate a 5.1.x minimum, php=5.2.3 to indicate a PHP 5.2.3 minimum, etc. As of Drupal 6, modules really should be using that if they have a version requirement. (As should themes.)
Note that hook_requirements is not really usable anyway in D5 (see issues about it), so it would be misleading to include this as a requirement when it can't be usefully implemented. ----- Original Message ----- From: "Nancy Wichmann" <nan_wich@bellsouth.net> To: "Development@Drupal. Org" <development@drupal.org> Sent: Monday, May 19, 2008 3:14 PM Subject: [development] Coding Standards / Hook_requirements
I've just taken another quick run through the Coding standards because of a module I looked at last night. The new module states right on its project page that it requires PHP 5 (as more and more modules are doing). Yet, in looking through the code, it does not include a hook_requirements. I propose adding to the Coding Standards:
"Any module that has requirements over and above base Drupal standards (e.g. PHP 5 vs. 4.3.5 for D6) must include a hook_requirements implementation to verify and/or warn users of this requirement."
Unfortunately, I don't think Coder would be able to check this.
Nancy
participants (5)
-
FGM -
Gábor Hojtsy -
John Fiala -
Larry Garfield -
Nancy Wichmann