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

page.uuid cannot be used in blueprint definitions in multi-lang setups #4955

Open
hariom147 opened this issue Dec 16, 2022 · 5 comments
Open
Labels
type: bug 🐛 Is a bug; fixes a bug

Comments

@hariom147
Copy link
Contributor

Description

When adding {{ page.uuid }} to a blueprint (anywhere, i.e. in the text property of the info field or the help property of any field I tried), the add page dialog throws a duplicate error, even though the page slug does not exist. The page is created nonetheless: After cancelling the dialog and refreshing the panel the created page shows.
Only happens when 'languages'=> true is set in config.

Expected behavior
Add a new page through pages section in the panel without error.

Screenshots
Bildschirm­foto 2022-12-14 um 22 37 25

To reproduce

  1. install fresh starterkit
  2. enable languages in config
  3. add page.uuid to page blueprint
    i.e.
fields:
  test:
    type: info
    text: "{{ page.uuid }}"
  1. From pages section create a new page that has page.uuid in its blueprint
  2. See error

Your setup

Kirby Version
3.8.3

Console output
XHRPOSThttp://starterkit.test/panel/dialogs/pages/create?language=en
[HTTP/1.1 400 Bad Request 29ms]

POST
http://starterkit.test/panel/dialogs/pages/create?language=en
Status
400
Bad Request
VersionHTTP/1.1
Übertragen406 B (145 B Größe)
Referrer Policysame-origin
Anfrage-PrioritätHighest

Cache-Control
	no-store, private
Connection
	keep-alive
Content-Type
	application/json; charset=UTF-8
Date
	Fri, 16 Dec 2022 12:47:36 GMT
Server
	nginx/1.23.2
Transfer-Encoding
	chunked
X-Fiber
	true
X-Powered-By
	PHP/8.1.13
	
Accept
	*/*
Accept-Encoding
	gzip, deflate
Accept-Language
	de,en-US;q=0.7,en;q=0.3
Cache-Control
	no-cache
Connection
	keep-alive
Content-Length
	72
Content-Type
	text/plain;charset=UTF-8
Cookie
	kirby_session=ecafab31991a13734302b2895694415ef3aa09de%2B1672404442.c7760f7f8bf57b3fafc0.f3521b151bc46c42e64d821b8633be831483e8bff171a3caa8e34ab2d2006771
Host
	starterkit.test
Origin
	http://starterkit.test
Pragma
	no-cache
Referer
	http://starterkit.test/panel/site
User-Agent
	Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:107.0) Gecko/20100101 Firefox/107.0
X-CSRF
	f5784bc2719486f3b79492777f5ba0dffde7c975c0b2ef48ca0d8aa991446ba9
X-Fiber
	true
X-Fiber-Globals
	false
X-Fiber-Only
	
X-Fiber-Referrer
	/site

Your system (please complete the following information)

  • Device: MacBook Pro, 16 inch 2019
  • OS: MacOS 13.0.1
  • Browser: all
@afbora afbora added the type: regression 🚨 Is a regression between versions label Dec 16, 2022
@afbora
Copy link
Member

afbora commented Dec 16, 2022

Summary

You are guessing this problem. Uuid processes start before the page is created (via form class, mentioned below related lines) and the non-existent page is saved with ModelUuid::storeId(). When it's time for the actual page creation, the error returns because the page has already created.

https://github.com/getkirby/kirby/blob/3.8.3/src/Cms/PageActions.php#L539-L543
https://github.com/getkirby/kirby/blob/3.8.3/src/Uuid/ModelUuid.php#L121

Also this is working on 3.8.0 but not for 3.8.1.1, 3.8.2 and 3.8.3. So it's regression. Because we have added UUIDs for multilanguage in 3.8.1.1. So this should be bug instead regression.

@afbora afbora added type: bug 🐛 Is a bug; fixes a bug and removed type: regression 🚨 Is a regression between versions labels Dec 17, 2022
afbora added a commit that referenced this issue Dec 19, 2022
Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@afbora afbora added this to the 3.8.3.1 milestone Dec 20, 2022
@afbora afbora added type: regression 🚨 Is a regression between versions and removed type: bug 🐛 Is a bug; fixes a bug labels Dec 21, 2022
@afbora afbora linked a pull request Dec 23, 2022 that will close this issue
5 tasks
@bastianallgeier bastianallgeier added type: bug 🐛 Is a bug; fixes a bug and removed type: regression 🚨 Is a regression between versions labels Jan 6, 2023
@afbora afbora removed this from the 3.8.4 milestone Jan 9, 2023
@afbora afbora removed a link to a pull request Jan 9, 2023
5 tasks
@bastianallgeier
Copy link
Member

It's unfortunately a lot more complex than we hoped, but there's a simple workaround for now:

info:
  type: info
  text: "{{ page.content.get('uuid') }}"  

We are working on getting this fixed permanently in one of the next major versions.

@bastianallgeier bastianallgeier changed the title [Panel, Multilang] Add page Dialog throws false duplicate error when page.uuid method is present in blueprint page.uuid cannot be used in blueprint definitions in multi-lang setups Jan 10, 2023
samzzi added a commit to samzzi/kirby3-janitor that referenced this issue Feb 2, 2023
@mynameisfreedom
Copy link

The same issue happens with {{ page.permalink }}, is there maybe a workaround for that too?

@afbora
Copy link
Member

afbora commented Feb 9, 2024

@mynameisfreedom As workaround you can use like that:

{{ kirby.url('base') }}/@/page/{{ page.content.get('uuid') }}

Also you use custom page methods: {{ page.myCustomPermalink }} that use $page->content()->get('uuid') instead $page->uuid().

@mynameisfreedom
Copy link

You are a Kirby beast @afbora 💪

Thank you, that works 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Is a bug; fixes a bug
Projects
None yet
Development

No branches or pull requests

4 participants