While this is a case of data in an unexpected state, it causes a difficult to track down problem.

After manually importing some url_aliases using SQL I ended up with a records where both src and dst were blank. After that, my client complained that they got the error message "The path is already in use" when trying to save a node which I easily reproduced. You can reproduce the problem by running this SQL code:

INSERT url_alias SELECT 0,'',''

It took a while, but with my PhpED debugger I was able to track down that line 218 in path.module where the line containing the following SQL query was the culprit, falsely reporting the error message:

case 'validate':
	$node->path = trim($node->path);
	if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s'", $node->path, "node/$node->nid"))) {
		form_set_error('path', t('The path is already in use.'));
	}

Although there are other potential workarounds that would actually clean the data I'd like to suggest a patch that I think would work around this problem and not give users an unrelated error message that is hard to track down:

case 'validate':
	$node->path = trim($node->path);
	if (!empty($node->path) and db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s'", $node->path, "node/$node->nid"))) {
		form_set_error('path', t('The path is already in use.'));
	}

Note that I added !empty($node->path) and to the if statement's conditional expression.

HTH.

Comments

EvanDonovan’s picture

This fix worked for me even though I wasn't able to find any cases where src & dst were both "" in our DB. However, I did notice that now when I submit pages of a particular content type (Volunteer Opportunities - a CCK content type we created) that have URL aliases already, their URL aliases are lost.

EvanDonovan’s picture

Version: 5.7 » 7.x-dev

Bumping this up to D7. Does anyone see any problems with adding this?

Of course, the "patch" would need to be re-rolled...

mstrelan’s picture

I just experienced this issue in D6. The src was set to node/150 but dst was an empty string. Deleting that record solved the problem. It would be good if we could track down how an empty dst gets inserted.

attiks’s picture

Version: 7.x-dev » 8.x-dev
Issue tags: +needs backport to 6.x

Moving to Drupal 8 first

cweagans’s picture

Issue tags: +Needs backport to D7
xjm’s picture

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Status: Active » Closed (outdated)
Issue tags: +Bug Smash Initiative

There are three reports of this issue. The first is the original, against Drupal 5.7, then a comment confirming the fix suggested in the IS and another one for Drupal 6. There are no reports for a current version of Drupal.

A look at the suggested fix for path.module in Drupal 7 shows that the validate function has changed and does include a check that the path is not empty.

Since there are no reports of this problem for a current version of Drupal, closing this as outdated.

IIf you are experiencing this problem reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core").

Thanks!