PHP Version: 7.4.4

Module throws the following warnings:

PHP Deprecated:  Array and string offset access syntax with curly braces is deprecated in /var/www/vhosts/brower/web/modules/contrib/h5p/vendor/h5p/h5p-core/h5p.classes.php on line 2747
PHP Deprecated:  Array and string offset access syntax with curly braces is deprecated in /var/www/vhosts/brower/web/modules/contrib/h5p/vendor/h5p/h5p-core/h5p-development.class.php on line 70

Update code for PHP 7.3 and 7.4 compatability

Comments

alasda created an issue. See original summary.

dakala’s picture

@alasda: This is an issue in the vendor package not in the Drupal module itself. It's been reported in the H5P issue queue here: https://github.com/h5p/h5p-php-library/issues/84. Interestingly enough, there's already a fix in the master branch:

https://github.com/h5p/h5p-php-library/blob/743147698f56b0433fe3bcb755d7...
https://github.com/h5p/h5p-php-library/blob/743147698f56b0433fe3bcb755d7...

It's a straightforward fix you can implement manually until there's an H5P release pulled into Drupal from the module.

daniel kulbe’s picture

Once those libraries get updated, the module itself needs to be updated as well.

somersoft’s picture

Until the change makes it way through, I have attached a patch file created from this commit PHP 7.4 fix, don't use curly braces for array/string offset

Example code for composer.json.

            "h5p/h5p-core": {
                "PHP 7.3, 7.4 deprecated syntax warnings - 3126374": "https://www.drupal.org/files/issues/2020-09-17/h5p-PHP_7_3_7_4_deprecated_syntax_warnings-3126374-4-D8.patch"
            }
catch’s picture

It might be useful for the Drupal h5p module to loosen the requirement slightly in composer.json - so that project can update to a dev version, or a new tag when one is released.

firstlut’s picture

StatusFileSize
new1.03 KB

Hey, guys!

I had trouble with the patch at #4, so I ran composer in verbose mode, and it couldn't find the files to patch. Turns out the file references were missing the folder structure: a/h5p-development.class.php instead of a/vendor/h5p/h5p-core/h5p-development.class.php

I don't know why this didn't turn up when I tried to make my own yesterday, but anyway.

Hope this helps.

vm’s picture

Category: Task » Bug report
Status: Active » Needs review
Issue tags: -PHP 7.3, -PHP 7.4, -deprecated

Patch in #6 works as expected. I applied it manually so I can't state if there are any issues with composer patch or patch in general.

Moving to needs review.

kwiechmann’s picture

Successfully applied patch #6 via composer. The patch itself works for me.

            "h5p/h5p-core": {
                "PHP 7.3, 7.4 deprecated syntax warnings - 3126374": "https://www.drupal.org/files/issues/2020-12-02/2020_12_02_h5p_syntax_update.patch"
            }
pjotr.savitski’s picture

You should probably close the issue as the version rc18 solves this issue.

paalj’s picture

Status: Needs review » Closed (duplicate)

This is already fixed in the vendor library