Hi,

'Pathauto' comes with a bulk update feature that is supposed to be able to bulk update (create) taxonomy term aliases. However, this does not work for me on a site with approximately 35,000 taxonomy terms.

The setting is available at ./admin/build/path/update_bulk, I can start the procedure, and the batch API claims to initialize. Thas goes on for at least an hour, without any errors or timeouts. Nothing related to path aliases is logged in Drupal's watchdog, Apache's error log remains clean of new error messages, as well. As far as I can tell, no aliases are created at all. It just "initializes" (screenshot attched), but seems not to do anything.

Possibly related: #1240760: Initialization process uses query that causes full table scan

Any workarounds or other suggestions how to fix missing aliases?

Thanks!

Files: 
CommentFileSizeAuthor
path-update-bulk-initializing.jpg35.03 KBasb

Comments

Short addition: It might be doing something, even if I cancelled the process some about two hours ago.

For some time I'm experiencing a pretty high server load (12 on a quad core with a normal load average around 2.5) and lots of activity in MySQL. According to 'mytop', queries like this are executed:

EXPLAIN SELECT COUNT(*) FROM term_data t LEFT JOIN url_alias ua ON CONCAT('taxonomy/term/', t.tid) = ua.src WHERE ua.src IS NULL AND t.tid > 0 AND t.vid <> 0:
*** row 1 ***
          table:  t
           type:  ALL
  possible_keys:  PRIMARY,vid_name,taxonomy_tree
            key:  NULL
        key_len:  NULL
            ref:  NULL
           rows:  41321
          Extra:  Using where
*** row 2 ***
          table:  ua
           type:  ALL
  possible_keys:  src_language_pid
            key:  NULL
        key_len:  NULL
            ref:  NULL
           rows:  109461
          Extra:  Range checked for each record (index map: 0x4); Not exists

EXPLAIN SELECT t.tid FROM term_data t LEFT JOIN url_alias ua ON CONCAT('taxonomy/term/', t.tid) = ua.src WHERE ua.src IS NULL AND t.tid > 0 AND t.vid <> 0 ORDER BY t.tid LIMIT 0, 25:
*** row 1 ***
          table:  t
           type:  range
  possible_keys:  PRIMARY,vid_name,taxonomy_tree
            key:  PRIMARY
        key_len:  4
            ref:  NULL
           rows:  41321
          Extra:  Using where; Using temporary; Using filesort
*** row 2 ***
          table:  ua
           type:  ALL
  possible_keys:  src_language_pid
            key:  NULL
        key_len:  NULL
            ref:  NULL
           rows:  109461
          Extra:  Range checked for each record (index map: 0x4); Not exists

I had the same issue with version 7.x-1.2.
In file pathauo.pathauto.inc there is taxonomy_pathauto_bulk_update_batch_process. There you have the following query:

$query = db_select('taxonomy_term_data', 'td');
$query->leftJoin('url_alias', 'ua', "CONCAT('taxonomy/term/', td.tid) = ua.source");
$query->addField('td', 'tid');
$query->isNull('ua.source');
$query->condition('td.tid', $context['sandbox']['current'], '>');
// Exclude the forums terms.
if ($forum_vid = variable_get('forum_nav_vocabulary', '')) {
$query->condition('td.vid', $forum_vid, '<>');
}
$query->orderBy('td.tid');
$query->addTag('pathauto_bulk_update');
$query->addMetaData('entity', 'taxonomy_term');

I dont think the leftJoin condition and the isNull condition are compatible. I commented the $query->isNull('ua.source'); line and the update worked ok.
For version 6.x-2.0 you have this line:
$sql = "SELECT t.tid FROM {term_data} t LEFT JOIN {url_alias} ua ON $concat = ua.src WHERE ua.src IS NULL AND t.tid > %d AND t.vid <> %d ORDER BY t.tid";
Replace it with this and it should work:
$sql = "SELECT t.tid FROM {term_data} t LEFT JOIN {url_alias} ua ON $concat = ua.src WHERE t.tid > %d AND t.vid <> %d ORDER BY t.tid";

Hi olteanu5000,

thanks for the code modification! I tried this, but the behaviour described above doesn't change: The bulk update keeps initializing and Batch API does not indicate any progress; in the background, the server load increases, and slow queries like this are executed:

EXPLAIN SELECT COUNT(*) FROM term_data t LEFT JOIN url_alias ua ON CONCAT('taxonomy/term/', t.tid) = ua.src WHERE t.tid > 0 AND t.vid <> 0:
*** row 1 ***
          table:  t
           type:  ALL
  possible_keys:  PRIMARY,vid_name,taxonomy_tree
            key:  NULL
        key_len:  NULL
            ref:  NULL
           rows:  42243
          Extra:  Using where
*** row 2 ***
          table:  ua
           type:  index
  possible_keys:  src_language_pid
            key:  src_language_pid
        key_len:  428
            ref:  NULL
           rows:  110970
          Extra:  Using index