function flag_friend_unfriend_form() uses $user but theres no global definition
Other just isset() for often lost values
I cant find using $token but it declared as parameter in some functions
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | ff-message-error.patch | 1.34 KB | andypost |
| #5 | ff-message-error.patch | 3.44 KB | andypost |
| ff-notices.patch | 2.6 KB | andypost |
Comments
Comment #1
sirkitree commentedThanks andpost. Couple of questions:
What is the advantage to using isset() in so many places over the way it works now?
Is there a better advantage to using empty() instead?
How the heck was my unfriend form working before!?! LOL
Comment #2
andypostThe main difference between empty-isset and current implementation that first check value for existence!
When you check array value by key
$token = $_REQUEST['token'];andtokendoes not exists in$_REQUESTphp throws notice which show in development and thrashes php_error_log on production!!!Next -
empty()checks value butisset()checks existence - in current patch suppose better to check existenceAbout
$user- broken only this logic branch:I dont know how it was working before the patch but it is really a BUG
Comment #3
andypostThis bug leads to flag_message table not cleared on friend/unfriend
Comment #4
andypostAbout $token
code in flag.module set no token on confirm form! so notice throws everytime
Comment #5
andypostAfter little debugging code I find why message was not cleared and bring error.
1) there was no call to
flag_friend_message()in submit when user cancel own request2) when someone aprove request message was stored in DB oposite to be cleared (so every second and next approve throws a error #435448: error message when adding friends)
3)
flag_friend_unfriend_form()always determines wrong statusThis patch is little complex but all this fixes should go together.
PS: here 2 fixed notices, as I describe before - they are very noisy when you debug.
Comment #6
sirkitree commentedI agree with the changes in hunk 1 and 2 of this patch.
Hunk 3 should not be using isset() as that variable is always going to be set there, it is specifically defined within the form being passed into the submit function. Therefor this should be checking !empty() instead but this is really the same as what is already there and should not throw any errors. Core actually does this in quite a few places. The second part of this hunk you make no mention as to why only checking if the $status === FLAG_FRIEND_PENDING instead of !== FLAG_FRIEND_BOTH is any better and I'm not convinced that it should be changed.
Hunk 4, 5 and 6 look good.
Please review hunk 3 again to address my concerns, and thank you for your work thus far.
Comment #7
andypostAbout hunk #3
1) Take a look at flag_friend_form_flag_confirm_alter()
'flag_friend_message' added only when flag (first request) and approve (to send a message) all other states have no this key in form array so not error but notice is generated and isset() just checking "is message input in form" - this is a cases: pending and approve.
2) Next
$status === FLAG_FRIEND_PENDING- because only pending and approve states come inside but only pending state should clear the message! If you leave this as it now (!== _BOTH) code will insert message with fcid=0 which throw an error "duplicate entry" (on approve)3)
elseif ($status === FLAG_FRIEND_PENDING) {additional branch for clearing {flag_message} when sender cancels own request.Suppose we need someone with debugger who will take a debug view at this ATM. I've done this already - so please leave status of this issue "need review"
Maybe you have no time to dig into this piece of code too closely...
Comment #8
sirkitree commentedThank you andypost! Comitted!
Comment #9
andypostStill not agree with leaving
This should be fired only in FLAG_FRIEND_PENDING but #message still not empty when decline - and this bring error.
Comment #10
andypostThis still not fixes a bug with inserting empty messages
As I write before -
empty()does not check for existence - this is a case when user send invite or other side approve request (only in this states form has #message) so no matter is it empty or not we just need to send email and clear the message if PENDING not !=BOTHComment #11
andypostChanging title to be more clear about patch
Comment #12
sirkitree commentedoops, sorry - I thought i had those in that commit. fixed.