1 (edited by jacobswell 2004-06-20 22:48)

Topic: $tpl_main should be global in message function

In some cases when message() function executed (not in punbb code I haven't found yet but some other user-made functions or even not in functions) the result is blank.

when $tpl_main is global in message function, everything is ok.

I think message() is a function, so letting $tpl_main global is more proper for removing future bugs.

Re: $tpl_main should be global in message function

Hmm, that's odd. Could you show an example of when the result is blank?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: $tpl_main should be global in message function

http://jacobswell.nared.net/punbb/wiki. … CreatePage

if you want to see the code here it is.
http://jacobswell.nared.net/upload/source.zip

Re: $tpl_main should be global in message function

But what call to message() leads to the blank screen?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

5 (edited by jacobswell 2004-06-20 23:32)

Re: $tpl_main should be global in message function

CreatePage.php is started like this. you can get the source by clicking above link

<?php
// default function
if ( $cookie['is_guest'] && $wiki_config['p_guests_read'] == '0' )
    message($lang_wiki['Login required']);

I had to spend so many hours to find out. I just thought it should come out. only to find that in message function $tpl_main is not defined. so I made it global. everything I expected displayed.

6 (edited by jacobswell 2004-06-21 03:59)

Re: $tpl_main should be global in message function

I've tested whole thing. if we include a file which location is in under 2 or more folders, $tpl_main has no value. for ex.

<?php
/*
** Tests message() function
*/

$pun_root = './';

require $pun_root.'include/common.php';

$pun_title = 'PunBB - Tests message function';
require $pun_root.'header.php';

require $pun_root.'include/temp/temp/temp.php';

require $pun_root.'footer.php';
?>

temp/temp/temp.php

<?php
message('Do you see me?');
?>

but when we declare $tpl_main as global in message(), it's OK.

Re: $tpl_main should be global in message function

Ah, of course! Thanks. I'll fix it in 1.2.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: $tpl_main should be global in message function

Fixed.

"Programming is like sex: one mistake and you have to support it for the rest of your life."