Problem/Motivation

I just tried to test this module on simplytest.me, but it breaks upon module installation with the following error:

Fatal error: Arrays are not allowed in class constants in /home/d2zlo/www/sites/default/modules/fb_instant_articles/src/Normalizer/FieldItemListNormalizer.php on line 19

Proposed resolution

  • Fix the error above

Remaining tasks

  • Create a patch

User interface changes

n/a

API changes

  • FieldItemListNormalizer::FORMAT constant value might have to be changed?!

Data model changes

Comments

hctom created an issue. See original summary.

hctom’s picture

Title: FieldItemListNormalizer : Arrays are not allowed in class constants » FieldItemListNormalizer: Arrays are not allowed in class constants
Status: Active » Needs review
StatusFileSize
new1.06 KB

Attached is a patch that splits up the FieldItemListNormalizer::FORMAT constant into two different constants:

  • FieldItemListNormalizer::FORMAT_FBIA
  • FieldItemListNormalizer::FORMAT_FBIA_RSS
hctom’s picture

StatusFileSize
new1.13 KB
new1.02 KB

Just digged into the code a little deeper, so here is an even better patch without duplicating the format constant values, but using the corresponding values from the available normalizer classes.

hctom’s picture

StatusFileSize
new1.13 KB
new1.02 KB

Damn... I forgot to remove one parenthesis ;) So here is the working patch with interdiff on patch from comment #2

m4olivei’s picture

Thanks! This looks great. Could you file a PR on Github per the Contributing guidelines?

https://github.com/BurdaMagazinOrg/module-fb_instant_articles/blob/8.x-2...

We use Drupal for issues, Github for contributing code.

hctom’s picture

@m4olivei: Of course ;) Here is the corresponding PR:

https://github.com/BurdaMagazinOrg/module-fb_instant_articles/pull/120

I also did some more cosmetic changes on that PR:

  • Add missing trailing comma on last array $supported_formats element
  • Also name fbia_rss format in return value documentation

  • m4olivei authored 145c410 on 8.x-2.x
    Issue #2914843 by hctom: FieldItemListNormalizer: Arrays are not allowed...
  • hctom committed f4e1bd1 on 8.x-2.x
    Issue #2914843: Fix PHP error for unallowed array values in class...
m4olivei’s picture

Status: Needs review » Fixed

Reviewed and merged to 8.x-2.x. Looks great. Thanks so much!

Status: Fixed » Closed (fixed)

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