I originally wanted to take over #585046: 'CAPTCHA required' even though Mollom servers don't respond for this patch, but then realized that that issue is slightly different and perhaps needs a different solution to handle the edge-case, if possible at all. Not sure yet.
The goal of the changes here is to introduce a unique function that determines and stores the current healthiness of the module's configuration.
- Prevent needless client-server communication
- Prevent triggering the fallback mode under wrong circumstances
- Fix the bug that Mollom never reports invalid API keys, always network errors only.
To do this, we want to:
- Implement hook_requirements() to inform the user about configuration and network problems
- Implement a helper function to determine the current status, but also store it, so we know when the module is operable and when it is not.
- Use the helper function for hook_requirements(), but also for the global Mollom settings page.
Attached patch is work in progress. Feedback welcome, though.
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | mollom-DRUPAL-6--1.status-positive.20.patch | 3.18 KB | sun |
| #19 | mollom-DRUPAL-6--1.status-positive.19.patch | 1.04 KB | sun |
| #14 | mollom.status.14.patch | 25.39 KB | sun |
| #13 | mollom-DRUPAL-6--1.status.11.sync_.patch | 9.27 KB | sun |
| #11 | mollom-DRUPAL-6--1.status.11.patch | 5.49 KB | sun |
Comments
Comment #1
sunbtw, deleting the server list was the cause for the bug that invalid API keys were never reported.
Powered by Dreditor.
Comment #2
sunAlso, I removed this positive status message, because it can be totally wrong -- when no forms are protected.
Powered by Dreditor.
Comment #3
sunComment #4
sunPosting what I have now... still failing tests (due to [my] wrong usage of xmlrpc server functions... bad/non-existing documentation... cross-linking #621618: Revamp MAINTAINERS.txt...)
Comment #5
dries commentedThis change is a bit sloppy, IMO, but probably acceptable.
Wouldn't it be better if we moved this to an else-statement at the end of the if-elseif-elseif block?
I found 'operable' to be an awkward word.
Would be nice to document the return type.
Flood protection doesn't seem necessary to me. We should just use the API in a smart way.
I'd maybe write 'Updated server list:'?
Comment #6
sunAll tests pass now. Will implement the main change now, which isn't contained yet.
If "operable" is not acceptable (IMHO, it's the most precise term), then the following synonyms would be possible: ready, usable, workable, verified, ok, working, overall, summary, total, ...
Out of those options, I'd choose "operable" or "ready".
The goal is to have a positive term (not negated) that indicates the overall status of the module's configuration and communication, and will be used as $status['operable'].
I've also suggested the (ugly) workaround idea to return two different data types depending on the overall status; simply $status === TRUE if everything is alright, or $status == array(...) with individual indicators as array keys if something is wrong. However, just mentioning this, I don't really like the idea either ;)
This is the identical watchdog message that is already used some lines below in that function; also keeping it as short as possible but still meaningful.
Powered by Dreditor.
Comment #7
sunok, now including the final change.
Comment #8
sunAlrighty - this new test finally reveals and proves the wrong error handling of the Mollom server response in case we have invalid keys.
Running the new "Status handling" test, we get the following errors when trying to save the settings form with 'foo' + 'bar' as keys:
The problem obviously is that we are invoking mollom.verifyKey, but we have an empty server list at this point. Since mollom.getServerList also requires valid keys, mollom.verifyKey is not even invoked, because we don't have a server list. Hence, we get a NETWORK_ERROR in the end - instead of a MOLLOM_ERROR.
Comment #9
sunAlright, this one should work. Also contains a big @todo, but not sure whether it needs to be resolved here. Reviews welcome.
Unrelated to this patch, I finally got this 1 fail about a session_id mismatch in the "Server responses" test (once). Based on the debug output in the test log, it seems like the returned session_id changed without any server redirect or refreshing of the server list. That should not happen - or at least, we currently expect it for the two aforementioned occasions only. This is not tackled in this patch and belongs into a separate issue.
Comment #11
sunSo we discussed to use different return values for _mollom_status() --- however, actually not sure whether this is really prettier.
Comment #12
dries commentedCommitted the patch. The fail is because of another problem, unrelated to this patch. Thanks sun!
Comment #13
sunClarified and cleaned up _mollom_status() a bit.
Additionally, syncing tests with HEAD.
Comment #14
sun#13 is RTBC. And attached patch applies the same changes to HEAD.
Comment #16
dries commentedGreat. I committed the patch in #13. Will commit the patch in #14 in a bit -- want to review it separately.
Comment #17
sunhttp://drupal.org/cvs?commit=321704
Comment #19
sunRe-introducing the positive status message.
Comment #20
sunAdjusting tests accordingly.
Comment #21
dries commentedCommitted!
Comment #22
sunNeeds forward-porting though. :)
Comment #23
dries commentedHas been ported now.