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
Elementl
Registered User
Posts: 2
Joined: Thu Aug 28, 2008 9:41 pm

Re: Outbuffering for integration with Joomla and errors

Post by Elementl »

radopod wrote:It is great to see the pace at which the phpBB Devs are replying back. :shock: Good to see that there might be a solution here than can prevent us from touching those hard coded phpBB Files. :D
I second this. Thanks for the help, I would love to see this feature for JFusion, Joomla, and PHPBB3!
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 could just kiss you now Kellanved!!!!!!!!!!!!!!!!!!!!!!!!!!

It works beautifully and phpBb3 is displayed inside Joomla without having to hack the trigger_error() behaviour. With the phpBB3 hook functionality, there is not even a need to create any file changes to the phpBB3 core :) It took me a while to figure out, but here is an example of how to add a simple phpBB3 hook (put the code in a hooks.php file and require it before you require the main phpBB3 code). Maybe the code below might save someone some time.

Code: Select all

<?php

//add the phpBB3 exit hook
function phpbb_hook_register(&$hook)
{	
	//Register the hooks
	foreach($hook->hooks as $definition => $hooks)
	{
		foreach($hooks as $function => $data)
		{
			$callback = $definition == '__global' ? $function : $definition.'_'.$function; 
			$hook->register(array($definition, $function), array('JFusionHook', $callback));
		}
	}
}

class JFusionHook
{
	function exit_handler($hook)
	{
               //throw an exception to allow Joomla to continue
               throw new Exception('phpBB exited.');
	}
}
THANKS AGAIN! Your solution works beautifuly and will allow for seamless integration between Joomla and phpBB3 without any hacks.

Marius
User avatar
Kellanved
Former Team Member
Posts: 407
Joined: Sun Jul 30, 2006 4:59 pm
Location: Berlin

Re: Outbuffering for integration with Joomla and errors

Post by Kellanved »

Maybe we'll stay one step short :D . Glad that it works!

See the docs/hook_system.html in the phpBB3 package for info on how to add hooks.

On a somber note : firing an exception will really harm performance; it is probably the single most expensive action in PHP.
No support via PM.
Trust me, I'm a doctor.
Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 371
Joined: Thu Sep 16, 2004 9:02 am
Contact:

Re: Outbuffering for integration with Joomla and errors

Post by Paul »

also dont forget that exceptions require at least php5, they dont exists in php4. so if you application requires php4 this method will not work unless you change the requirements.
mariusvr
Registered User
Posts: 27
Joined: Mon Aug 25, 2008 10:10 am

Re: Outbuffering for integration with Joomla and errors

Post by mariusvr »

PHP4 support has been dropped both by PHP itself and also by Joomla. Therefore Joomla users will run PHP5, as it is now a requirement.

Frameless integration will be one of the options offered for integration, also offered are an iframe wrapper and direct links. Each one of these will have its own advantages/disadvantages. Obviously large sites will go for a direct link and modify their phpBB3 style, but smaller sites with only a couple of thousand of users can use frameless visual integration if they wish.

Thanks, Marius
ssnobben
Registered User
Posts: 7
Joined: Tue Oct 10, 2006 9:24 pm

Re: Outbuffering for integration with Joomla and errors

Post by ssnobben »

Kellanved wrote:Maybe we'll stay one step short :D . Glad that it works!

See the docs/hook_system.html in the phpBB3 package for info on how to add hooks.

On a somber note : firing an exception will really harm performance; it is probably the single most expensive action in PHP.
firing an exception .... so what you mean that this solution really harm performance for Jfusion solution for Joomla/phpBB 3? hmmm there is no other solution?
User avatar
Dog Cow
Registered User
Posts: 271
Joined: Wed May 25, 2005 2:14 pm

Re: Outbuffering for integration with Joomla and errors

Post by Dog Cow »

ssnobben wrote: firing an exception .... so what you mean that this solution really harm performance for Jfusion solution for Joomla/phpBB 3? hmmm there is no other solution?
Throwing a new exception creates a new object, and that adds more overhead to the server, as in any other time a new object created. OOP takes more memory and processing than a procedural script, but overall, the gains outweigh the drawbacks.
mariusvr
Registered User
Posts: 27
Joined: Mon Aug 25, 2008 10:10 am

Re: Outbuffering for integration with Joomla and errors

Post by mariusvr »

Not all URL's are fully parsed using append_sid. There are a dozen of urls that only have the first half parsed and the remainder of the query is directly appended. This results in that Joomla SEF URL's are broken for most PM functions. For instance the reply URL looks like:

http://www.jfusion.org/index.php/compon ... &f=0&p=596

The same problem occurs when a user logs in and is redirected to the post reply window. In addition, the search action URL is fixed and append_sid is not called. Also the edit profile function in the UCP, uses the current filename as the action target of the form (which is a problem since the Joomla filename is not search.php).

I have overcome these problems with a regex of the buffer output and some clever coding in the append_sid function. However it would be great if all urls can be parsed completely in the future, as this will minimize server resources for rendering the phpBB3 frameless output. The great news is that I ironed all bugs with the phpBB3 frameless integration into Joomla and these improvements will be released to the public soon with a JFusion Beta.

Thanks, Marius
User avatar
Kellanved
Former Team Member
Posts: 407
Joined: Sun Jul 30, 2006 4:59 pm
Location: Berlin

Re: Outbuffering for integration with Joomla and errors

Post by Kellanved »

Technically, I agree that URL handling needs work, but that is something that will have to wait for 3.2 .
The easiest approachfor 3.0 would be hooking into the template display hook and rewriting the URLs based on their template variable names prior to phpBB generating output.
No support via PM.
Trust me, I'm a doctor.
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 would be willing to provide you with the code fixes for the URL generation, as I am getting familiar with the phpBB3 source code. These fixes would not affect a "normal" phpbb3 users, as they involve passing the all variables to the append_sid hook. phpBB3 is a great software and improving this could would be my way of saying "thank you". An example of such change is:

/included/ucp/ucp_pm_compose.php line 392

Code: Select all

	$s_action = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=$mode&action=$action", true, $user->session_id);
	$s_action .= ($msg_id) ? "&p=$msg_id" : '';
to:

Code: Select all

	
$s_action_url_raw = "{$phpbb_root_path}ucp.$phpEx", "i=$id&mode=$mode&action=$action";
$s_action_url_raw .= ($msg_id) ? "&p=$msg_id" : '';
$s_action = append_sid($s_action_url_raw , true, $user->session_id);
This will pass the complete URL to the append_sid hook and will allow for perfect URL parsing.

Then it would be great if I could work closely with the phpBB3 team to add some extra hooks. One particular hook that I have in mind is a phpbb3 auto-login hook. This hook would allow external applications to synchronise sessions, by passing the phpBB3 userid to phpBB3 itself of the user that should be logged into phpBB3. It has been successfully created for other forum softwares, so I can show examples of it in use if needed.

I assume that the bug tracker would be the best place to post these fixes? (http://www.phpbb.com/bugs/phpbb3/)

Thanks, Marius
Post Reply