Skip to content

Commit

Permalink
class.xmlimporter.php - switch is_countable() to array()
Browse files Browse the repository at this point in the history
On PHP 7.2 `is_countable` creates an undefined function. `is_countable` is not available until PHP 7.3, <https://www.php.net/manual/en/function.is-countable.php>. 

In PHP 7.3, I get this error... "count(): Parameter must be an array or an object that implements Countable".

BUT, I found this... instead of `is_countable($value)`, **it works with `array($value)`** which I got from this Stack Overflow post, <https://stackoverflow.com/a/59818642>.
  • Loading branch information
bzerangue authored Dec 1, 2020
1 parent 5166aa6 commit 287d1da
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/class.xmlimporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ function handleXMLError($errno, $errstr, $errfile, $errline, $context) {
$field = FieldManager::fetch($field_id);

if(is_array($value)) {
if(count(is_countable($value)) === 1) {
if(count(array($value)) === 1) {
$value = current($value);
}
if(count(is_countable($value)) === 0) {
if(count(array($value)) === 0) {
$value = '';
}
}
Expand Down

0 comments on commit 287d1da

Please sign in to comment.