Latest IPB update broke old link redirection

10 posts in this topic

Posted

Hello all,

A long time ago (over a year) I converted from phpBB to IPB. Everything went fine with the conversion and everything was working perfectly up until the last IPB update.

Now, all the old redirects (/forum/viewtopic.php?t=1234) go to a IPB 404 page.
I've looked at the redirect files and the databse and everything is still there and running the query manually returns the correct result.


Any ideas?

$row = $DB->buildAndFetch( array( 'select' => 'ipb_id', 'from' => 'conv_link', 'where' => "foreign_id='".ipsRegistry::$request['t']."' AND type='topics' AND app='".$app['app_id']."'" ) );
vashkvartal likes this

Share this post


Link to post
Share on other sites

Posted

Taking a look at the source code of the 404 page, it appears that the redirect files are not redirecting to the correct url, as the base URL of all links becomes:

http://site.com/viewtopic.php?/user/1-jasonh/

Share this post


Link to post
Share on other sites

Posted

For example, running a SQL query manually, substituting for variables

and then manually substituting the id as /index.php?showtopic=16010
returns the correct topic without a 404.
So something with the update has changed the way the php redirect files deals with redirecting to the proper URL.


SELECT `ipb_id`

FROM conv_link

WHERE `foreign_id` =18327

AND `type` = 'topics'

AND app =1


returns:


ipb_id=16010

Share this post


Link to post
Share on other sites

Posted

Ok, so I've been trying to debug this and found something interesting.

I stripped viewtopic.php down to just:

Somehow, with no redirect, only an echo, it's STILL going to the IPB 404 page.
I don't even get how that's even possible unless the require files are somehow overriding the file entirely.


require_once 'config.php';

require_once( IPB_PATH.'/initdata.php' );

require_once( IPB_PATH.'/'.CP_DIRECTORY.'/sources/base/ipsRegistry.php' );

require_once( IPB_PATH.'/'.CP_DIRECTORY.'/sources/base/ipsController.php' );


$registry = ipsRegistry::instance();

$registry->init();

$DB	   = $registry->DB();


$row = $DB->buildAndFetch( array( 'select' => 'ipb_id', 'from' => 'conv_link', 'where' => "foreign_id='".ipsRegistry::$request['t']."' AND type='topics' AND app='".$app['app_id']."'" ) );

echo $row['ipb_id'];

Share this post


Link to post
Share on other sites

Posted

Since I couldn't figure out what the hell was happening with it, I just wrote a new one... I know it doesn't do any checking (does that even matter?), but I'm going to use it until someone figures out why the IPB one isn't working.


<?php

$oldtopic = $_GET["t"];

$con = mysql_connect("dbhost","dbuser","dbpass");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

mysql_select_db("dbname", $con);

$result = mysql_query("SELECT `ipb_id` FROM conv_link WHERE `foreign_id` = '$oldtopic' AND `type` = 'topics' LIMIT 1" );

$row = mysql_fetch_array($result);

mysql_close($con);

Header( "HTTP/1.1 301 Moved Permanently" );

Header("Location: http://site.com/index.php?showtopic=".$row['ipb_id']);

?>

vitoreis likes this

Share this post


Link to post
Share on other sites

Posted

[quote name='jason hilton' timestamp='1328126735' post='2227228']
Ok, so I've been trying to debug this and found something interesting.

I stripped viewtopic.php down to just:

Somehow, with no redirect, only an echo, it's STILL going to the IPB 404 page.
I don't even get how that's even possible unless the require files are somehow overriding the file entirely.


I know on the redirect files I have been messing with you have to strip the "t=" and get just the number for the topic or forum id, otherwise you are searching for t=1234 and won't find a match.


require_once 'config.php';

require_once( IPB_PATH.'/initdata.php' );

require_once( IPB_PATH.'/'.CP_DIRECTORY.'/sources/base/ipsRegistry.php' );

require_once( IPB_PATH.'/'.CP_DIRECTORY.'/sources/base/ipsController.php' );


$registry = ipsRegistry::instance();

$registry->init();

$DB	   = $registry->DB();


$row = $DB->buildAndFetch( array( 'select' => 'ipb_id', 'from' => 'conv_link', 'where' => "foreign_id='".ipsRegistry::$request['t']."' AND type='topics' AND app='".$app['app_id']."'" ) );

echo $row['ipb_id'];

Share this post


Link to post
Share on other sites

Posted

[quote name='-GR-' timestamp='1328199955' post='2227473']
I know on the redirect files I have been messing with you have to strip the "t=" and get just the number for the topic or forum id, otherwise you are searching for t=1234 and won't find a match.

Yeah I'm not sure what was going on with the IPB redirect file, I did a lot of debugging and couldn't get it to work. I think something has changed in ipsRegistry.php that prevents them from working the way they did before.

Anyway, the code I posted (post 5) doesn't require any ipb files. It manually does a mysql select from a PHP $_GET "t" and then sets the result as the header location. It works perfectly, I don't know why IPB made such a complicated redirect in the first place.

Share this post


Link to post
Share on other sites

Posted

[quote name='jason hilton' timestamp='1328208656' post='2227533']
Yeah I'm not sure what was going on with the IPB redirect file, I did a lot of debugging and couldn't get it to work. I think something has changed in ipsRegistry.php that prevents them from working the way they did before.

Anyway, the code I posted (post 5) doesn't require any ipb files. It manually does a mysql select from a PHP $_GET "t" and then sets the result as the header location. It works perfectly, I don't know why IPB made such a complicated redirect in the first place.


I know what you mean, it is nice though keeping with using the same classes and methods though. We are getting ready to do the live conversion on our vb4 site next weekend and I have been busy trying to get everything in place and the redirects were one of the things I just took care of which is why it was fresh in my brain about having to strip the t= out.

I guess using their classes and methods if you change your database info for some reason it would be one less thing to worry about but it isn't like that happens too often if ever.

Share this post


Link to post
Share on other sites

Posted

please be careful about classes and methods...............................................its important now...................

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Who's Browsing   0 members

    No registered users viewing this page.