Problem/Motivation

On the latest state of the main branch when visiting admin/content I get the following error equal to the number of nodes on the page.

Deprecated function: Using null as an array offset is deprecated, use an empty string instead in Drupal\Core\Entity\ContentEntityBase->hasTranslation() (line 984 of /var/www/html/repos/drupal/core/lib/Drupal/Core/Entity/ContentEntityBase.php).
Drupal\Core\Entity\ContentEntityBase->hasTranslation() (Line: 1911)
Twig\Extension\CoreExtension::getAttribute() (Line: 46)
__TwigTemplate_104c123cb839873dcefb442f12b3c12d->doDisplay() (Line: 402)
Twig\Template->yield() (Line: 386)
Twig\Template->render() (Line: 51)
Twig\TemplateWrapper->render() (Line: 35)
Drupal\Core\Template\TwigThemeEngine->renderTemplate() (Line: 388)
Drupal\Core\Theme\ThemeManager->render() (Line: 485)
Drupal\Core\Render\Renderer->doRender() (Line: 211)
Drupal\Core\Render\Renderer->render() (Line: 1809)
Drupal\views\Plugin\views\field\FieldPluginBase->theme() (Line: 767)
Drupal\views\Plugin\views\style\StylePluginBase->elementPreRenderRow()
call_user_func_array() (Line: 107)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 895)
Drupal\Core\Render\Renderer->doCallback() (Line: 428)
Drupal\Core\Render\Renderer->doRender() (Line: 211)
Drupal\Core\Render\Renderer->render() (Line: 704)
Drupal\views\Plugin\views\style\StylePluginBase->renderFields() (Line: 579)
Drupal\views\Plugin\views\style\StylePluginBase->renderGrouping() (Line: 467)
Drupal\views\Plugin\views\style\StylePluginBase->render() (Line: 2207)
Drupal\views\Plugin\views\display\DisplayPluginBase->render() (Line: 1586)
Drupal\views\ViewExecutable->render() (Line: 201)
Drupal\views\Plugin\views\display\Page->execute() (Line: 1681)
Drupal\views\ViewExecutable->executeDisplay() (Line: 80)
Drupal\views\Element\View::preRenderViewElement()
call_user_func_array() (Line: 107)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 895)
Drupal\Core\Render\Renderer->doCallback() (Line: 428)
Drupal\Core\Render\Renderer->doRender() (Line: 211)
Drupal\Core\Render\Renderer->render() (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->{closure:Drupal\Core\Render\MainContent\HtmlRenderer::prepare():235}() (Line: 619)
Drupal\Core\Render\Renderer::{closure:Drupal\Core\Render\Renderer::executeInRenderContext():619}()
Fiber->resume() (Line: 634)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 235)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 131)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 69)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray() (Line: 246)
Symfony\Component\EventDispatcher\EventDispatcher::{closure:Symfony\Component\EventDispatcher\EventDispatcher::optimizeListeners():241}() (Line: 206)
Symfony\Component\EventDispatcher\EventDispatcher->callListeners() (Line: 56)
Symfony\Component\EventDispatcher\EventDispatcher->dispatch() (Line: 188)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 30)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 114)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 88)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 61)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 54)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 753)
Drupal\Core\DrupalKernel->handle() (Line: 19)

same happens visiting admin/people leading also for a deprecation error for each user account created causing the exact same error as the one on admin/content. the errors dont show up with claro set as the admin theme while the errors show with the admin theme.

Steps to reproduce

  • set the theme to admin (experimental) on admin/appearance
  • go to admin/content
  • make sure you have at least one or two nodes already created.
  • go to admin/people
  • make sure you have at least one or two user accounts created

Proposed resolution

Fix the deprecation on admin/content and admin/people

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#14 gin-status-field-null-langcode.patch707 bytessuper_romeo

Comments

rkoller created an issue. See original summary.

adhershmnair’s picture

Tried to reproduce this on PHP 8.3.30 and PHP 8.4.18 with DDEV, using the default_admin theme and 5 test article nodes - the deprecation warning does not appear on admin/content.

