I have User, Language, and Content translation enabled.

I created a couple of user accounts before Language and Content Translation were enabled (especially user 1, no choice in that matter!).

I have User entities set to translatable, and I've added a translatable text field to the user account entity.

If I go to the Translate tab for a user account, such as user/1/translations, I get a PHP error. I've seen this on other translation pages too:

Warning: array_filter() expects parameter 1 to be array, null given in content_translation_overview() (line 49 of core/modules/content_translation/content_translation.pages.inc).

content_translation_overview(Object)

Drupal\content_translation\Controller\ContentTranslationController->overview(Object)

call_user_func_array(Array, Array)

Drupal\Core\Controller\HtmlPageController->getContentResult(Object, '\Drupal\content_translation\Controller\ContentTranslationController::overview')

Drupal\Core\Controller\HtmlPageController->content(Object, '\Drupal\content_translation\Controller\ContentTranslationController::overview')

call_user_func_array(Array, Array)

Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)

Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)

Drupal\Core\DrupalKernel->handle(Object)

If I go to the Edit tab and save the entity (forcing it to save the content language, which maybe wasn't on the user before?), then go back to Translate, the errors go away.

So I think this is because when I originally created the users, the language wasn't set up. User 2 (created before language was installed) also has this problem, but not User 3 (created after language was installed).

Maybe this is a symptom of #1966436: Default *content* entity languages are not set for entities created with the API; however, user 2 was created in the UI, so I am not sure this applies?

CommentFileSizeAuthor
#4 2323935-4.patch1.89 KBandypost

Comments

andypost’s picture

jhodgdon’s picture

Status: Active » Postponed

We should probably postpone this until #1966436: Default *content* entity languages are not set for entities created with the API is taken care of, because I think it will prevent this problem.

andypost’s picture

Status: Postponed » Active

Currently I get that warning when visiting user/1/translations

Warning: array_filter() expects parameter 1 to be array, null given in Drupal\content_translation\Controller\ContentTranslationController->overview() (line 74 of core/modules/content_translation/src/Controller/ContentTranslationController.php).
Drupal\content_translation\Controller\ContentTranslationController->overview(Object, 'user')
call_user_func_array(Array, Array)
Drupal\Core\Controller\HtmlPageController->getContentResult(Object, '\Drupal\content_translation\Controller\ContentTranslationController::overview')
Drupal\Core\Controller\HtmlPageController->content(Object, '\Drupal\content_translation\Controller\ContentTranslationController::overview')
call_user_func_array(Array, Array)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)
andypost’s picture

Title: PHP error on Translations page for content created prior to enabling » PHP warning on Translations page for content created prior to enabling
Status: Active » Needs review
Related issues: +#1916790: Convert translation metadata into regular entity fields
StatusFileSize
new1.89 KB

This removes warning but adds some todos

jhedstrom’s picture

Status: Needs review » Reviewed & tested by the community

I think this makes sense (although ideally we'd just get the patch mentioned in the @todo committed).

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Especially with this being refactored again in the future I think it makes sense to have some tests for this. Setting to needs work for that as skimming the issue summary it seems that wouldn't be rocket science. Please reset if I missed something.

Status: Needs work » Needs review

Berdir queued 4: 2323935-4.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 4: 2323935-4.patch, failed testing.

Anonymous’s picture

#1916790: Convert translation metadata into regular entity fields got in, so the todo's probably can be removed/replaced now.

jhedstrom’s picture

Is there anything left to be done here then? In manual testing, this appears fixed by #1916790: Convert translation metadata into regular entity fields.

omar’s picture

Status: Needs work » Closed (fixed)

Tested process manually and cannot reproduce (any) errors with beta10. Closing ticket.

jhodgdon’s picture

Priority: Major » Normal
Status: Closed (fixed) » Active

Hm. OK, I checked again on my local machine just to be sure (it has strict PHP warnings being shown):
- Created a text field for Users.
- Created a user and edited user 1 to add values to that field.
- Enabled Language and Content Translation
- Added Spanish language
- Set up User entity, and that field on User, to be translatable
- Visit user/1/translations and user/2/translations
==> Here, there is one oddity, in that it says that the English version is "Not published" in the list of translations.
- Click Add from here to add a translation, which goes to es/user/1/translations/add/en/es - this seems OK

And then after translating, when I go back to the User list page, I have two copies of User 1. That's also not right, but it's a separate issue.

So the warning is gone but the problem is not exactly completely gone.

jhodgdon’s picture

Title: PHP warning on Translations page for content created prior to enabling » Translations page for content created prior to enabling shows "unpublished" for English versions
Issue tags: +Needs issue summary update

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Status: Active » Closed (outdated)

@jhodgdon, thanks for the error report and the clear steps for testing.

I tested this on 8.6.19, starting from a fresh install of the standard profile.

I used these steps, from #12. The '***' indicates where my results differ.
- Created a text field for Users.
- Created a user and edited user 1 to add values to that field.
- Enabled Language and Content Translation
- Added Spanish language
- Set up User entity, and that field on User, to be translatable
- Visit user/1/translations and user/2/translations
*** There is NO error here the English version is Published.

- Click Add from here to add a translation, which goes to es/user/1/translations/add/en/es - this seems OK

And then after translating, when I go back to the User list page, I have two copies of User 1. That's also not right, but it's a separate issue.
*** This is no longer true, there is just 1 copy of user 1 and 1 copy of user 2.

Based on this testing this issue has been fixed. Since this was reported when Drupal 8 was in beta it isn't surprising that this has been fixed somewhere along the way. I haven't searched for the issue that fixed this, just relying on manual testing.

closing as outdated.