Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The aggregator_item entity does not declare the fid (feed ID) base field to be required, but saving an aggregator_item without a fid will fatal error in getCacheTagsToInvalidate() trying to reference the non-existent feed ID. This is a problem for me in #2590993: Create stub entities with proper default values - that issue will populate required fields with appropriate values when creating migration stubs, but needs to know that a field is required to do that.
Proposed resolution
A simple setRequired(TRUE) on the base field. This is verified to work with my stubbing patch.
Remaining tasks
Submit a patch with a test.
User interface changes
None
API changes
None
Data model changes
None
Comments
Comment #2
mikeryanComment #3
phenaproximaThe indentation around Item::create() is strange, and it might be helpful to assert the constraint violation message (or something).
Other than that, looks good to me.
Comment #4
alexpottWe need an empty hook_update_N to force a cache clear.
Comment #5
mikeryanIndentation fixed.
Removed the comment at the end of the test, which I think is only a distraction... That reflects the original symptom, but the fix is being tested here.
Added an update function.
Comment #6
phenaproximaHmmm, the test seems to have vanished from this patch :(
Comment #7
mikeryanCreate feature branch
Apply patch that creates new file
Commit changes to feature branch <- easy to forget this step
git diff 8.0.x
Comment #8
phenaproximaAce. Pre-RTBC assuming DrupalCI passes.
Comment #11
phenaproximaComment #12
catchDiscussed with @xjm, @alexpott and @effulgentsia.
We agreed this should be an RC target. It would be nice to see a test only patch exposing the failure.
Comment #13
mikeryanFailure exposed!
Comment #15
mikeryanAs expected.
Comment #17
mikeryanEnough with the fail test already...
Comment #18
alexpottCommitted 22716ab and pushed to 8.0.x. Thanks!
changed to rc on commit.
Comment #21
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedNote that this is not correct. Adding an empty update function does not update the "last installed" field storage definition automatically.
Since we shouldn't touch existing update functions, this is being fixed in #2346019-25: Handle initial values when creating a new field storage definition, see the
system_update_8300()
function from that patch.Comment #22
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedOn second thought, I opened a separate followup issue to fix this: #2840595: The 'Source feed' field of aggregator items has to be updated and marked as required.