PHP function "empty" bugged?

Discussion about the open-source Phalanger [?] project.

PHP function "empty" bugged?

Postby johnc » November 29th, 2013, 10:56 pm

We're using BuddyPress and experiencing problems. When diving into the code I discovered this:

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?

Postby Jakub Misek » November 30th, 2013, 2:42 pm

Hi,

it may be a bug in "empty". What is the value of $bp->groups->current_create_step?

Thanks,
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: PHP function "empty" bugged?

Postby johnc » November 30th, 2013, 7:20 pm

string(13) "group-details"
johnc
 
Posts: 45
Joined: March 24th, 2013, 9:17 pm

Re: PHP function "empty" bugged?

Postby Jakub Misek » December 1st, 2013, 1:39 pm

ok, thats weird, could you try more var_dumps whether everything else is as it is expected?
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: PHP function "empty" bugged?

Postby johnc » December 1st, 2013, 8:18 pm

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?

Postby Jakub Misek » December 2nd, 2013, 4:01 pm

At least the output of the script. Does it really output "assigning blank" ?

Thanks,
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: PHP function "empty" bugged?

Postby johnc » December 9th, 2013, 4:55 pm

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?

Postby Jakub Misek » January 2nd, 2014, 1:23 pm

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,
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: PHP function "empty" bugged?

Postby johnc » January 17th, 2014, 3:43 am

Sorry, I've been away for holidays.

The code is from BuddyPress, a WordPress plugin.
johnc
 
Posts: 45
Joined: March 24th, 2013, 9:17 pm

Re: PHP function "empty" bugged?

Postby johnc » January 17th, 2014, 5:40 am

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.
johnc
 
Posts: 45
Joined: March 24th, 2013, 9:17 pm

Next

Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 20 guests

cron

User Control Panel

Login

Who is online

In total there are 20 users online :: 0 registered, 0 hidden and 20 guests (based on users active over the past 5 minutes)
Most users ever online was 256 on March 28th, 2024, 9:42 am

Users browsing this forum: No registered users and 20 guests