After deleting a flag, rules administration interface was inaccessable.

The reason was flag.rules.inc loading the flag instance by name without testing for success, and then calling get_title() on the returned false value.

The attached patch made rules administration interface accessible again. Someone might want to look through the flags-code to eliminate similar flaws, because I think deleting flags is quite unusual and thus fairly untested.

CommentFileSizeAuthor
#3 flag-fatal_php_error_in_rules_when_deleting_flag-1451730-3.patch525 bytespavlosdan
flag.rules_.inc_.patch486 bytesAnonymous (not verified)

Comments

joachim’s picture

Thanks for the patch.

Needs tweaking for code style -- should be FALSE and needs space around the operator.

Needs review from some Rules users too!

pavlosdan’s picture

Hi,

I'm using Flag with Rules as well but I cannot replicate this issue. I have Flag 7.x-2.0-beta6 and Rules 7.x-2.1 installed on my site.

Steps I took to try to replicate were:

- Deleted a Flag that was stored in code (features). I was still able to access the Rules UI.

- Added a new Flag and created a Rule with a Flag event (content flagged) and actions to Display a Message on the site and Trim the Flag.

The only errors I got when I deleted the flag were on the Rules UI

Error: Data selector flagging_user for parameter flagging_user is invalid

Looked again... the error is happening when you try to edit the Rule that uses the deleted flag so only the interface relevant to the deleted flag is affected.

Applying the patch fixes the issue and allows you to edit the affected rule to remove the event and edit the action that are associated with the removed flag.

pavlosdan’s picture

Here's the same patch as above with the changes joachim suggested.

Patch made against the code in branch 7.x-2.x from git.

pavlosdan’s picture

Status: Needs work » Needs review

Forgot to set the status. Sorry.

joachim’s picture

Status: Needs review » Fixed

That's perfect, thanks!

Committed.

Issue #1451730 by pavlos_dan, Shnapoo: Fixed fatal PHP error in Rules administration after deleting a flag.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.