Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Required for #903770: Integrate with Mollom moderation and allows us to clean up some other existing (feedback/report to Mollom) functions as well.
Comment | File | Size | Author |
---|---|---|---|
#23 | mollom-DRUPAL-6--1.form-id.23.patch | 21.89 KB | sun |
#22 | mollom-DRUPAL-6--1.form-id.22.patch | 21.78 KB | sun |
#21 | mollom-DRUPAL-6--1.form-id.21.patch | 19.93 KB | sun |
#20 | mollom-DRUPAL-6--1.form-id.20.patch | 20.45 KB | sun |
#19 | mollom-DRUPAL-6--1.form-id.19.patch | 19.92 KB | sun |
Comments
Comment #1
sunInitial stab. My hope is to get this ready for the new release tomorrow already.
Comment #2
Dries CreditAttribution: Dries commentedWhat is the motivation for this patch? I looked at #909484: Add {mollom}.form_id and store originating form_id for session values but it didn't provide any motivation for this patch either. Having context helps with the review process.
Comment #3
sunWe're starting to make further use of the session data we are getting from Mollom. Everything in the module is tied to a form_id in the meantime, except for the session data stored in {mollom}.
Right now, in various places, we are loading the locally stored data, so as to perform an action on it. However, the process of getting from that {mollom} data back to the originating form_id is a painful job that requires lengthy loops and lots of code lines. We need to get back to the form_id, to be able to load the registered Mollom form information, to e.g. figure out whether there is a 'report access callback' to invoke, or a registered 'delete form' to integrate with.
More specifically, #903770: Integrate with Mollom moderation will only get a Mollom session hash from mollom.com, so that's the only information we have. With the session hash, we can load our locally stored data, but as of now, that data only contains an entity type and entity ID. Thus, to be able to report content to Mollom, or to display or execute the delete (confirmation) form, we have to invoke mollom_form_list() to collect all registered forms, and for each registered form, compare the form information with the data of the session, in order to find the corresponding form information that belongs to the session. So only after taking this long code path of trying to find the originating form information, we can actually perform the desired action.
With a {mollom}.form_id, it gets as simple as this:
And this is an example for the painful ride we currently have:
Comment #4
Dries CreditAttribution: Dries commentedOK, that looks like a really good idea.
Reviewed the patch and it looks good.
There is one @todo in the code though -- probably something that something we want to tackle first?
Comment #5
sunTo facilitate testing, let's do this for HEAD first.
Comment #6
sunOK, I think this is ready to fly.
Comment #7
Dries CreditAttribution: Dries commentedHeavy duty upgrade path. Committed to CVS HEAD.
Comment #8
sunSorry, working on the other issue revealed that a style $GLOBALS condition remained in mollom_data_save().
Comment #9
sunPlus, mollom_data_save() should allow to use re-save existing data.
Comment #10
sunRan into one more bug in trying to re-save existing $data. Actually, it would be a good idea to finally change the {mollom}.session column into {mollom}.session_id... if you'd be on board with that.
Comment #11
Dries CreditAttribution: Dries commentedI'm not a fan of this kind of casting. I much prefer to pass in an element of a certain type instead of accepting fuzzy parameters. Ditto for the return value.
Happy to rename to session_id.
Powered by Dreditor.
Comment #12
sunThanks for reviewing! I agree that the casting is poor design. Only used it, because I didn't have time to analyze whether $data should be an array or an object. If we enforce it for mollom_data_save(), then all other mollom_data_* functions and calling code should follow. As of now, I can only guess that an array makes more sense, since the data is derived from XML-RPC, resp., $form_state, which are both arrays. However, I need to double-check all existing code to make sure it's the right decision.
Comment #13
sunSo I've analyzed our current and also upcoming usage of $data, and also took into account best practices for data types in Drupal core, and figured that $data should be an object, and we also want to explicitly require the $entity, $id, and $form_id properties to be set on $data, instead of overloading those individually via function arguments.
I'm going to resolve the @todo of renaming the two columns 'session' and 'did' now, which should ideally be part of this patch.
All of this is an API change, but I don't think (and actually hope) that no one is using those functions.
Comment #14
Dries CreditAttribution: Dries commentedThis looks good. Renaming those looks good too.
Comment #15
sunI actually expected a giant patch now, but the size of the attached one basically proves that the module provides really good API functions.
Comment #17
sunForgot to also update the 'session' table index.
Comment #18
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #19
sunCumulative backport to D6. Note that I've committed two small follow-up fixes for the existing update path in HEAD (typos).
Comment #20
sunFixed stale code in mollom_data_save().
Comment #21
sunoh my, sorry - forgot to revert disabled test class methods.
Comment #22
sunFixed lots of hiccups + learned something new about the D6 version: We only happen to store Mollom session date for nodes and comments in D6, because we implement dedicated hook_nodeapi() and hook_comment() hooks.
Comment #23
sunMore bullet-proof. Ran tests manually.
Comment #24
Dries CreditAttribution: Dries commentedCommitted to CVS DRUPAL-6--1. Thanks sun.
Comment #25
Dries CreditAttribution: Dries commentedOr not. Firewall didn't let my CVS commit through. Feel free to commit on my behalf.
Comment #26
sunThanks for reviewing! Committed to D6.
A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.