This is useful functionality if you need it - and I've just encountered a need for it! So thanks.
The problem I ran into is that I only need to comment permissions by role on one content type, but the module was stopping comments working on unmanaged types. The culprit is this code:
foreach ($types as $type) {
if ($build['#bundle'] == $type) {
The value of $type for unmanaged types is 0, so this comparison defaults to numeric. $build['#bundle'] is the content-type name and as a non-numeric string evaluates to 0, so the condition is true for all unmanaged types. The result is the comment form is never shown.
It can be fixed simply by changing to:
foreach ($types as $type) {
if ($type && $build['#bundle'] == $type) {
I've added this test to all similar lines of code to avoid pitfalls and pointless string comparisons.
There is also inconsistent testing for whether $types[$node->type] is non-0 (occurs several times). In some places isset($types[$node->type]) is used, which is wrong - isset() returns true for a 0 value. The safest test is !empty($types[$node->type]), I've changed all occurrences to this.
There's also some rather crazy indenting of braces which I've tidied up. This is currently working for me, patch to follow.
Comment | File | Size | Author |
---|---|---|---|
#2 | unmanaged-types-2890104-2.patch | 4.08 KB | RickJ |
Comments
Comment #2
RickJ CreditAttribution: RickJ commentedPatch
Comment #4
sdstyles CreditAttribution: sdstyles at FFW commentedFixed in 7.x-2.x branch.
Thanks!