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.
I tried a test of the D7 version in PHP 7 and the empty values don't get stripped out of the result. That is probably still valid as far as Google goes but should be fixed.
Comment | File | Size | Author |
---|---|---|---|
#4 | php7-compatibility-2945333.patch | 5.85 KB | KarenS |
Comments
Comment #2
ChristophWeber CreditAttribution: ChristophWeber as a volunteer and at BIZX LLC commentedFor what it's worth I am testing the D7 module on PHP 7.0.21 exclusively. No issues this far.
You're right, empty values aren't stripped, but if they don't stand for a required property Google doesn't mind and structured data validates fine. My previous JSON-LD solutions (with https://www.drupal.org/sandbox/nsciacca/2765653 still in production) don't strip empty values either and this never hurt us.
Comment #3
KarenS CreditAttribution: KarenS at Lullabot commentedI see no problems in 7.1, and tests pass for that as well. This causes tests against 7.0 to fail, but doesn't actually affect functionality or validation. So I'm inclined to not worry about this for release. It would help to identify the specific environment that fails because I can't replicate any problems locally so far, all I know is the test against 7.0 fails because of the extra empty values.
Comment #4
KarenS CreditAttribution: KarenS at Lullabot commentedFound the issue and did some general cleanup. It mostly affects deeply nested elements and in that situation it may involve more than just PHP 7. Here's a patch that seems to work, still testing. There's some cruft in the patch since I went ahead and did some general cleanup of SchemaMetatagManager as well. But the important part is the arrayTrim function which was not cleaning out empty values completely on deeply nested arrays. Which was made worse by the validation function that didn't work exactly right.
Comment #6
KarenS CreditAttribution: KarenS at Lullabot commented