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

[Panel] Users Field Should Save Persistent ID, Not Email Address #1885

Open
neildaniels opened this issue Jun 28, 2019 · 7 comments

Comments

@neildaniels
Copy link
Contributor

commented Jun 28, 2019

Describe the bug
We just ran into an unexpected issue today, if you change the email address of a user, pages that had a Users field are no longer linked to the affected user.

I genuinely thought the Users field would save a list of persistent User IDs (i.e. the folder name that contains an individual user's files). If it had done this, renaming an email address wouldn't break existing pages (it breaks now because $field->toUsers() finds no matching email address.

What's Actually Saved in a Content File

Authors: 

- foo@example.com

What I Would Expect to be Saved

Authors: 

- By4XbnMB

To Reproduce
Steps to reproduce the behavior:

  1. Have a user with an email foo@example.com ("Example User")
  2. Go to a page with a Users field, select "Example User"
  3. Change the email address for "Example User" to bar@example.com
  4. Attempt to do $field->toUsers() on the original page

Expected behavior
The user should still be accessible.

Kirby Version
3.1.x and 3.2.0

@texnixe

This comment has been minimized.

Copy link
Contributor

commented Jun 28, 2019

It might make sense to make what is stored optional, like in a select field

query:
  fetch: kirby.users.filterBy("role", "editor")
  text: '{{kirby.user.email}}'
  value: '{{kirby.user.id}}'

Not really a bug, more a feature request.

@GiantCrocodile

This comment has been minimized.

Copy link

commented Jun 29, 2019

I'm surprised that this really happens 😮. This is very far away from expected behavior and can be a real mess for productive sites. I think this should be changed very soon, as @neildaniels suggests.

@texnixe

This comment has been minimized.

Copy link
Contributor

commented Jun 30, 2019

This is very far away from expected behavior

The same happens if you delete a user and do not take care of removing the reference or outputting something else instead. The same happens for page or file references as well if you remove a page or if you rename a page slug (unless you use a manual or automatically generated permanent reference, for example using the AutoID plugin by @bnomei).

The main point here is the missing feature to store anything else but the email.

As long as this feature doesn't exist, you can use a hook that takes care of updating all references to a user email with the new one.

@bastianallgeier

This comment has been minimized.

Copy link
Contributor

commented Jul 1, 2019

We always try to keep the result in text files as human readable as possible in the first place. Kirby's file system should ideally stay editable without the panel. That's the reason why emails are stored instead of the ID. I agree that we need the additional feature to change that behaviour though.

@bnomei

This comment has been minimized.

Copy link

commented Jul 1, 2019

@texnixe the autoid plugin does not support generating values at the user content file yet. but if anyone has more sparetime than me right now and does a PR with a solution i would welcome this feature.

@texnixe

This comment has been minimized.

Copy link
Contributor

commented Jul 1, 2019

@bnomei Yes, I know, I just wanted to point it out as an example. However, we need the option to store values other than the email in the users field first before we can actually make use of an extended AutoId plugin. But after what @bastianallgeier wrote above I'm pretty confident we'll get this feature soon.

@afbora

This comment has been minimized.

Copy link

commented Jul 14, 2019

Can we also add this feature (Array Query Options) for pages and files field?

Forum discussion: https://forum.getkirby.com/t/invalid-value-for-query-on-fetching-pages-field/14925

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