file: pathauto.module line 596.

rowCount() is not supported by SQLSrv so this method returns -1 meaning that the return from the function is FALSE even when an alias exists.

/**
* Implements hook_pathauto_is_alias_reserved() on behalf of path.module.
*/
function path_pathauto_is_alias_reserved($alias, $source, $langcode) {
// For language neutral content, we need to make sure the alias doesn't
// collide with any existing aliases. For localized content, just make sure
// it doesn't collide with same language or language neutral aliases.
$query = db_select('url_alias', 'ua')
->fields('ua', array('pid'))
->condition('source', $source, '<>')
->condition('alias', $alias);

if ($langcode != LANGUAGE_NONE) {
$query->condition('language', array($langcode, LANGUAGE_NONE), 'IN');
}

// return $query->execute()->rowCount() > 0; // DOES NOT WORK ON SQLSRV
return !empty($query->execute()->fetchAll()); // WORKS ON SQLSRV
}

Comments

bencontra created an issue.

punch’s picture

Thanks, I'm using oracle and it's the same here.
According to http://php.net/manual/en/pdostatement.rowcount.php rowCount only safe to use on DELETE, INSERT, or UPDATE.

I changed the return to this:
return $query->countQuery()->execute()->fetchField() > 0;

which I think is better.