Problem/Motivation
While running update.php on Drupal 10.2, the following warning is triggered:
Warning: Undefined array key "title" in Drupal\update\ProjectSecurityRequirement::createFromProjectDataAndSecurityCoverageInfo()
This occurs during update status checks and can be reproduced consistently.
Steps to reproduce
- Install Drupal 10.2.
- Ensure Update Manager (core
updatemodule) is enabled. - Run
/update.php. - Observe PHP warning during the update process.
Actual result
The following PHP warning is displayed:
Warning: Undefined array key "title" in Drupal\update\ProjectSecurityRequirement::createFromProjectDataAndSecurityCoverageInfo()
Debugging shows that the issue originates from:
core/modules/update/src/ProjectSecurityRequirement.php:103
if (isset($project_data['existing_version'])) { [$major, $minor] = explode('.', $project_data['existing_version']); $existing_version = "$major.$minor"; $next_version = "$major." . ((int) $minor + 1); return new static($project_data['title'], $security_coverage_info, $existing_version, $next_version); }
The code assumes $project_data['title'] exists.
However, the announcements feed project entry (from Update Manager data) does not always contain a title key, which results in the undefined array key warning.
Expected result
update.php should run without PHP warnings.
The code should safely handle cases where title is missing in $project_data.
Additional context
While debugging, it was observed that the announcements feed project data does not include a title value, which leads to the warning when creating ProjectSecurityRequirement objects.
This appears to be an edge case where project data returned by the update system does not match the assumptions in ProjectSecurityRequirement::createFromProjectDataAndSecurityCoverageInfo().
Screenshot:
Proposed resolution
Add a defensive check before accessing $project_data['title'], for example:
$title = $project_data['title'] ?? $project_data['name'] ?? 'Unknown'; return new static($title, $security_coverage_info, $existing_version, $next_version);
Alternatively, ensure all project data provided to this method always includes a title.
Environment
- Drupal: 10.2.x
- PHP: (add version)
- Reproducible: Yes
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 3-3412207.patch | 855 bytes | samir_shukla |
| Capture d'écran 2024-01-04 015628.png | 212.63 KB | lazzyvn |
Issue fork drupal-3412207
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 #2
lazzyvn commentedComment #4
samir_shuklaHi, I have created patch for the issue. Please review.
Comment #5
samir_shuklaComment #6
smustgrave commentedRecommended to use MRs vs patches
Tagging for issue summary as it should follow the standard issue template.
Also will need a test case.
Comment #7
tanmaykAs @smustgrave suggested, it needs issue summary with steps to reproduce the issue on fresh Drupal 10 install.
This issue may happen if module, which have hook_requirements implemented, returns an array without title in it. This title is used on Status Report page (
$phase == 'runtime').Do you have any contributed module installed which may have causing this issue? Or do you have custom modules installed as well? Try checking all entries on Status report page if it shows empty title somewhere. If you find it, please post a screenshot so we can figure out which module is causing this.
@samir_shukla This should be fixed in respective module as I mentioned above & not in core unless any core module causing this. In any case, that's not correct place to do the change :)
Comment #9
ecvandenberg commentedThis issue has a solution in /project/drupal/issues/3132426
Comment #10
djg_tram commentedThat's not a solution, that's a workaround. Another year has passed and the issue is still present.
Comment #12
pearls commentedThe issue is still ongoing. We are currently using Drupal version 11.3.3.
Comment #13
sivaji_ganesh_jojodae commented