Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to change Authority Record slug #1006

Closed
rferris opened this issue Nov 22, 2019 · 3 comments
Closed

Unable to change Authority Record slug #1006

rferris opened this issue Nov 22, 2019 · 3 comments

Comments

@rferris
Copy link
Contributor

rferris commented Nov 22, 2019

Currently it is not possible to change the slug of an authority record once it has been created. Advice from Dan in the forum is to use SQL against the database directly to do this.
Regenerating slugs

In order to avoid this I modified the QubitActor.php file as per the following diff:

index f36bfebc2..4869dcadb 100644
--- a/lib/model/QubitActor.php
+++ b/lib/model/QubitActor.php
@@ -140,6 +140,17 @@ class QubitActor extends BaseActor
     {
       $this->parentId = QubitRepository::ROOT_ID;
     }
+
+    // Added by rferris to allow changing authority record slugs
+    $newQubitSlug = QubitSlug::getByObjectId($this->id);
+    if (isset($newQubitSlug)) {
+        $slug = QubitSlug::slugify($this->__get('authorizedFormOfName', array('sourceCulture' => true)));
+        if ($slug !== $this->slug) {
+            $this->slug = $slug;
+            $newQubitSlug->slug = $slug;
+            $newQubitSlug->save();
+        }
+    }

This allows a user to simply edit the record, change the title, hit save, and have the slug change accordingly. As far as I can tell this is effectively no different to doing this via SQL and the CLI slug utility. Whether it's the way the team at Artefactual would go about this or not, I'm not sure. I did, however, want to provide my change for your consideration.

@fiver-watson
Copy link
Contributor

Hi @rferris !

Thanks so much for sharing this idea. While we would love to see a method for end users to easily update authority record slugs to AtoM's user interface, at this time, I'm not sure this is a solution we will implement. Changing the permalink of a resource in AtoM without the user explicitly choosing to do so could have unexpected consequences - for example, breaking every external link added to third-party websites.

Long term, our preferred solution would be to add support for a Rename module for authority records, similar to what we've added for descriptions, as described in our docs here:

If you are curious to see the code behind this, here are some of the main files used:

I'll leave this issue open for now, to make it easier for others to find your code snippet in case they would like to implement this locally.

Cheers,

Dan Gillean, MAS, MLIS
AtoM Program Manager

@rferris
Copy link
Contributor Author

rferris commented Nov 24, 2019

Hi Dan,

Agreed - my quick fix here definitely isn't ideal. I'll see if I can get time to create a rename form and if I can I'll do a pull request on it. :)

Cheers,
Rohan

@anvit
Copy link
Contributor

anvit commented May 3, 2023

Fix merged in: #1542

@anvit anvit closed this as completed May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants