-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
When importing CSV data with the "Modify the existing page" option selected for duplicate page names, the module throws a fatal error:
Fatal Error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in ImportPagesCSV.module:515
This occurs because $page->get('ImportPagesCSVData') returns null for existing pages that are being modified, but the code attempts to call count() on it without checking if it's an array first.
Steps to Reproduce
- Import CSV data to create pages
- Re-import the same CSV data with "Modify the existing page" option selected
- Fatal error occurs on line 515
Proposed Fix
Line 515: Add null/array check before count()
// Before:
if($page->id && count($page->get('ImportPagesCSVData'))) {
// After:
$importData = $page->get('ImportPagesCSVData');
if($page->id && is_array($importData) && count($importData)) {Line 609 (in modifyPage method): Transfer ImportPagesCSVData to existing page
// Add after the foreach loop, before return:
if($data) {
$existingPage->set('ImportPagesCSVData', $data);
}This ensures file imports and other post-save data work correctly when overwriting existing pages.
Environment
- PHP 8.2 (stricter type checking for count())
- ProcessWire 3.0.252 (and earlier)
- ImportPagesCSV module 1.0.8
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels