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

Craft passes old existing to setUniqueUri when "save entry as new" with custom URI structure #4759

Closed
coryzibell opened this issue Aug 14, 2019 · 6 comments

Comments

@coryzibell
Copy link
Contributor

coryzibell commented Aug 14, 2019

Description

In a section where the URI is based on a field, duplicating one of those entries with a different slug and field results in craft passing the previous URI to setUniqueUri, resulting in a failure message of "Could not generate a unique URI based on the URI format."

Steps to reproduce

  1. Create a new text field with a handle like testTextField
  2. Create a new channel, add the field to the section
  3. Set the URI of the Channel to {testTextField}
  4. Create a new entry in the channel.
  5. Open the new entry. Change the slug and the contents of testTextField Click "Save as new entry."

Additional info

  • Craft version: Craft Pro 3.2.10
  • PHP version: 7.3.7
  • Database driver & version: MySQL 5.5.5
  • Plugins & versions:
    Asset Rev 6.0.2
    Calendar Links 1.0.1
    Child Me! 1.0.4
    Cloudflare 0.2.9
    Contact Form 2.2.5
    Contact Form Extensions 1.1.7
    Cookies 1.1.11
    CP Field Inspect 1.0.6
    Craft Countries and Divisions dev-master
    Download Assets 1.0.1
    Element Link 1.0.0
    Environment Label 3.1.5
    Feed Me 4.1.2
    Feed Me Pro 3.0.4
    Fetch 1.2.0
    Image Resizer 2.0.5
    Inlin 2.1.1
    Inventory 2.0.3
    Json Client 1.0.3
    Nanoslugs 1.0.3
    Position Fieldtype 1.0.14
    Redactor 2.3.3.2
    SEO 3.6.2
    Spoon 3.3.7
    SuperSort 3.0.1
    Super Table 2.2.1
    Twig Perversion 2.1.0
@brandonkelly
Copy link
Member

Thanks for reporting that, just fixed for the next release.

To get the fix early, change your craftcms/cms requirement in composer.json to:

"require": {
  "craftcms/cms": "dev-develop#43caabc535a815e4c3571f63024d68084586b2eb as 3.2.10",
  "...": "..."
}

Then run composer update.

@1stevengrant
Copy link

I'm seeing this again on 3.4.5 - luckily it's on a channel that we're not using fully yet.

As soon as I remove the person/{firstName|lower}-{lastName|lower} as the entry URI format, everything goes back to normal.

brandonkelly added a commit that referenced this issue Feb 17, 2020
@brandonkelly
Copy link
Member

I’m sure I would have tested, but on looking into this further, I’m not sure this was ever fully fixed. The entry would get duplicated fine, however Craft would then attempt to resave the duplicate with the POST data applied to it, at which point you’d get that validation error again. Awkward thing is, post 3.3.0 when this was originally “fixed”, when the form reloads with the validation error, you’re actually technically looking at the form for the duplicated entry, despite it having the original entry’s URL.

This should now be fully fixed for the next release. Now Craft no longer cares about duplicate URIs for disabled elements, and entries will be automatically disabled on duplicate if a unique URI can’t be generated for it.

To get the fix early, change your craftcms/cms requirement in composer.json to:

"require": {
  "craftcms/cms": "dev-develop#6c47da3d367b97a25106df245849e7ce708cae43 as 3.4.5",
  "...": "..."
}

Then run composer update.

@1stevengrant
Copy link

Thanks @brandonkelly - I can hold off.

@brandonkelly
Copy link
Member

Craft 3.4.6 is out now with this change.

@alexanderloewe
Copy link

I got the same problem after an update from Craft CMS 2.9.2 to 3.7.14.

Bildschirmfoto 2021-09-29 um 19 38 32

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

4 participants