PHP function "empty" bugged?
11 posts
• Page 1 of 2 • 1, 2
PHP function "empty" bugged?
We're using BuddyPress and experiencing problems. When diving into the code I discovered this:
The var_dump calls are mine. When $bp->groups->current_create_step is non-empty the else branch is still executed and $current_create_step results as a blank string.
- Code: Select all
function bp_get_groups_current_create_step() {
global $bp;
var_dump($bp->groups->current_create_step);
if ( !empty( $bp->groups->current_create_step ) ) {
var_dump("assigning value");
$current_create_step = $bp->groups->current_create_step;
} else {
var_dump("assigning blank");
$current_create_step = '';
}
var_dump($current_create_step);
return apply_filters( 'bp_get_groups_current_create_step', $current_create_step );
}
The var_dump calls are mine. When $bp->groups->current_create_step is non-empty the else branch is still executed and $current_create_step results as a blank string.
- johnc
- Posts: 45
- Joined: March 24th, 2013, 9:17 pm
Re: PHP function "empty" bugged?
Hi,
it may be a bug in "empty". What is the value of $bp->groups->current_create_step?
Thanks,
it may be a bug in "empty". What is the value of $bp->groups->current_create_step?
Thanks,
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: PHP function "empty" bugged?
string(13) "group-details"
- johnc
- Posts: 45
- Joined: March 24th, 2013, 9:17 pm
Re: PHP function "empty" bugged?
ok, thats weird, could you try more var_dumps whether everything else is as it is expected?
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: PHP function "empty" bugged?
What do you want var_dumps of? There's only one value involved in this function.
- johnc
- Posts: 45
- Joined: March 24th, 2013, 9:17 pm
Re: PHP function "empty" bugged?
At least the output of the script. Does it really output "assigning blank" ?
Thanks,
Thanks,
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: PHP function "empty" bugged?
The code pasted outputs:
- Code: Select all
string(13) "group-details"
string(15) "assigning blank"
string(0) ""
- johnc
- Posts: 45
- Joined: March 24th, 2013, 9:17 pm
Re: PHP function "empty" bugged?
sorry for the delay, but this is weird. I can't replicate the issue.
The code sample you've provided above, is it a console app? Could you attach compiled EXE/DLL or the complete project?
Thank you,
The code sample you've provided above, is it a console app? Could you attach compiled EXE/DLL or the complete project?
Thank you,
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: PHP function "empty" bugged?
Sorry, I've been away for holidays.
The code is from BuddyPress, a WordPress plugin.
The code is from BuddyPress, a WordPress plugin.
- johnc
- Posts: 45
- Joined: March 24th, 2013, 9:17 pm
Re: PHP function "empty" bugged?
So I spent a bit of time tonight trying to write a reproduction of the issue and completely failing.
I have managed to write a workaround hack: I replaced all calls to empty with calls to a custom PHP function, which in turn calls a method in a C# compiled DLL, which finally calls the static PHP.Core.PhpVariable.IsEmpty. I'm not sure if the call through the custom PHP function is required or not but it does work this way.
I have managed to write a workaround hack: I replaced all calls to empty with calls to a custom PHP function, which in turn calls a method in a C# compiled DLL, which finally calls the static PHP.Core.PhpVariable.IsEmpty. I'm not sure if the call through the custom PHP function is required or not but it does work this way.
- johnc
- Posts: 45
- Joined: March 24th, 2013, 9:17 pm
11 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 38 guests