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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

KarenS created an issue. See original summary.

ChristophWeber’s picture

For 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.

KarenS’s picture

Status: Active » Postponed (maintainer needs more info)

I 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.

KarenS’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
5.85 KB

Found 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.

  • KarenS committed e064dd6 on 7.x-1.x
    Issue #2945333 by KarenS: Make D7 version compatible with PHP 7
    
KarenS’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.