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
mariusvr
Registered User
Posts: 27
Joined: Mon Aug 25, 2008 10:10 am

Outbuffering for integration with Joomla and errors

Post by mariusvr »

Hi All,

I am the lead developer for JFusion and have been working on a visual integration of phpBB3 into Joomla itself. JFusion is a universal bridge software for Joomla that allow for user integration of many different softwares. The problem I am having is as follows:

phpBB3 specifically calls "exit" in /inlcludes/function.php file in the function exit_handler().However this causes all currently active code to be stopped including the Joomla code that is still running and trying to parse the phpBB3 output buffer. When I comment out the "exit" the phpBB3 output buffer is parsed successfully, but pages that require some sort of redirect (login, logout, posting, etc), have the page displayed in duplicate with the lower output having displaying extra SQL errors (see attached image).

It would be great if someone would point out to me where this additional page and error are generated. Or if someone could give me the username of one of the phpBB3 developers to PM.

Thanks, Marius
Attachments
phpbb3_error.gif
(37.51 KiB) Downloaded 8435 times

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 »

Add a hook for the exit_handler() to be able to continue your softwares operation.

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 the reply. Even when I change the exit statement to "return true;" (which is what essentially the hook would do). the problems still persist with the double pages and the SQL error. Therefore I don't think that adding an exit hook will help.

Anything else that I would be able to do?

Thanks, Marius

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 »

mariusvr wrote:Thanks for the reply. Even when I change the exit statement to "return true;" (which is what essentially the hook would do). the problems still persist with the double pages and the SQL error. Therefore I don't think that adding an exit hook will help.
Adding the hook only makes sure you are able to proceed processing data. ;) Why the "double page" problem occurs need to be identified, sure.
Anything else that I would be able to do?
maybe quoting the SQL error? :) From the screenshot i can only see that it must be connected to the error handler (E_NOTICE errors echoing the data and not going through the template there... the doubled page may be only the sql error "appended" to the page because the script did not exit). The Rokbridge for example circumvented problems within the error handler by using Joomlas error handler directly. You are able to define your own error handler (or jommla!s) by defining PHPBB_MSG_HANDLER before calling a phpBB script.

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 »

I have tried adding hooks and even trying out the same code that rokbridge uses, but with no success. phpBB3 still seems to stop any Joomla code at its exit hook.

Code: Select all

		/* set scope for variables required later */
		global $phpbb_root_path, $phpbb_admin_path, $phpEx;
		global $user, $auth, $template, $cache, $db, $config, $phpbb_hook;
		global $action, $module, $mode, $starttime;
		global $forum_id, $topic_id, $post_id, $user_id;

                //loaded the Rokbridge hooks as a test
                require_once(JPATH_ADMINISTRATOR .DS.'components'.DS.'com_jfusion'.DS.'plugins'.DS.'phpbb3'.DS.'hooks.php');

		define('PHPBB_DB_NEW_LINK' , true);
		define('PHPBB_EMBEDDED'    , true);
		define('PHPBB_MSG_HANDLER' , 'msg_handler_hook_register');

		// Get the output
		ob_start();
		$rs = include_once($index_file);
                $buffer = ob_get_contents();
                ob_end_clean();
Is there any code that I could try out to get these hooks up and running?

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 »

The problem you have is that there are many places where the code assumes that function to actually exit. So if the function returns it will continue with other code that was not supposed to be executed. So instead you need to execute all your code in that hook function (or call other functions you want to execute) and afterwards exit.

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

Re: Outbuffering for integration with Joomla and errors

Post by mariusvr »

Well that will be a problem, since JFusion runs completely within Joomla itself, which means there could be many tasks left inside Joomla to run. Whereas rokbridge is a script that runs completely outside Joomla and where it is easier to complete the buffer parsing in a hook.

Since there is no way to find out what else Joomla needs to run (different people run different modules), it won't be possible to run the remaining functions in a phpBB3 hook.

Is there a way where we can avoid an exit statement and still have a clean exit? The problem seems to occur in pages where there is a redirect (login,logout, post,etc). Would you be able to point me in the direction where the additional code is executed (that normally would be stopped with the exit statement). Maybe a return statement can be added at these locations which will stop the code cleanly and will allow for output buffers to work.

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 »

I doubt that's possible without major code changes in quite a few places.

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

Re: Outbuffering for integration with Joomla and errors

Post by mariusvr »

From what I understand it is not possible to catch a die or exit statement that is called from within an output buffer. When an exit statement is called all running code is stopped and all open output buffers flushed. Is there an other way to make it possible to get phpBB3 inside an output buffer?

It would be a pity if phpBB3 can not be made compatible with output buffers, as this is possible with the other major bb softwares (here is an SMF example embedded into Joomla with JFusion):

http://www.jfusion.org/index.php?option ... &jname=smf

It would be great if you know of a different way to get phpBB3 into an output buffer. I'll be happy to put in the time to get an alternative visual integration method up and running, as I believe phpBB3 is the best bb software available (we use it for our jfusion forums). However I might need a push in the right direction to overcome this problem.

Thanks, Marius

ToonArmy
Registered User
Posts: 335
Joined: Fri Mar 26, 2004 7:31 pm
Location: Bristol, UK
Contact:

Re: Outbuffering for integration with Joomla and errors

Post by ToonArmy »

What about a terminate argument to the exit handler, which can be used by redirect(). Errors can be trapped by checking for the IN_ERROR_HANDLER constant.
Chris SmithBlogXMOOhlohArea51WikiNo support via PM/IM
Image

Post Reply