Investigation findings:

  1. The template core/themes/default_admin/templates/views/views-view-field--status.html.twig calls entity.hasTranslation(row.node_field_data_langcode) on line 24.
  2. However, row.node_field_data_langcode does not exist as a property on the Views result row object (confirmed via get_object_vars()), so Twig resolves it to null.
  3. This null is passed to ContentEntityBase::hasTranslation() which uses it as an array key at line 984.
  4. On PHP 8.3/8.4, using null as an array key is silently cast to "" (empty string) - no deprecation is triggered.
  5. Could you share which PHP version you were using when you saw this error? That would help reproduce and confirm the fix.

rkoller’s picture

I use php8.5 which is the minimum requirement for drupal 12 / the main branch. haven't explicitly stated that after it is the minimum requirement. apologies. also probably related to #3546535: [meta] Deal with NULL as array key/offset where @andypost dealt with it for core already in the end of 2025. at that time gin wasn't in core yet as experimental. add the aforementioned meta as the parent issue. i am also uncertain if the problem applies to more pages in the admin ui for gin?

ishani patel’s picture

I've followed the same steps as mentioned, but have not replicated that deprecation error .

rkoller’s picture

@ishani patel not reproducible with php8.5?

vegardjo’s picture

Project: Drupal core » Gin Admin Theme
Version: main » 6.x-dev
Component: Admin theme » Code

I have the same using php 8.5.2. The error appears once per node on admin/content and once per user on admin/users.

You see it if you use Gin admin theme. If changing to Claro, the errors goes away.

Moving to Gin project, even though it is likely going into core pretty soon.

rkoller’s picture

@vegardjo it is in core already therefore i filed it against that component in core. it is called admin theme / default admin theme now

rkoller’s picture

Project: Gin Admin Theme » Drupal core
Component: Code » Admin theme
vegardjo’s picture

Ok, sorry for messing about :)

Though, a bit confused on exactly "how" it is in core? I have Gin 5.0.12 via composer on latest Drupal 11.3.5, and this is why Gin is available for me.

I see from some discussions that it was merged to 11.x, and called "Admin" or "Default admin", but that seems to not be in a release yet? I do not have the code in my codebase, and thus can not enable this either.

So per now, the error described here occurs for me when switching admin theme from Claro to (contrib) Gin 5, and that is the only way I have to test it.

(I guess it is simply not released in core yet, but in that case the same bug likely also exist in Gin contrib, and I assume not everyone will be able to update to latest core to fix it either, so it might need to be backported to Gin if fixed in core)

rkoller’s picture

no worries, gin got merged in #3556948: Merging Gin as Admin theme... On that merge it got renamed into "admin" then it got renamed to "default_admin" in #3576646: Rename Gin-based admin theme (which i still consider a bad choice). it went into the main branch and will be available as an experimental theme in the next public release which will be 12.0 and 11.4

for testing, in case you are using ddev simply run the following steps (the drupal12 project type ensures that the project is already set to php8.5 - without ddev you just have to remove the ddev prefix on every command and ensure that your local dev environment meets the php8.5 requirement):

mkdir defaultadmintest
cd defaultadmintest
ddev config --project-type=drupal12 --docroot=web
ddev composer create-project drupal/recommended-project:main-dev
ddev composer require drush/drush:14.x-dev
ddev drush si --account-name=admin --account-pass=admin -y
ddev drush theme:enable default_admin -y
ddev drush config:set system.theme admin default_admin -y
rkoller’s picture

Title: Using null as an array offset is deprecated error on admin/content » Using null as an array offset is deprecated error on admin/content and admin/people
Issue summary: View changes

realized that the deprecation error also happens on admin/people so i'Ve extended the issue summary accordingly

jurgenhaas’s picture

Version: 6.x-dev » main

Fixing the version to main.

If this issue is in core main and also in Gin 5.x, then we should have a second issue in the Gin project linking to this one so that we can fix it in contrib as well, as this will certainly be around for a couple of years as well.

rkoller’s picture

woops forgot to also switch back to the main branch, i've only reverted to the core repo, apologies.

and about gin 5.x, i've just installed gin 5.x on an install of drupal 11.x (after the system requirements dont allow to install 5.x for a site on the main branch). the errors are shown there as well. so a separate issue for gin 5.x would be needed as well

super_romeo’s picture

StatusFileSize
new707 bytes

Fast patch from AI.

berdir’s picture

This is a duplicate of #3580733: Warning when visiting /admin/people with the admin_theme theme which has more discussion and work already.

cilefen’s picture

Status: Active » Closed (duplicate)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.