From a404a97bbd05539c7a8eda0cf5f15a6058d7465f Mon Sep 17 00:00:00 2001
From: Patrick Dawkins <pjcdawkins@googlemail.com>
Date: Tue, 6 Sep 2011 12:01:00 +0100
Subject: [PATCH] Issue #1270066: Fixed pathauto problem.

---
 election.constants.inc |  1 +
 election.module        | 25 ++++++++++++++++++++-----
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/election.constants.inc b/election.constants.inc
index d4ffafb..5fffd35 100644
--- a/election.constants.inc
+++ b/election.constants.inc
@@ -27,4 +27,5 @@ define('ELECTION_CANDIDATE_APPROVED', 1);
 define('ELECTION_CANDIDATE_PENDING', 0);
 define('ELECTION_CANDIDATE_REJECTED', -1);
 
+// Cardinality of the nomination form's "seconder" field (instance of "endorser").
 define('ELECTION_CANDIDATE_MAX_SECONDERS', 10);
diff --git a/election.module b/election.module
index 2215bff..7f90abe 100644
--- a/election.module
+++ b/election.module
@@ -860,11 +860,20 @@ function election_save($election) {
 }
 
 /**
- * Implements hook_entity_presave().
+ * Implements hook_entity_insert().
  */
-function election_election_presave($election) {
+function election_election_insert($election) {
   if (function_exists('pathauto_election_update_alias')) {
-    pathauto_election_update_alias($election, $op);
+    pathauto_election_update_alias($election, 'insert');
+  }
+}
+
+/**
+ * Implements hook_entity_update().
+ */
+function election_election_update($election) {
+  if (function_exists('pathauto_election_update_alias')) {
+    pathauto_election_update_alias($election, 'update');
   }
 }
 
@@ -1111,8 +1120,14 @@ function pathauto_election_update_alias(stdClass $election, $op, array $options
     return;
   }
   module_load_include('inc', 'pathauto');
-  $uri = entity_uri('election', $election);
-  pathauto_create_alias('election', $op, $uri['path'], array('election' => $election), $election->type, $options['language']);
+  pathauto_create_alias(
+    'election',
+    $op,
+    election_uri_path($election),
+    array('election' => $election),
+    $election->type,
+    $options['language']
+  );
 }
 
 /**
-- 
GitLab