Skip to content

Fix TypeError when processing non-array semantics fields#296

Open
A-deranged-man wants to merge 1 commit into
h5p:masterfrom
A-deranged-man:fix/h5p-count-null-argument-type-error
Open

Fix TypeError when processing non-array semantics fields#296
A-deranged-man wants to merge 1 commit into
h5p:masterfrom
A-deranged-man:fix/h5p-count-null-argument-type-error

Conversation

@A-deranged-man

Copy link
Copy Markdown

Ensures that $semantics->fields is an array before calling count() on it. This prevents a TypeError if the property is null or another non-countable type.

Error:

Fatal error: Uncaught TypeError: count(): Argument #1 ($value) 
must be of type Countable|array, null given 
in h5p-php-library\h5p.classes.php on line 4713

Image of error on site:
Screenshot 2026-05-08 145830

Ensures that `$semantics->fields` is an array before calling `count()` on it. This prevents a `TypeError` if the property is `null` or another non-countable type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant