Use hook_requirements() rather than odd simpletest_load() stuff

webchick - January 21, 2008 - 04:21
Project:SimpleTest
Version:6.x-1.x-dev
Component:Code
Category:task
Priority:normal
Assigned:webchick
Status:closed
Description

Every time the Administer >> Site building >> SimpleTest form is ran, it does this bizarre workaround to check if the SimpleTest library is installed or not. I presume this code pre-dates hook_requirements(), which will run only on installation, and/or when you hit admin/reports/status. Let's clean this sucker up.

#1

webchick - January 21, 2008 - 07:29
Status:active» patch (code needs review)

I don't imagine this is perfect yet, but I want to roll a patch for the drupalPost change and to do so I have to blow away what I'm working on. ;)

AttachmentSize
simpletest-hook_requirements-212415-1.patch5.15 KB

#2

Rok Žlender - January 21, 2008 - 08:42

This is a very clean way of checking for simpletest lib. But the problem is requirements check does not happen on module enable and so user can click on simpletest link in menu and is presented with a php errror or even WSOD if errors are not shown. This is obviously not cool. I like your idea very much and would like to see it happen so if there is some way other way. Can we check for error in simpletest requirements before we present simpletest form?

#3

webchick - January 21, 2008 - 18:51
Status:patch (code needs review)» patch (code needs work)

Right. This is not functionally equivalent. I was thinking this would prevent the module from being installed at all, but I don't think it does.

I'll do some pondering about this a bit more...

#4

moshe weitzman - March 25, 2008 - 00:34

This should prevent it from being installed in D6. D5 had a bug whereby 'install' phase requirements were not checked (i thought this was fixed). hook_requirements() definately has a $phase='install' which stops the install if there is a REQUIREMENTS_ERROR raised.

#5

boombatower - March 25, 2008 - 02:45
Version:6.x-1.x-dev» 7.x-1.x-dev

This looks like something that would work.

Is this still something we want to do?

If so can someone take the initiative and write it.

#6

webchick - May 14, 2008 - 15:12

Oh, I ran into this today on another module, and it turns out hook_requirements() has to be in an .install file, not the .module file. It might be that if this is re-rolled with the function in simpletest.install instead it could work.

#7

webchick - May 18, 2008 - 19:21
Version:7.x-1.x-dev» 6.x-1.x-dev
Assigned to:Anonymous» webchick

I'm moving back to 6.x, since 7.x (Drupal core) includes SimpleTest so this dependency will never be missing. Also, I'm assigning to myself, since that code utterly offends me on a basic level. :P

#8

webchick - May 18, 2008 - 19:59
Status:patch (code needs work)» patch (code needs review)

Re-roll. Seems to work this time. :)

AttachmentSize
simpletest-hook_requirements-212415-8.patch5.65 KB

#9

boombatower - May 18, 2008 - 22:49
Status:patch (code needs review)» fixed

Committed.

#10

Anonymous (not verified) - June 1, 2008 - 23:14
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.