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

slug is overwritten when updating partial data without slug field (via PHP or API) #3

raffaelj opened this issue Sep 8, 2019 · 0 comments


Copy link

commented Sep 8, 2019

When using the UI, all fields will be sent when updating an entry and everything works like expected. But when I update only a partial data set, the addon thinks, that the slug was deleted and creates a new one with the default fallback.

Steps to reproduce:


$change = [
    '_id' => '5cebf12a333862178c0001f8', // existing _id
    'test' => 'change only this one',
    // UniqueSlugs addon wants to check against these fields:
    // 'slug' => 'about',
    // 'title' => 'About',

// save changes
$this->module('collections')->save('pages', [$change], ['revision' => true]);

{"data":{"_id":"5cebf12a333862178c0001f8","test":"change only this one"}}


    "_id": "5cebf12a333862178c0001f8",
    "test": "change only this one",
    "_by": "user_id...",
    "_modified": 1567949823,
    "slug": "entry",
    "slug_fr": "entry-1"

It is totally possible, to update entries with partial data, but the addon doesn't know about it and tries to check against non sent values.

Problems to solve that issue:

I could load the original entry to find the missing fields before comparing, but that would cause another avoidable database request and multiple new possible edge cases.

Checking against an empty slug field is a feature to reset the slug or to create it for older entries, that were created without or with misconfigured addon.

I'm not sure about an elegant solution. If anyone has ideas, please share them.

@raffaelj raffaelj closed this in d79c827 Sep 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.