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

[3.7]: Users native fields not applied in orderBy param #12241

Closed
cakleimeier opened this issue Nov 1, 2022 · 6 comments
Closed

[3.7]: Users native fields not applied in orderBy param #12241

cakleimeier opened this issue Nov 1, 2022 · 6 comments
Assignees

Comments

@cakleimeier
Copy link

What happened?

Description

The firstName and lastName Users native fields are not applied in the orderBy parameter or in the Users element list view in the Control Panel.

Steps to reproduce

Note: The following steps also apply to the native firstName field.

  1. Create, or have, a list of Users with the native lastName field populated.
  2. In the template, use some version of a Users element query, ordered by lastName. Example: {% set items = craft.users.orderBy('lastName asc').all() %}
  3. OR, in the Control Panel, ensure that the Last Name field is set as a visible table column and try to sort by that field.

Expected behavior

The expectation is that the list of Users will be output alphabetically, according to the lastName field.

Actual behavior

The result is that the list of Users is not output alphabetically by lastName.

Craft CMS version

3.7.59 and 3.7.55.2

PHP version

8.0.24

Operating system and version

No response

Database type and version

mariadb:10.6

Image driver and version

No response

Installed plugins and versions

@cakleimeier cakleimeier changed the title [3.x]: [3.x]: Users native fields not applied in orderBy param Nov 1, 2022
@cakleimeier cakleimeier changed the title [3.x]: Users native fields not applied in orderBy param [3.7]: Users native fields not applied in orderBy param Nov 1, 2022
@brianjhanson brianjhanson self-assigned this Nov 1, 2022
@brianjhanson
Copy link
Contributor

Thanks for reaching out! Unfortunately, I'm having some trouble replicating this one. Do you have any plugin or module code that could be altering the element query by chance? Are you able to determine what order they are actually being shown? I'm curious if the order they are showing in might offer any clues.

@cakleimeier
Copy link
Author

@brianjhanson , I'm seeing this same issue on at least two sites, one of which has no module code at all. The two have some plugins in common, but nothing that should affect the Users in this way:

  • craftcms/postmark
  • craftcms/redactor
  • nystudio107/craft-seomatic
  • nystudio107/craft-twigpack
  • sebastianlenz/linkfield
  • topshelfcraft/wordsmith
  • verbb/field-manager
  • verbb/super-table
  • vlucas/phpdotenv

It seems that most of the Users are in something of an alphabetical order, but with more recent users first. At least one of the two sites had the Users imported, if that makes a difference?

@brianjhanson
Copy link
Contributor

brianjhanson commented Nov 2, 2022

Any chance some of the imported users were accidentally imported with a space before the value? For example, imported as " Lastname" instead of "Lastname"?

If not, could you send a database dump and your composer files over to [email protected] so I can dig deeper?

@cakleimeier
Copy link
Author

@brianjhanson , I don't see any spaces before the value, no. I suppose it's possible, but I don't think that's very likely. I'll send over those files as soon as I can, though. Thanks for your help on this!

@brianjhanson
Copy link
Contributor

Sounds like @olivierbon got you sorted out 🎉

For any wanderers ending up here in the future, this ended up being caused by multiple fields with the firstName/lastName handles.

@brandonkelly
Copy link
Member

We just released Craft 4.3.2 which includes firstName and lastName in the list of reserved field handles for the user field layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants