Open michaelborn opened 2 years ago
It's worth noting that this same export also fails in Bolt 5.1.12 on PHP 7.4. (Albeit with a slightly different error message.) So this is not just a PHP 8 issue, as I previously thought.
// Importing ContentType content
8/72 [=====>--------------------------------------------] 11% 1 sec/9 secs 54.5 MiB
In ContentEditController.php line 442:
[ErrorException]
Notice: Undefined index: order
Exception trace:
at /home/user/myBoltSite/vendor/bolt/core/src/Controller/Backend/ContentEditController.php:442
Bolt\Controller\Backend\ContentEditController->updateCollections() at /home/user/myBoltSite/vendor/bobdenotter/conimex/src/Import.php:344
BobdenOtter\Conimex\Import->importRecord() at /home/user/myBoltSite/vendor/bobdenotter/conimex/src/Import.php:118
BobdenOtter\Conimex\Import->importContentType() at /home/user/myBoltSite/vendor/bobdenotter/conimex/src/Import.php:87
BobdenOtter\Conimex\Import->import() at /home/user/myBoltSite/vendor/bobdenotter/conimex/src/Command/ImportCommand.php:62
BobdenOtter\Conimex\Command\ImportCommand->execute() at /home/user/myBoltSite/vendor/symfony/console/Command/Command.php:298
Symfony\Component\Console\Command\Command->run() at /home/user/myBoltSite/vendor/symfony/console/Application.php:1042
Symfony\Component\Console\Application->doRunCommand() at /home/user/myBoltSite/vendor/symfony/framework-bundle/Console/Application.php:96
Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /home/user/myBoltSite/vendor/symfony/console/Application.php:299
Symfony\Component\Console\Application->doRun() at /home/user/myBoltSite/vendor/symfony/framework-bundle/Console/Application.php:82
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/user/myBoltSite/vendor/symfony/console/Application.php:171
Symfony\Component\Console\Application->run() at /home/user/myBoltSite/bin/console:48
conimex:import <filename>
I'm guessing this is a case of an old conimex
version, and not an issue in Bolt Core.
I can see the order
set on the collection field in the Conimex extension here:
Nope - this still occurs on the latest conimex
v 2.1.2. Unsure whether the issue is in conimex or in bolt/core.
I still don't know if this is a Conimex bug or a Bolt core bug, but I was able to fix by adding a check for array length in the collections
array in ContentEditController.php:
if (isset($formData['collections'])) {
foreach ($formData['collections'] as $collectionName => $collectionItems) {
if ( !count( $collectionItems ) ) continue; // NEW LINE HERE
This prevents line 433 from flipping out (pun!) because $collectionItems['order']
doesn't exist.
https://github.com/bolt/core/blob/master/src/Controller/Backend/ContentEditController.php#L433
Is this a newbie fix, or should I PR this?
I get a warning
"Warning: Undefined array key "order"
after running a conimex import:I believe this is a new / more strict warning in PHP 8?
https://stackoverflow.com/questions/71025115/dealing-with-php-8-1-warning-for-undefined-array-key
Details
Reproduction
Stack trace:
Steps to reproduce
Evidently, importing a conimex import which does not include the
order
key.Expected result
I expected that my content would import.
Actual result
A failed import, with no ability to skip the warning.