Bug + Fix: Redirection to topic does not work after a login

This is an archive of the phpBB 2.0.x support forum. Support for phpBB2 has now ended.
Forum rules
Following phpBB2's EoL, this forum is now archived for reference purposes only.
Please see the following announcement for more information: viewtopic.php?f=14&t=1385785
User avatar
uncle.f
Registered User
Posts: 253
Joined: Thu Mar 25, 2004 11:42 am
Location: Purple Yonder
Contact:

Bug + Fix: Redirection to topic does not work after a login

Post by uncle.f » Mon Jul 25, 2005 5:01 pm

Problem:

* Installed brand new 2.0.17, no mods/addons
* Logged in as 'admin', changed the forum "Test Forum 1" to be "Private"
* Logged out.
* Tried to access the only topic present by default: http://.../bb/viewtopic.php?t=1
* Got a login box (as the forum is private now)
* Logged in again as 'admin'
* Got a message "The topic or post you requested does not exist"


Cause:

When I am presented with a login box, the full url reads: http://.../bb/login.php?redirect=viewtopic.php&p=0&start=0
which is obviously incorrect, as it is about to redirect me to a post #0 instead of topic #1
Looking into viewtopic.php reveals the following:

Code: Select all

//
// Start initial var setup
//
$topic_id = $post_id = 0;
if ( isset($HTTP_GET_VARS[POST_TOPIC_URL]) )
{
	$topic_id = intval($HTTP_GET_VARS[POST_TOPIC_URL]);
}
else if ( isset($HTTP_GET_VARS['topic']) )
{
	$topic_id = intval($HTTP_GET_VARS['topic']);
}

if ( isset($HTTP_GET_VARS[POST_POST_URL]))
{
	$post_id = intval($HTTP_GET_VARS[POST_POST_URL]);
}
and then

Code: Select all

$redirect = ( isset($post_id) ) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id";
This does not make any sense. Because of this line: $topic_id = $post_id = 0;
$post_id is always set, at least to 0, which means that POST_TOPIC_URL . "=$topic_id" will never be executed.

I believe this "zeroing-out" was introduced in 2.0.6, it is funny no one noticed it since.

Fix:

Code: Select all

#
#-----[ OPEN ]---------------------------------------------
#
viewtopic.php

#
#-----[ FIND ]---------------------------------------------
#
$topic_id = $post_id = 0;

#
#-----[ REPLACE WITH ]---------------------------------------------
#
unset($topic_id, $post_id);

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
Last edited by uncle.f on Fri Jul 29, 2005 12:25 pm, edited 4 times in total.

gasteropod
Registered User
Posts: 270
Joined: Thu Mar 24, 2005 10:37 am
Location: Hampshire, UK

Post by gasteropod » Tue Jul 26, 2005 11:55 am

Are you running php5? If so then this is not supported and although some people seem to indicate they are running this without trouble others do not and the "official" answer is that php5 is not supported. The next Olympus release will support php5 out of the box.

There is a php5 flavour which can be found at http://phpbb-php5mod.sourceforge.net/ if you wish to use the existing phpbb release with php5.

It does look to me like you have a valid point though. From this code extract it looks like the variable will always be set although I have not looked at the code other than what you posted here. If you wish to report this as a bug then you should be able to do this soon. From the 2.0.17 release announcement:
We also intend to open our private bugtracker system to the public for reporting 2.0.x bugs within the next days.
Use the Support Request Template when asking for help.

User avatar
uncle.f
Registered User
Posts: 253
Joined: Thu Mar 25, 2004 11:42 am
Location: Purple Yonder
Contact:

Post by uncle.f » Tue Jul 26, 2005 12:11 pm

Just to dismiss the PHP5/PHP4 argument let me point that after some testing I can conclude that both PHP4 and PHP5 (latest release versions) behave the same way when it comes to isset() on a variable with value = 0.

