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
Generated 250 nodes with devel, turn on tracker module and go to /tracker
Error notices:
Notice: Undefined index: property in tracker_page() (line 132 of core/modules/tracker/tracker.pages.inc).
Warning: array_merge(): Argument #1 is not an array in tracker_page() (line 132 of core/modules/tracker/tracker.pages.inc)
.
The $last_activities_attributes variable is getting an empty array.
$last_activity_attributes = rdf_rdfa_attributes($last_activity_mapping, $node->last_activity);
Proposed resolution
Possibly check to if the property exists or that the array is not empty before trying to check and merge that 'property' key.
Comment | File | Size | Author |
---|---|---|---|
#20 | tracker-remove-rdfa-2100369-20.patch | 10.91 KB | ashepherd |
#15 | 2100369.15.test-only.patch | 785 bytes | alexpott |
#11 | 2100369-tracker-undefined-index-property.patch | 1.12 KB | joelpittet |
#6 | drupal_2100369_6.patch | 865 bytes | Xano |
#1 | 2100369-1-tracker-fix-rdf-notice.patch | 1000 bytes | joelpittet |
Comments
Comment #1
joelpittetHere's a patch that works and is fairly fast. Let me know if that's the right approach or maybe it has to do something different higher up (like not use rdf until it's enabled...)?
Comment #2
mcrittenden CreditAttribution: mcrittenden commentedComment #3
dags CreditAttribution: dags commentedConfirmed that this is an issue and this patch fixes it.
Comment #4
Xano1: 2100369-1-tracker-fix-rdf-notice.patch queued for re-testing.
Comment #5
Dries CreditAttribution: Dries commentedThis patch will eliminate the warning, but it also eliminates the array_merge. I believe this may cause incorrect results to be returned.
Comment #6
XanoThis patch doesn't prevent the merge, but just makes sure the array item required for the merge is created if it doesn't exist yet.
Comment #7
joelpittetMuch better approach, thank you Xano and Dries.
Gave it a test and works like a charm.
Comment #8
alexpottSince we're getting a warning here we obviously have no tests for this code :)
Comment #9
joelpittetI can't think of how to test this type of fix. Any suggestions?
Comment #10
joelpittetThis still exists as I ran into it again testing #1939092: Convert theme_mark() to Twig
Comment #11
joelpittetI should mention that #6 seems to no longer fix this issue.
Here's a re-roll that does, looks like both items being merged need to check for that missing property key.
Comment #12
alexpottSurely you can just create a test that does what the issue summary says - create some nodes and go to /tracker
Comment #13
joelpittetOh duh! I thought it was something devel does but it just happens regardless. Thanks for the *surely* trigger @alexpott.
Comment #14
joelpittet@alexpott there is already a test that does that but doesn't seem to fail. I tried tweaking it a bit but I'm not really sure what 'property' merging is used for, is that an RDF thing or something else?
Anyways it doesn't fail with the minimal code in testTrackerAll.
Comment #15
alexpottHere's a test only patch :)
Comment #17
dawehnerWe could also just work on getting #1941830: Convert tracker listings to a view in.
Comment #18
joelpittetThanks for the patch @alexpott you make this look easy:D
Now I wonder if we should maybe initialize those arrays in RDF now or use #11. Assigning to scor to see what he thinks.
Comment #19
scor CreditAttribution: scor commentedWe added RDFa support to tracker listings back in 2009 because I thought search engines would pick up recent updated content (and its RDFa) from the tracker, but sitemaps are, to this day, the de facto mechanism that search engines use to keep their index up to date. So, in hindsight, I don't think it makes sense to support RDFa in the tracker page, since search engines will ultimately look for this RDFa data in the node / entity pages, which is were we have all our RDFa markup. This way we can also get rid of more custom code that doesn't use the regular code flow from the field formatters to generate the RDFa markup (same as what we're aiming for with #2226493: Apply formatters and widgets to Node base fields).
We'll tackle this issue in the RDF code sprint we have later today.
Comment #20
ashepherd CreditAttribution: ashepherd commentedBased on comment #19 this patch removes RDFa support in the tracker module and the related RDF module test.
Comment #21
scor CreditAttribution: scor commentedLooks good to me, I couldn't find any other place where we had RDFa in the tracker module.
Comment #22
ashepherd CreditAttribution: ashepherd commentedComment #23
joelpittetGreat that fixes this! Thanks @ashepherd and @scor. 238 lines of code less!
Comment #24
catchMakes sense to just remove the support. Committed/pushed to 8.x, thanks!