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.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 1124580-9-prevent-arc-errors.patch | 3.95 KB | milesw |
Comments
Comment #1
tourendal commentedsubscribing
Comment #2
scor commentedMaybe 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.
Comment #3
scor commentedotherwise 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.
Comment #4
scor commentedactually, 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.
Comment #5
Anonymous (not verified) commentedSweet! 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.
Comment #6
milesw commentedMoving to new project, assigning to myself.
Comment #7
scor commentedthe 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...
Comment #8
milesw commentedSo 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.
Comment #9
milesw commentedThis 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?
Comment #10
Anonymous (not verified) commentedI 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.
Comment #11
Stefan Freudenberg commentedIs 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.