Comments

cyberswat’s picture

Status: Active » Needs review
dman’s picture

I think this is a valuable, constructive addition.
Though I'd prefer to look and see that the required file(s) was actually there - it's possible to unpack things incorrectly - eg into a subdirectory.

scor’s picture

Status: Needs review » Needs work

we should not care where the files are located, as long as the library ARC2 is available (in fact rdfx.module allows for 2 locations for the library to live at). class_exists('ARC2') should do it.

dman’s picture

yes, even better

Anonymous’s picture

Status: Needs work » Needs review
StatusFileSize
new834 bytes

Changed the check from is_dir to class_exists. I tested it with latest version of RDFx, and it works.

dan7’s picture

I tested the last patch and it worked for me as well.

scor’s picture

Status: Needs review » Needs work

I've committed the patch #5 for now so we have some safety net to remind people.

I'm leaving this issue open as we could display more information to the user on how to download ARC2 (check the D6 code). and how about a drupal_set_message() on the modules page with similar instructions? we could also display the version of ARC2 used in status report.

milesw’s picture

This patch adds the ARC version to the status report and installation instructions if ARC is not installed.

It also adds a very visible warning when ARC can't be loaded. I'm not sure we want to nag users this much, so I'm including a version without this message.

scor’s picture

This is great stuff Miles! I definitely like the improve status report!

Looking at your patch, it adds a message in hook_init() which will be displayed on every single page, indeed, not convinced we need to nag users so much, maybe we could only display it in some places only, like in the admin area, or in the admin RDF settings page. Status report should automatically display a red warning anyways. How about a message upon enabling the RDFx module at the top of the modules pages? That should do no harm...

Anonymous’s picture

How about a message upon enabling the RDFx module at the top of the modules pages?

I do something like this in Evoc, the text is "You can now import the core RDF vocabularies." It even shows up when people enable using Drush.

The only thing I would do differently is change the wording to "You can now import the core RDF vocabularies by going to....." so that people using Drush would know where to go.

milesw’s picture

So by default, if hook_requirements encounters a REQUIREMENT_ERROR, it will display a warning that points to the status report page, but this warning only appears in the Configuration section.

My reasoning for including the notice in hook_init() and making it so visible is that RDFx is quite dependent on ARC. It will fail very badly if you hit a page that uses ARC classes -- that's most config pages for RDFx. You will either get a fatal "Class not found" or even worse, a white screen. If someone just installed/enabled the module, I'd rather nag them than let them run into nasty errors like that. Am I being too cautious?

scor’s picture

Status: Needs work » Needs review

you're right, I quite like the idea of nagging people until they've installed it. Can't think of a use case where you would use rdfx without ARC2. I wonder how other modules which require a library achieve this type of thing.

Anonymous’s picture

I'm thinking instead of nagging people on every page, we might want to add better error handling. We could have a special include function... when ARC can't be found, then we give the message.

milesw’s picture

@linclark

Yep, you're right, that's the ideal solution.

I looked at the Apache Solr module and the Search Lucene module (D6 versions), which both have library requirements. Solr does not include any special measures for preventing fatal errors, it just relies on hook_requirements. Search Lucene also uses hook_requirements on both install and runtime, but is also setup to fail gracefully if the required library is missing. The author describes this in #525608: Add safeguards to prevent fatal errors when the ZF Components become unavailable.

I'll make a new patch that adds the 'install' phase for hook_requirements, but adding extra error handling should be a separate issue.

Anonymous’s picture

Sounds good.

Just a note, I did drush si on a site with RDFx and got the message because libraries wasn't enabled. We may want to add some help text below that mentions:

  1. Instructions for download
  2. That if libraries is disabled, might not be able to find ARC
milesw’s picture

Bah, this is tricky. By making ARC required during install phase, the module can't be enabled if ARC isn't present. This makes sense, except it also means the drush command for downloading ARC isn't available.

The check on install phase also only covers that very first installation. Subsequent re-enabling of the module won't be affected even if ARC is missing.

I'm thinking the second patch in #8 (without the nag message) is good enough for this issue. I opened a separate issue to address error handling.

Anonymous’s picture

I'm thinking that we probably want to keep the drush command, it really simplifies the download process. If we have proper error handling, do we still need hook_requirements?

milesw’s picture

Yeah, we still want hook_requirements for runtime so the status report shows whether ARC is installed properly. The Configuration page will also show a "There is a problem with your Drupal installation" message.

It's only hook_requirements at install phase that would interfere with the drush command.

The second patch in #8 simply adds more information to the status report per scor's comments in #7. If we get it tested we can commit it and close out this issue.

scor’s picture

let's not do hook_requirements during install then, the drush command is really handy, and cannot be used before installing the rdf module (drush used to allow that but not anymore).

Anonymous’s picture

Status: Needs review » Fixed

Ahh, I didn't realize that there were two phases. Ok, this is committed. I just made a small wording change to make the install instructions a little easier for noobs.

Fixed with commit http://drupalcode.org/project/rdf.git/commit/0df6e92

milesw’s picture

If you ever have to deal with hook_requirements for install phase, make sure to put it in the .install file instead. Seems like many have lost hair over that one. :)

Thanks for wrapping this one up!

Status: Fixed » Closed (fixed)

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

milesw’s picture

Project: Resource Description Framework (RDF) » RDF Extensions