Type Error thrown when counting XML items

Created on 21 October 2024, 3 months ago

Problem/Motivation

We have an XML "importer" set-up on one of our sites that is based on migrate module. When the XML is empty, which is still a valid case in our scenario (nothing new will be imported), we are getting type error from the counting function:

TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in MigrateItemsXML->computeCount() (line 694 of migrate/plugins/sources/xml.inc).

Steps to reproduce

Run a migration with an empty XML.

Proposed resolution

Since we are using NULL as a value for cacheIDs property when there are no items, let's ask if we have the value first and only then call the count() or return 0 directly if we do not have a countable value.

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΈπŸ‡°Slovakia gresko8

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024