Outbuffering for integration with Joomla and errors

Discussion of general topics related to the new version and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Forum rules
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Post Reply
User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Berlin, Germany
Contact:

Re: Outbuffering for integration with Joomla and errors

Post by naderman »

I'm not sure you understand the problem, the following code will simply not allow returning:

Code: Select all

if (something)
{
    trigger_error(...);
}
code that must not be executed if something is true
phpBB is not built in a way that it will always run to the very end of the file which is what mariusvr is asking for. However one can definately make this work with a hook that calls whatever code is supposed to run after the inclusion.
User avatar
Acyd Burn
Posts: 1838
Joined: Tue Oct 08, 2002 5:18 pm
Location: Behind You
Contact:

Re: Outbuffering for integration with Joomla and errors

Post by Acyd Burn »

I do not think we have that many occurrences of this. The modules can just return (theoretically).

Image
mariusvr
Registered User
Posts: 27
Joined: Mon Aug 25, 2008 10:10 am

Re: Outbuffering for integration with Joomla and errors

Post by mariusvr »

Thanks for your fast responses! It is great to have such quick interactions with developers of phpBB3.

Isn't that why the "else" command was invented?

Code: Select all

if (something)
{
    trigger_error(...);
} else {
    code that must not be executed if something is true;
}
Rather than following code used in ucp.php:

Code: Select all

switch ($mode)
{
	case 'login':
              //code that needs to done with login
	break;
	case 'logout':
              //code that needs to done for logout
	break;
}
//execute the code if the application hasn't died
some_code;

Wouldn't it be better to have a default option in the switch that would call some code if something didn't match? Such as:

Code: Select all

switch ($mode)
{
	case 'login':
              //code that needs to done with login
	break;
	case 'logout':
              //code that needs to done for registration
	break;
        default:
        default_function();
}
//execute the code if the application no matching action was found
function default_function(){
       some_code;
}
I realize that this would involve rewriting the PHP files in the phpBB3 home directory, but this would allow for the code to end cleanly without the necessity of a die/exit statement. I have tried changing routing the error messages to a Joomla function, but this still results in the "extra" code being executed. I can't seem to stop the extra phpBB3 code, without stopping all the Joomla code.

It is impossible to find out what code needs to be executed after the phpBB3 output buffer (as people will have different Joomla configurations). Therefore it won't be possible to execute the remaining code in a phpBB3 exit hook.

Thanks, Marius
User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Berlin, Germany
Contact:

Re: Outbuffering for integration with Joomla and errors

Post by naderman »

Well yeah as I said earlier, with quite some massive amount of rewriting/restructuring one could make this possible, but really the first method is simply a little easier to read, and should normally not stop you from doing anything. I'm pretty sure you are able to use the hook for what you want to achieve.
mariusvr
Registered User
Posts: 27
Joined: Mon Aug 25, 2008 10:10 am

Re: Outbuffering for integration with Joomla and errors

Post by mariusvr »

Thanks Naderman for the reply.

I can't use the phpBB3 exit hook (like the Rokbridge), as it is impossible to know what other functions need to be executed inside Joomla itself. (Different people have different configuratations and have different modules). I couldn't redirect the errors to Joomla without stopping the "extra" phpBB code, but that could also be to my own coding limitations.

For the time being I will have to put the visual integration of phpBB3 into Joomla on hold, as it is impossible to stream phpBB3 itself into an output buffer without all code being stopped.

Can I put a request down to make phpBB3 have a clean exit in the future? There are only a couple of pages affected involved (login, logout, new postings, etc) and the display of forums/posts are unaffected.

Thanks, Marius
User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Berlin, Germany
Contact:

Re: Outbuffering for integration with Joomla and errors

Post by naderman »

mariusvr wrote:I can't use the phpBB3 exit hook (like the Rokbridge), as it is impossible to know what other functions need to be executed inside Joomla itself. (Different people have different configuratations and have different modules). I couldn't redirect the errors to Joomla without stopping the "extra" phpBB code, but that could also be to my own coding limitations.
Well obviously there is code that executes whatever functions depending on the config/modules need to be executed so you would only have to jump to that code from within the hook.
mariusvr
Registered User
Posts: 27
Joined: Mon Aug 25, 2008 10:10 am

Re: Outbuffering for integration with Joomla and errors

Post by mariusvr »

naderman wrote:
mariusvr wrote:I can't use the phpBB3 exit hook (like the Rokbridge), as it is impossible to know what other functions need to be executed inside Joomla itself. (Different people have different configuratations and have different modules). I couldn't redirect the errors to Joomla without stopping the "extra" phpBB code, but that could also be to my own coding limitations.
Well obviously there is code that executes whatever functions depending on the config/modules need to be executed so you would only have to jump to that code from within the hook.
The Joomla code would have half way during the rending of the templates and its components. Since it would be half way it is impossible to know what has been executed and what has not. There are big differences between different templates that users use, therefore you can't just launch the remaining Joomla code with a phpBB3 exit hook. Joomla is very modular, which means it is impossible to have a static function call to resume some code half way inside the template rendering.

Therefore it won't be possible to use the phpBB3 exit hook to render the remainder of Joomla before, phpBB3 terminates all code

Thanks, Marius
mariusvr
Registered User
Posts: 27
Joined: Mon Aug 25, 2008 10:10 am

Re: Outbuffering for integration with Joomla and errors

Post by mariusvr »

I'm not the type of person to complain without offering a solution :)

The error messages can be suppressed by changing the exit; statement into error_reporting(0); in /includes/function.php

However this still results in the login page being displayed "double" on login and logout. This again is easily solved by adding a default: at the bottom of theswitch command in ucp.php, for the blank login form not being displayed when a valid mode was found. Then moving the closing bracket of the switch function to the bottom of the ucp.php file.

This is easy to implement for a programmer, however a end user will have problems making these adjustments themselves. I don't really feel that it is practical (or legal) for me to create modifications of the phpBB3 php files in the home directory and offer these as a download on the JFusion site. Therefore I hope that these small code changes can be implemented in a future release of phpBB3.

Would you be interested in making phpBB3 have a clean exit in the future?

Thanks, Marius
User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Berlin, Germany
Contact:

Re: Outbuffering for integration with Joomla and errors

Post by naderman »

Well I certainly don't see us using your method, suppressing error messages, doesn't mean that everything works fine. Whether or not - and if when - we will change phpBB's exit points still has to be decided.
mariusvr
Registered User
Posts: 27
Joined: Mon Aug 25, 2008 10:10 am

Re: Outbuffering for integration with Joomla and errors

Post by mariusvr »

What I am asking for if to use the default function when using a switch statement and I am not asking for you to suppress all errors by default. By using a simple code change phpBB3 would be able to have a clean exit without the need to die all of the code with an exit statement.

All current phpBB3 functions would remain the same, including exit hooks. But it would enable phpBB3 to have a clean exit. All I am asking for is if the php files in the phpBB3 home directory do not automatically assume that phpBB3 will die the code during the switch statement.

Like I said it is very easy to implement with the use of "default:" in the switch statements. After a trigger_error statement you would have to add "return;" and replace the exit commands in these files with return as well.



Thanks, Marius
Post Reply