Welcome to Geeklog, Anonymous Sunday, December 22 2024 @ 07:02 am EST

Geeklog Forums

Possible bug, COM_siteHeader


Status: offline

exaurdon

Forum User
Regular Poster
Registered: 08/13/03
Posts: 107
I'm running into an interesting problem.

I am calling COM_siteHeader from a plugin, and trying to capture the output. I was having weird problems, and eventually traced it down to the lines 912-915 of lib-common.php. Here, the parsed header template is eval'd and then returned.

Text Formatted Code
   
$tmp = $header->parse( 'index_header', 'header' );

    return eval( "?>" . $tmp );
    return $header->finish( $header->get_var( 'index_header' ));


 


Now, has anyone else had problems with this? The behavior I am gettings, is that if I remove the eval line, everything works as expected, however with the eval line, the header immediately is sent to teh user's browser, and cannot be captured in the return variable. Eval appears to have the following properties:

1. It writes directly to the browser.
2. It does _not_ return anything, unless a literal return statement exists.
3. You seem to need php tags around any php you want to evaluate.

So, when eval is called on that line, any non-php code (which generally includes the entire template) is immediately dumped to the browser, and nothing is returned. This means you cannot capture the output from COM_stieHeader, to output it in later code.

Fix:

I'd suggest that the php output buffering functions be used to catch the outptu from eval, and return this, instead of a return value. The code would look something like this:

Text Formatted Code
   
$tmp = $header->parse( 'index_header', 'header' );

    ob_start();
    eval( "?>" . $tmp );
    $headerBuffer = ob_get_contents();
    ob_end_clean();
    return $headerBuffer;
    //return $header->finish( $header->get_var( 'index_header' ));


 


I'm forced to make a change of this sort by my system requirements, but a permanent fix should probably be inserted into a future patch for geeklog.

Exaurdon

P.S> Sorry for another long post
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
You should have a look at CVS occasionally Mr. Green

bye, Dirk
 Quote

Status: offline

exaurdon

Forum User
Regular Poster
Registered: 08/13/03
Posts: 107
happy
Ok, my mistake

I'm still getting used to the distributed development/open source system.... I checked that the bug was in the latest release code, but I didn't check to see if it was already fixed for a future release. Well, I guess on the plus side, that means that you patched the bug 4 months before I reported it! What a great development team! Big Grin

Thanks Dirk,

Exaurdon
 Quote

All times are EST. The time is now 07:02 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content