Skip to content

Fix: avoid count() crash in ImportListView on non-array headerColumns #650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: hotfix
Choose a base branch
from

Conversation

aamirsk8766
Copy link

This PR fixes a potential fatal error that occurs during the import process when $headerColumns is not an array.

In ImportListView.php, the following line:

$this->ss->assign('colCount', count($this->headerColumns));

can throw an error like:

Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, bool given

This usually happens if something goes wrong earlier in the import process and $headerColumns ends up being false or unset.

Motivation and Context
This change ensures that the import view doesn't break if $headerColumns isn’t an array. It's a small defensive coding fix, but it improves stability for users importing large or complex datasets.

How To Test This
Go to the Import section for the Targets module.

Try importing a large or malformed CSV file.

Confirm that the page doesn’t crash with a count() error.

Verify that the number of columns is displayed correctly if $headerColumns is valid.

Types of changes
Bug fix (non-breaking change which fixes an issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant