PDA

View Full Version : Fix pathauto bug for vbDrupal


Alexandros Roussos
03-26-2006, 06:00 PM
When using pathauto module, I noticed that there was an SQL error each time I posted an article:

Unknown column 'name' in 'field list'
query: SELECT name FROM forums_user WHERE uid='1'

However it had no effect on the result, the news was posted and the linked forum thread too.

It was annoying though so I squashed it this way:

1. edit file: /modules/pathauto/pathauto_node.inc
2. go to line 127
3. modify this line from:
$result = db_query("SELECT name FROM {users} WHERE uid='%u'", $node->uid);
to:
$result = db_query("SELECT username FROM {users} WHERE userid='%u'", $node->uid);
4. save and upload the edited file, it now should work fine.

This was probably due to the fact we're using vBulletin's userbase structure instead of drupal's.

I guess other modules may require the same fix.
________
Vaporizer questions (http://vaporizer.org/forum/vaporizer-questions/)

BryceI
03-28-2006, 12:18 PM
there are a few more changes that you'll have to make in order to get bulk updates to work:

In pathauto_user.inc:

starting at line 118, find

// Generate aliases for all users without aliases
function user_pathauto_bulkupdate() {
$query = 'SELECT uid,name,src,dst FROM {users} '.
"LEFT JOIN {url_alias} ON CONCAT('user/', uid) = src ".
'WHERE uid > 0';
$result = db_query($query);
$user = db_fetch_object($result);

$count = 0;
$placeholders = array();
while ($user) {
$placeholders[t('[user]')] = pathauto_cleanstring($user->name);
$placeholders[t('[uid]')] = $user->uid;
$src = 'user/'.$user->uid;

replace with

// Generate aliases for all users without aliases
function user_pathauto_bulkupdate() {
$query = 'SELECT userid,username,src,dst FROM {users} '.
"LEFT JOIN {url_alias} ON CONCAT('user/', userid) = src ".
'WHERE userid > 0';
$result = db_query($query);
$user = db_fetch_object($result);

$count = 0;
$placeholders = array();
while ($user) {
$placeholders[t('[user]')] = pathauto_cleanstring($user->username);
$placeholders[t('[uid]')] = $user->userid;
$src = 'user/'.$user->userid;

Starting at line 142, find
// Generate aliases for all blogs without aliases
function blog_pathauto_bulkupdate() {
$query = 'SELECT uid,name,src,dst FROM {users} '.
"LEFT JOIN {url_alias} ON CONCAT('user/', uid) = src ".
'WHERE uid > 0';
$result = db_query($query);
$user = db_fetch_object($result);

$count = 0;
$placeholders = array();
while ($user) {
$placeholders[t('[user]')] = pathauto_cleanstring($user->name);
$placeholders[t('[uid]')] = $user->uid;
$src = 'blog/'.$user->uid;

replace with

// Generate aliases for all blogs without aliases
function blog_pathauto_bulkupdate() {
$query = 'SELECT userid,username,src,dst FROM {users} '.
"LEFT JOIN {url_alias} ON CONCAT('user/', userid) = src ".
'WHERE userid > 0';
$result = db_query($query);
$user = db_fetch_object($result);

$count = 0;
$placeholders = array();
while ($user) {
$placeholders[t('[user]')] = pathauto_cleanstring($user->username);
$placeholders[t('[uid]')] = $user->userid;
$src = 'blog/'.$user->userid;

Starting at line 167, find
// Generate aliases for all tracker pages without aliases
function tracker_pathauto_bulkupdate() {
$query = 'SELECT uid,name,src,dst FROM {users} '.
"LEFT JOIN {url_alias} ON CONCAT('user/', uid) = src ".
'WHERE uid > 0';
$result = db_query($query);
$user = db_fetch_object($result);

$count = 0;
$placeholders = array();
while ($user) {
$placeholders[t('[user]')] = pathauto_cleanstring($user->name);
$placeholders[t('[uid]')] = $user->uid;
$src = 'user/'.$user->uid.'/track';

Replace with

// Generate aliases for all tracker pages without aliases
function tracker_pathauto_bulkupdate() {
$query = 'SELECT userid,username,src,dst FROM {users} '.
"LEFT JOIN {url_alias} ON CONCAT('user/', userid) = src ".
'WHERE userid > 0';
$result = db_query($query);
$user = db_fetch_object($result);

$count = 0;
$placeholders = array();
while ($user) {
$placeholders[t('[user]')] = pathauto_cleanstring($user->username);
$placeholders[t('[uid]')] = $user->userid;
$src = 'user/'.$user->userid.'/track';

In file pathauto_node.inc, starting at line 126, find

// Then the slightly less simple stuff
$result = db_query("SELECT name FROM {users} WHERE uid='%u'", $node->uid);
$userinfo = db_fetch_object($result);
$placeholders[t('[user]')] = pathauto_cleanstring($userinfo->name);


replace with

// Then the slightly less simple stuff
$result = db_query("SELECT username FROM {users} WHERE userid='%u'", $node->uid);
$userinfo = db_fetch_object($result);
$placeholders[t('[user]')] = pathauto_cleanstring($userinfo->username);


(Note that this last change is a slightly extended version of the change in the original post).

hanviet
04-02-2006, 06:48 AM
Could you help me, I don't know why I can not find and download pathauto module. :(

sifuhall
04-02-2006, 08:52 PM
http://drupal.org/project/pathauto

Caerydd
04-14-2006, 07:16 AM
Uh, by any chance can someone just attach the patched version of pathauto for vbdrupal? Patching is one of the few bits of tinkering that just flat out scares me >_<

yeah, I'm a wimp

nick_1
04-16-2006, 10:49 AM
Hi Guys,

I've just made those changes to pathauto and as someone asked for them attached are the files. I've done every edit listed here but I haven't tested them fully. I would be grateful if anyone could have a look for any mistakes.

I'm going to look into how to add the optimisation patch next as my site is growing rapidly :)

Nick

Alexandros Roussos
04-25-2006, 06:57 PM
I have already applied the changes but I wanted to test your modified pathauto but it looks like I cannot access to it.
________
Cold case advice (http://www.tv-gossip.com/cold-case/)

nick_1
04-26-2006, 10:31 AM
I have already applied the changes but I wanted to test your modified pathauto but it looks like I cannot access to it.
Where are you getting the error? Is it an error downloading the file from these forums?

Thanks,
Nick

peach
04-29-2006, 12:46 PM
Hi, just got VbD installed, well almost, do I still need to make the above changes or have they been put in the package by now?

nick_1
04-29-2006, 02:13 PM
Hi, just got VbD installed, well almost, do I still need to make the above changes or have they been put in the package by now?
I don't believe the package has been updated, I've also managed to add the url alias optimisation patch as well and if you make use of pathauto you really need to patch as my load times went from 10-20 seconds to a peak of 2s. This is on a large site so you may not notice the change as much as I did.

Nick

peach
04-29-2006, 02:26 PM
Thanks for the quick reply.
Right now I'm just playing with a test site, but the site I'm doing to convert from mambo to drupal already has about 550 content items and lots of comments, allthough I probably won't be able to import the comments.

nick_1
04-29-2006, 02:48 PM
Thanks for the quick reply.
Right now I'm just playing with a test site, but the site I'm doing to convert from mambo to drupal already has about 550 content items and lots of comments, allthough I probably won't be able to import the comments.
Comments might be tricky if you want to put them into vb with all of the caches it has. The patch I have installed to increase performance is this one:
http://drupal.org/files/issues/path_alias_backport_0.patch

If you are feeling lazy I can send my patched versions but I make no promises about any errors it may have. The files are currently live on my site and seem to work though.

Nick

peach
04-29-2006, 02:50 PM
Comments might be tricky if you want to put them into vb with all of the caches it has. The patch I have installed to increase performance is this one:
http://drupal.org/files/issues/path_alias_backport_0.patch

If you are feeling lazy I can send my patched versions but I make no promises about any errors it may have. The files are currently live on my site and seem to work though.

Nick
It's not that I'm lazy but I am a non-programmer, and I don't know where that .patch file goes, can you post your patched version please? (off autopath you mean right?)

nick_1
04-29-2006, 02:55 PM
It's not that I'm lazy but I am a non-programmer, and I don't know where that .patch file goes, can you post your patched version please? (off autopath you mean right?)
In that case download the attachment below and unzip the files into drupal/includes/ that should replace two files common.inc and bootstrap.inc.

Nick

peach
04-29-2006, 02:56 PM
In that case download the attachment below and unzip the files into drupal/includes/ that should replace two files common.inc and bootstrap.inc.

Nick

Thanks :)
I'll put it up as soon as I get through this mess:http://www.vbdrupal.org/forum/showthread.php?t=232

peach
05-02-2006, 07:26 AM
Okay I got it working now, thanks for the patches nick :)
What did the drupal core patches do exactly?

alexanderpas
05-02-2006, 09:57 AM
i like to verify that these patches are incorperated in vbDrupal 4.6.6.1, are they or aren't they?

peach
05-02-2006, 11:25 AM
nope......

elmuerte
05-02-2006, 01:54 PM
the pathauto module wasn't part of the vbdrupal distribution and wasn't something I was working on, so no... it's not part of 4.6.6.1-2