If you have manually set or edited a user profile alias, updating the user account (user/NNN/edit) overwrites the alias. It also throws an error if path_redirect is installed (below).

This patch implements a fix analogous to what was committed for nodes: #369840: If a user changes the automatic path, try to remember that in the future

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'people/dylan-tack-und' for key 'source_language': INSERT INTO {path_redirect} (source, redirect, query, fragment, language, type, last_used) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => people/dylan-tack [:db_insert_placeholder_1] => user/10 [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => und [:db_insert_placeholder_5] => 301 [:db_insert_placeholder_6] => 1286252449 ) in drupal_write_record() (line 6014 of /Users/dylan/Sites/mtm_d7/drupal/includes/common.inc).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, pathauto.patch, failed testing.

grendzy’s picture

Status: Needs work » Needs review

I don't think the the testbot is working, there is one test failure when I run simpletest, but it's not caused by this patch.

Fabianx’s picture

Hi,

I believe the proper fix is like with nodes to extend the http://drupal.org/project/pathauto_persist module to not only work with node entities, but also with user entities.

The reason is that users could also be done in bulk-processing, where the above change would affect the performance of the bulk processing. (Same reason as for nodes)

Best Wishes,

Fabian (LionsAd)

Fabianx’s picture

Hm, updating pathauto_persist is more complicated than I thought.

I think the only way to handle manual path alias updates is to hook into the path_admin_form_submit handler for D6 and get the entity type from the first part of 'src'.

In D7 the hook_path_insert and hook_path_update could be used. However they might have the possibility of recursion, so hooking _submit and perhaps addind field to form might still be the preferred way.

@DaveReid: Do you think this would be sane to do? What do you suggest?

Best Wishes,

Fabian (LionsAd)

Fabianx’s picture

I now made a proposal for solving this issue for 6.x-2.x-dev.

See: http://drupal.org/node/968644 and http://drupal.org/node/968622

The same approach should work in D7 with minimal porting needed.

Best Wishes,

Fabian (LionsAd)

klonos’s picture

...subscribing - in order to confirm if(ever) this is fixed.

I need to keep track of all related issues that seem to have a hope of getting solved by either using pathauto_persist as a separate module or by eventually using a future version of pathauto that has the code merged.

Dave Reid’s picture

Assigned: Unassigned » Dave Reid
Dave Reid’s picture

Dave Reid’s picture

Dave Reid’s picture

Dave Reid’s picture

Status: Needs review » Fixed

Committed #10 to CVS for both 7.x-1.x and 6.x-2.x.
http://drupal.org/cvs?commit=467254
http://drupal.org/cvs?commit=467256

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

grendzy’s picture

Status: Closed (fixed) » Needs review

I'm still seeing the PDOException in Beta1. This is reproducible on a fresh install:

  • Install pathauto and path_redirect
  • Set pathauto update action to "Create a new alias. Redirect from old alias."
  • Save your user profile
  • Edit your alias at admin/config/search/path
  • Re-save your user profile.

The patch in #0 still applies and resolves the issue for me.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'users/dylan-und' for key 'source_language': INSERT INTO {path_redirect} (source, redirect, query, fragment, language, type, last_used) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => users/dylan [:db_insert_placeholder_1] => user/1 [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => und [:db_insert_placeholder_5] => 301 [:db_insert_placeholder_6] => 1300167386 ) in drupal_write_record() (line 6851 of /Users/dylan/Sites/7-drupal/drupal/includes/common.inc).
Dave Reid’s picture

path_redirect for d7 is no longer supported. Use the Redirect module instead.

Dave Reid’s picture

Status: Needs review » Closed (fixed)
Dave Reid’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Closed (fixed) » Needs review
FileSize
3.29 KB

Patch re-rolled for 6.x-1.x.

klonos’s picture

...I thought the bot only run tests against d7(?). This one passed the tests though. Was it pure luck?

Dave Reid’s picture

Status: Needs review » Fixed

Confirmed all the tests passed locally, so committing to Git.
http://drupalcode.org/project/pathauto.git/commit/49a70b6

klonos’s picture

Thanx Dave! One less patch to babysit ;)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

maximpodorov’s picture

Status: Closed (fixed) » Active

Is there user interface for editing pathauto_perform_alias property for users and terms?

klonos’s picture

Status: Active » Closed (fixed)

AFAIK you can only set user and term paths through their respective path patterns (../admin/config/search/path/patterns) not in directly in the user/term edit form the way one does it with nodes. Still, not a reason to re-open this issue.

maximpodorov’s picture

I meant $term->pathauto_perform_alias is checked in the current code (commit link in #18), but there's no way to set it for particular term (except from additional module), and the same is for user, right? So is the fix for the initial request complete?

klonos’s picture

...ok, I wouldn't know about that.

Fabianx’s picture

Yes, it needs addtional changes in other modules:

Here is one proposed change for D6 pathauto_persist for user entities:

http://drupal.org/node/968644

It should not be too difficult to port this to D7.

Best Wishes,

Fabian