Problem/Motivation
When adding new fields to user accounts via /admin/config/people/accounts/fields and then editing the user account and setting a value for the new fields so they can be pulled into a view block does not display in the view unless the user account has at least 1 published or unpublished node content. Very...strange!
For about 3 days I went round and round thinking I had some kind of permission problem, removing contrib modules that handle extra permissions or events like ECA, Content Access, ACL and eliminating any other possibilities I could think of that could be causing this issue. After reading through probably 50 different posts on similar events occuring.
I couldn't understand why some accounts would display the new view blocks (being displayed on user/* account pages with the new fields data) showing the complete view block with the correct data and other accounts would only show partial data and not the new fields data (even when those fields have value) especially since I have the fields in the view set to display even when empty including display rewrite if empty. I used the rewrite output to display the field but with some added html, ID's and classes - so even if the field had no data it should still display but that didn't even happen. Thus why I thought I had a permission problem somewhere!
By the time I was done with all that, basically stripped all permissions between fields and the view and view blocks themselves "and the same thing was/is happening" (getting overly frustrated at this point I started digging further into it.) The entire time no errors, warning or issues reported anywhere, not in dblog or onscreen or browser console, nothing...
Roles, permissions, etc., all set the same between all accounts (this should not be happening). The only difference I could find between any accounts was the fact that some accounts have published and unpublished node content while others did not. The ones that in the past had/have at least one published or unpublished node (did not matter what the content type was/is) their account view blocks were working as expected displaying the new field data from the user account (which to note, those fields are in NO WAY attached to any content type). Now on the other side any account that has never published a node and does not have any unpublished nodes as well are the accounts not displaying the view blocks with the new fields data.
OK, found a difference I can test...
Using the masquerade module I switched to a user account without any published node type content and add a new node of any content type the user account can access. Once completed I go back to the users account page and "waahhhh'laaa" the view block now showed properly. I switched accounts back to administrator account and then to make sure it still works, I check the users account page and all is good and then I unpublish that users node content to make sure it still shows and it does for both admin and user accounts.
Now before just posting this here, the field I initially added to the user accounts was actually a paragraph with 2 number fields so to rule out the paragraph module as causing this issue I created a new "test number field" again at /admin/config/people/accounts/fields then duplicated my view block removed the original field and added the new one and placed the block on the same user account pages and got the same exact issue in my results.
I'll include some sample images showing the issue before and after the user has a published node. I also tested to see if a user without a published or unpublished node could trigger the view to work properly by another published entity like comments which did not work!
That said I'm not entirely sure why not having a published or unpublished node content type that isn't related to the user account fields display through a view. It just doesn't make sense.
You'll see on the example images the before image looking at /user/4 (I have the field themselves displayed just as the fields as per user display of fields and then the view blocks in the right sidebar which should also have the data and does not. When all is said and done the fields themselves won't be displayed there just the view blocks with the fields data will because of what and how they are being used all around.
It's also worth mentioning using "preview" in views using user id's to preview with contextual filters also produces the same results. If user has a published or unpublished node everything displays properly. If the user does not have a published or unpublished node the view does not display properly.
Regarding the view there is no default filter criteria or sort criteria for the view and it uses relationships "User" and Contextual filter "(User) User: User ID" -> set to Provide default value: Type "User ID from route context".
For good measure:
Drupal: 10.2.6
PHP: 8.1.13
Apache: 2.4.38 (Debian)
Database: MySQL 5.7.40
Steps to reproduce
SEE COMMENT #3 https://www.drupal.org/project/drupal/issues/3447170#comment-15596991 for steps to reproduce.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet