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.
Was testing different conditions, and typed in to the browser the URL of a forum comment edit page.
However, I entered the URL incorrectly... instead of this:
CORRECT:
/comment/553223/edit
I flipped the second and third segments:
INCORRECT:
/comment/edit/553223
I got an "Access Denied" page as I expected, but also received an error from Forum Access:
Notice: Trying to get property of non-object in _forum_access_comment_access_callback() (line 118 of /sites/all/modules/forum_access/forum_access.module).
It is passing in the string of "edit" as $comment
, which is going to fail. The attached patch checks if $comment
is a string, and returns FALSE if it is.
Please review, thanks.
Comment | File | Size | Author |
---|---|---|---|
forum_access-comment_edit_url_error-1.patch | 700 bytes | ron_s | |
Comments
Comment #2
salvisNice catch, thank you!
I think it would make sense to use !is_numeric() rather than is_string().
A similar issue probably exists for nodes, too.
Please check whether the issue in in D8, too — D8 needs to go first...
Comment #3
ron_s CreditAttribution: ron_s commentedWhat if you want to use the function in the future to pass in
$comment
as an object? I think that's the reason why other functions allow it to beis_numeric
and then check foris_string
. If it's an object, it will continue through without running the conditionals.If you feel strongly it should be
!is_numeric
that's fine, can change it, but wanted to explain there was a reason for choosingis_string
.I understand D8 is primary, but it's just not our focus right now. You can check my profile to see how many D7 patches we have submitted in the last few months... there are quite a few. We'll eventually start looking at D8, but it won't be for a bit yet.
Comment #5
salvisThank you, ron_s, and sorry about taking so long.
Comment #6
salvisAFAICS, D8 gives me a Page Not Found, so it doesn't seem to be an issue for D8.