Problem/Motivation

A view of users, with sort criteria only sorting on some fields in the user entity... It does NOT sort on creation date, or update date, or most recent login... or anything related to WHEN something happened. Just the content in the user profile.

user view details

When a user logs in, and changes a value in their user/UID/edit screen... It changes the sort order of the view.

Those users fly to the top of the view results, but UNDER the first sort criteria.

The first sort criteria is a boolean on the user profile. If its checked, show them first, unchecked below,...

Users who login and edit something move to the top, under that boolean check.

Steps to reproduce

See image above.

user profiles have many fields, some are entity references to taxonomy terms.

the view sorts based on the following.

* A boolean switch
* The weight of a "School" term. (relationship)
* The Weight of a "Major" term. (relationship)
* Last Name
* First Name

When the data was first displayed with this new sort logic, it was correct.

As soon as a user changed a value in their user/UID/edit screen, they popped up to the top of the sort, BELOW the boolean.

This image shows the behavior. The two circled results are user profiles who edited their user/UID/edit screen

results of view

The first one is out of order based on last name, but is in the first "school".

The second one, the pink one, should be 2 pages down...

I have tried to change SQL queries and caching... to no result.

Does it have something to do with the relationships on the terms?
we need that to control the sort order based on the weight position for the term -- not the term ID...

The SQL query

SELECT "user__field_phd_candidate"."field_phd_candidate_value" AS "user__field_phd_candidate_field_phd_candidate_value", "taxonomy_term_field_data_user__field_user_school"."weight" AS "taxonomy_term_field_data_user__field_user_school_weight", "taxonomy_term_field_data_user__field_user_major"."weight" AS "taxonomy_term_field_data_user__field_user_major_weight", "user__field_user_last_name"."field_user_last_name_value" AS "user__field_user_last_name_field_user_last_name_value", "user__field_user_first_name"."field_user_first_name_value" AS "user__field_user_first_name_field_user_first_name_value", "users_field_data"."uid" AS "uid", "taxonomy_term_field_data_user__field_user_major"."tid" AS "taxonomy_term_field_data_user__field_user_major_tid", "taxonomy_term_field_data_user__field_user_school"."tid" AS "taxonomy_term_field_data_user__field_user_school_tid"
FROM
{users_field_data} "users_field_data"
LEFT JOIN {user__field_user_major} "user__field_user_major" ON users_field_data.uid = user__field_user_major.entity_id AND user__field_user_major.deleted = '0'
LEFT JOIN {taxonomy_term_field_data} "taxonomy_term_field_data_user__field_user_major" ON user__field_user_major.field_user_major_target_id = taxonomy_term_field_data_user__field_user_major.tid
LEFT JOIN {user__field_user_school} "user__field_user_school" ON users_field_data.uid = user__field_user_school.entity_id AND user__field_user_school.deleted = '0'
LEFT JOIN {taxonomy_term_field_data} "taxonomy_term_field_data_user__field_user_school" ON user__field_user_school.field_user_school_target_id = taxonomy_term_field_data_user__field_user_school.tid
LEFT JOIN {user__roles} "user__roles_value_0" ON users_field_data.uid = user__roles_value_0.entity_id AND user__roles_value_0.roles_target_id = 'student'
INNER JOIN {user__field_user_year} "user__field_user_year" ON users_field_data.uid = user__field_user_year.entity_id AND user__field_user_year.deleted = '0'
LEFT JOIN {user__field_phd_candidate} "user__field_phd_candidate" ON users_field_data.uid = user__field_phd_candidate.entity_id AND user__field_phd_candidate.deleted = '0'
LEFT JOIN {user__field_user_last_name} "user__field_user_last_name" ON users_field_data.uid = user__field_user_last_name.entity_id AND user__field_user_last_name.deleted = '0'
LEFT JOIN {user__field_user_first_name} "user__field_user_first_name" ON users_field_data.uid = user__field_user_first_name.entity_id AND user__field_user_first_name.deleted = '0'
WHERE ((user__field_user_year.field_user_year_target_id = '148')) AND (("users_field_data"."status" = '1') AND ("user__roles_value_0"."roles_target_id" = 'student'))
ORDER BY "user__field_phd_candidate_field_phd_candidate_value" DESC, "taxonomy_term_field_data_user__field_user_school_weight" ASC, "taxonomy_term_field_data_user__field_user_major_weight" ASC, "user__field_user_last_name_field_user_last_name_value" ASC, "user__field_user_first_name_field_user_first_name_value" ASC
LIMIT 25 OFFSET 0

Thoughts?
Thank you!

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

alphex created an issue. See original summary.

alphex’s picture

Issue summary: View changes

typo fix.

larowlan’s picture

Category: Bug report » Support request
Issue tags: +Bug Smash Initiative
lendude’s picture

Status: Active » Postponed (maintainer needs more info)
StatusFileSize
new329.52 KB

Usually the culprit is the default click sort order used on the table format in the style settings. Looking at the screenshot this display is using an overridden format. Is the default display using a table? Can you set this display up so that it is not using an override? Does that help?

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

cilefen’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)