Problem/Motivation
When visiting a content translation add page (e.g. /node/1/translations/add/en/af), PathBasedBreadcrumbBuilder checks access for each parent path segment. Because the entity.{entity_type}.content_translation_add route defines both {source} and {target} as optional parameters (defaulting to NULL), the breadcrumb builder also triggers access checks for partial paths such as /node/1/translations/add/en (source=en, target=NULL) and /node/1/translations/add (source=NULL, target=NULL).
ContentTranslationManageAccessCheck::access() passes these NULL values directly to LanguageManager::getLanguage(), which performs an array lookup $languages[$langcode]. Using NULL as an array offset is deprecated in PHP 8.5, producing:
Deprecated function: Using null as an array offset is deprecated, use an empty string instead in Drupal\Core\Language\LanguageManager->getLanguage()
The same method already guards the $language parameter correctly (lines 73–76), but the $source and $target parameters on lines 104–105 were missing the equivalent null check.
Steps to reproduce
1. Enable content_translation and configure at least two languages.
2. Create a translatable node.
3. Log in as a non-superadmin user with translation permissions.
4. Visit /node/{nid}/translations/add/{source}/{target}.
5. Observe the PHP 8.5 deprecation notice in the logs
Proposed resolution
- Guard $source and $target before passing them to getLanguage(), consistent with the existing pattern used in other places.
- Add a unit/kernel test showcasing the missing coverage.
Remaining tasks
?
User interface changes
None
Introduced terminology
None
API changes
None
Data model changes
None
Release notes snippet
None
Issue fork drupal-3590967
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
herved commentedComment #5
liam morlandThe changes look good. I rebased the merge request.