This issue (if you don't want to call it a bug) will remain whether PHP4 or PHP5 is being used.

gasteropod
Registered User
Posts: 270
Joined: Thu Mar 24, 2005 10:37 am
Location: Hampshire, UK

Post by gasteropod » Tue Jul 26, 2005 12:25 pm

Yes, I agree.

I see this problem on my php4 system and using unset as you suggest resolves this. php4/php5 is irrelevant to this. Looking at the code it looks as if having the variables unset is expected as long as one of them is set since we also check for this:

Code: Select all

if ( !isset($topic_id) && !isset($post_id) )
{
  message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
}
This does not make sense unless they can be unset. I would guess that the line to set them to zero was added at some point when unset() should have been used.

I'd call this a bug and it needs to be posted into the bugs database when open. I'm going to put this into my local CVS repository for my forum so thanks for the heads up. Let's hope a support team member sees this and it gets fixed.
Use the Support Request Template when asking for help.

gasteropod
Registered User
Posts: 270
Joined: Thu Mar 24, 2005 10:37 am
Location: Hampshire, UK

Post by gasteropod » Tue Jul 26, 2005 12:52 pm

I have traced this back, and the line to set the variables to zero was added in release 2.0.6. It looks like this was part of a security fix and I suspect it has been broken since then!
Use the Support Request Template when asking for help.

User avatar
uncle.f
Registered User
Posts: 253
Joined: Thu Mar 25, 2004 11:42 am
Location: Purple Yonder
Contact:

Post by uncle.f » Tue Jul 26, 2005 2:04 pm

Let's hope a support team member sees this and it gets fixed.


I have my concerns about this seeing how often people post in this forum. A post is long lost in less than 20 minutes...

Anyway, I will report this bug as soon as the tracker is open.

gasteropod
Registered User
Posts: 270
Joined: Thu Mar 24, 2005 10:37 am
Location: Hampshire, UK

Post by gasteropod » Tue Jul 26, 2005 2:46 pm

The other option is to PM a member of the development team or Acyd Burn their leader. I think this would be a valid thing to do as the bugs database is down.

Maybe someone in the support team can correct me if this is not appropriate and they see this before it disappears in 20 minutes ;)
Use the Support Request Template when asking for help.

basB
Registered User
Posts: 48
Joined: Mon Jul 25, 2005 10:42 am

Post by basB » Tue Jul 26, 2005 2:50 pm

I think that when they react they'll probably ask you to fill out this http://www.phpbb.com/phpBB/viewtopic.php?t=128123 template, so if you want to beat them to it i suggest filling in and posting it here will speed u things :wink:

gasteropod
Registered User
Posts: 270
Joined: Thu Mar 24, 2005 10:37 am
Location: Hampshire, UK

Post by gasteropod » Tue Jul 26, 2005 3:15 pm

Well, that is a support template relevant for troubleshooting. This is a bug which is applicable to 2.0.6 through 2.0.17 identified to line of code and the majority of the questions are therefore irrelevant. It cannot harm, but I'm not sure in this instance it helps.

The first response in this thread by uncle.f is far more useful for a bug.
Use the Support Request Template when asking for help.

CVinje
Registered User
Posts: 32
Joined: Mon Jul 11, 2005 8:35 am

I can second this

Post by CVinje » Fri Jul 29, 2005 12:40 am

I am experiencing this problem as well, just wanted to link to the thread I had made so we might get coinciding answers or whatever. Hope they get the bug fixed soon, it's hard to link members to a post when they keep getting reports that it doesn't exist after they log in.

My post: http://www.phpbb.com/phpBB/viewtopic.php?t=311039

Thanks,

CVinje

gasteropod
Registered User
Posts: 270
Joined: Thu Mar 24, 2005 10:37 am
Location: Hampshire, UK

Post by gasteropod » Fri Jul 29, 2005 8:25 am

I posted the fix from this thread in the other thread referenced.
Use the Support Request Template when asking for help.

User avatar
uncle.f
Registered User
Posts: 253
Joined: Thu Mar 25, 2004 11:42 am
Location: Purple Yonder
Contact:

Post by uncle.f » Fri Jul 29, 2005 12:15 pm

gasteropod, I have edited the first post here and included the fix using the easymod syntax as you have posted it on the other thread. Thanks!

User avatar
uncle.f
Registered User
Posts: 253
Joined: Thu Mar 25, 2004 11:42 am
Location: Purple Yonder
Contact:

Post by uncle.f » Wed Aug 03, 2005 5:05 pm

I have reported this to the newly opened bug tracker.

mickfilipe
Registered User
Posts: 5
Joined: Tue Jan 25, 2005 9:25 pm

Post by mickfilipe » Tue Jun 06, 2006 6:14 pm

Hey thanks for the fix :wink: I dunno If this has been fixed on new versions but I'm running an old version of phpbb and this problem was giving me an headache :evil:

Thx for saving me ass :lol:

espicom
Registered User
Posts: 17905
Joined: Wed Dec 22, 2004 1:14 am
Location: Woodstock, IL

Post by espicom » Tue Jun 06, 2006 6:29 pm

If you're running a version old enough to have this bug, it's the least of your worries! I hope you're keeping daily, sequential backups of your database for the restore you'll be doing when one of the script kiddies MAKES you update.
Jeff
Fixing 1016/1030/1034 Errors | (obsolete link) | MySQL 4.1/5.x Client Error | phpBBv2 Logo in ACP
Support requests via PM are ignored!
"To be fully alive is to feel that everything is possible." - Eric Hoffer

Locked

Return to “2.0.x Support Forum”