The RDFx module depends heavily on ARC2 classes being available. Currently, if the ARC2 class is not available, using many RDFx functions will lead to fatal errors or WSOD.

Implementing hook_requirements()helps somewhat, but it's easy to imagine a scenario where a user has accidentally wiped out ARC (quite easy if it was installed in the rdfx module folder). They may never see the warning appearing on the Configuration page or status report, particularly if they're using another module that simply depends on RDFx -- SPARQL Views, for example.

There should be some extra measures taken to avoid fatal errors and white screens. Ideally this involves a combination of warning messages and better error handling.

CommentFileSizeAuthor
#9 1124580-9-prevent-arc-errors.patch3.95 KBmilesw

Comments

tourendal’s picture

subscribing

scor’s picture

Maybe we could register a shutdown function to output a message on WSOD page with drupal_register_shutdown_function(), though I'm not sure it works on WSOD.

scor’s picture

otherwise as discussed with Miles on skype, a lingering drupal_set_message() would no hurt and could give a clue to those running into a WSOD. It's annoying, but you should really not enable the rdfx module without ARC2.

scor’s picture

actually, it does work on WSOD! So that's all we need:
drupal_register_shutdown_function('rdf_shutdown') in rdf_init() which echoes the usual blurb about installing ARC2.

Anonymous’s picture

Sweet! This would be great to get committed, I'm guessing that you'll do it at the code sprint, but I can test if needed.

milesw’s picture

Project: Resource Description Framework (RDF) » RDF Extensions
Assigned: Unassigned » milesw

Moving to new project, assigning to myself.

scor’s picture

the only downside I can think of is that the shutdown function will insert the message on every page, causing bug on json requests. Maybe there is a way to check that we're on WSOD page...

milesw’s picture

So I did some testing but couldn't come up with a good way to utilize drupal_register_shutdown_function(). The problem is I can't see a way to only register a function when a fatal error occurs (WSOD). Normally the function is going to run at the end of every single Drupal request. Maybe I'm missing something obvious?

I think the ideal solution avoids fatal errors altogether. RDFx would recognize that ARC2 is missing, set error messages, and halt its processing gracefully. Normally you'd probably do this by throwing exceptions inside try/catch statements, but I'm thinking a single include function might do the job and keep code lean. It would be called at the top of each RDFx function that uses ARC2 classes and the calling function would bail if ARC couldn't be loaded.

milesw’s picture

Status: Active » Needs review
StatusFileSize
new3.95 KB

This patch adds a function called rdfx_include_arc() to load the ARC2 classes. Each RDFx function that involves ARC classes calls this function before utilizing ARC and bails if the classes could not be loaded. The include function is also called on hook_init(), so a nag message is always displayed when ARC is missing.

This is the best solution I can come up with right now. Any thoughts?

Anonymous’s picture

I haven't tested this yet, but one thought is that we might want to call it rdfx_include and pass arc as an argument. Then, if we end up utilizing other RDF libraries, we could just add those to rdfx_include.

Stefan Freudenberg’s picture

Is that really an issue we should deal with? If you see a WSOD first thing to do is look at your php error log. In development you can display errors instead of showing a blank screen.