count(): Argument #1 ($value) must be of type Countable|array, null given
Closed this issue · 3 comments
daedric7 commented
Hello, i was trying to test this and on book:scan i'm getting the error in the issue title.
-vvv bellow:
./bin/console -vvv books:scan
Scanning books directory
0/84 [>---------------------------] 0% < 1 sec/< 1 sec 22.0 MiB00:26:01 INFO [deprecation] User Deprecated: In ORM 3.0, the AttributeDriver will report fields for the classes where they are declared. This may uncover invalid mapping configurations. To opt into the new mode today, set the "reportFieldsWhereDeclared" constructor parameter to true. (AttributeDriver.php:79 called by App_KernelDevDebugContainer.php:1923, https://github.com/doctrine/orm/pull/10455, package doctrine/orm)
[
"exception" => ErrorException {
#message: "User Deprecated: In ORM 3.0, the AttributeDriver will report fields for the classes where they are declared. This may uncover invalid mapping configurations. To opt into the new mode today, set the "reportFieldsWhereDeclared" constructor parameter to true. (AttributeDriver.php:79 called by App_KernelDevDebugContainer.php:1923, https://github.com/doctrine/orm/pull/10455, package doctrine/orm)"
#code: 0
#file: "./vendor/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php"
#line: 210
#severity: E_USER_DEPRECATED
trace: {
./vendor/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php:210 { …}
./vendor/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php:108 { …}
./vendor/doctrine/orm/src/Mapping/Driver/AttributeDriver.php:79 { …}
./var/cache/dev/ContainerFKSgkET/App_KernelDevDebugContainer.php:1923 {
ContainerFKSgkET\App_KernelDevDebugContainer::getDoctrine_Orm_DefaultAttributeMetadataDriverService($container)^
› {
› return $container->privates['doctrine.orm.default_attribute_metadata_driver'] = new \Doctrine\ORM\Mapping\Driver\AttributeDriver([(\dirname(__DIR__, 4).'/src/Entity'), (\dirname(__DIR__, 4).'/vendor/gedmo/doctrine-extensions/src/Sluggable'), (\dirname(__DIR__, 4).'/vendor/gedmo/doctrine-extensions/src/Blameable'), (\dirname(__DIR__, 4).'/vendor/gedmo/doctrine-extensions/src/Timestampable')], false);
› }
}
./var/cache/dev/ContainerFKSgkET/App_KernelDevDebugContainer.php:913 { …}
./var/cache/dev/ContainerFKSgkET/App_KernelDevDebugContainer.php:883 { …}
./vendor/symfony/var-exporter/Internal/LazyObjectState.php:100 { …}
./vendor/symfony/var-exporter/LazyGhostTrait.php:178 { …}
./vendor/doctrine/orm/src/EntityManager.php:206 { …}
./vendor/doctrine/persistence/src/Persistence/AbstractManagerRegistry.php:194 { …}
./vendor/doctrine/doctrine-bundle/src/Repository/LazyServiceEntityRepository.php:71 { …}
./vendor/doctrine/doctrine-bundle/src/Repository/LazyServiceEntityRepository.php:49 { …}
./vendor/doctrine/orm/src/EntityRepository.php:238 { …}
./src/Service/BookManager.php:170 { …}
./src/Service/BookManager.php:152 { …}
./src/Command/BooksScanCommand.php:57 { …}
./vendor/symfony/console/Command/Command.php:326 { …}
./vendor/symfony/console/Application.php:1096 { …}
./vendor/symfony/framework-bundle/Console/Application.php:126 { …}
./vendor/symfony/console/Application.php:324 { …}
./vendor/symfony/framework-bundle/Console/Application.php:80 { …}
./vendor/symfony/console/Application.php:175 { …}
./vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49 { …}
./vendor/autoload_runtime.php:29 { …}
./bin/console:12 { …}
}
}
]
9/84 [===>------------------------] 10% < 1 sec/< 1 sec 28.0 MiB00:26:01 CRITICAL [console] Error thrown while running command "-vvv books:scan". Message: "count(): Argument #1 ($value) must be of type Countable|array, null given"
[
"exception" => TypeError {
#message: "count(): Argument #1 ($value) must be of type Countable|array, null given"
#code: 0
#file: "./vendor/kiwilan/php-ebook/src/Formats/Mobi/Parser/MobiParser.php"
#line: 50
trace: {
./vendor/kiwilan/php-ebook/src/Formats/Mobi/Parser/MobiParser.php:50 { …}
./vendor/kiwilan/php-ebook/src/Formats/Mobi/MobiModule.php:51 { …}
./vendor/kiwilan/php-ebook/src/Ebook.php:284 { …}
./vendor/kiwilan/php-ebook/src/Ebook.php:113 { …}
./src/Service/BookManager.php:98 {
App\Service\BookManager->extractEbookMetadata(SplFileInfo $file): array^
›
› $ebook = Ebook::read($file->getRealPath());
› if (!$ebook instanceof Ebook) {
arguments: {
$path: "/var/www/html/public/books/George R R Martin/01 A Game Of Thrones/A Game Of Thrones - George R. R. Martin.mobi"
}
}
./src/Service/BookManager.php:34 { …}
./src/Service/BookManager.php:184 { …}
./src/Service/BookManager.php:152 { …}
./src/Command/BooksScanCommand.php:57 { …}
./vendor/symfony/console/Command/Command.php:326 { …}
./vendor/symfony/console/Application.php:1096 { …}
./vendor/symfony/framework-bundle/Console/Application.php:126 { …}
./vendor/symfony/console/Application.php:324 { …}
./vendor/symfony/framework-bundle/Console/Application.php:80 { …}
./vendor/symfony/console/Application.php:175 { …}
./vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49 { …}
./vendor/autoload_runtime.php:29 { …}
./bin/console:12 { …}
}
},
"command" => "-vvv books:scan",
"message" => "count(): Argument #1 ($value) must be of type Countable|array, null given"
]
00:26:01 DEBUG [console] Command "-vvv books:scan" exited with code "1"
[
"command" => "-vvv books:scan",
"code" => 1
]
In MobiParser.php line 50:
[TypeError]
count(): Argument #1 ($value) must be of type Countable|array, null given
Exception trace:
at /var/www/html/vendor/kiwilan/php-ebook/src/Formats/Mobi/Parser/MobiParser.php:50
count() at /var/www/html/vendor/kiwilan/php-ebook/src/Formats/Mobi/Parser/MobiParser.php:50
Kiwilan\Ebook\Formats\Mobi\Parser\MobiParser->get() at /var/www/html/vendor/kiwilan/php-ebook/src/Formats/Mobi/MobiModule.php:51
Kiwilan\Ebook\Formats\Mobi\MobiModule->toEbook() at /var/www/html/vendor/kiwilan/php-ebook/src/Ebook.php:284
Kiwilan\Ebook\Ebook->convertEbook() at /var/www/html/vendor/kiwilan/php-ebook/src/Ebook.php:113
Kiwilan\Ebook\Ebook::read() at /var/www/html/src/Service/BookManager.php:98
App\Service\BookManager->extractEbookMetadata() at /var/www/html/src/Service/BookManager.php:34
App\Service\BookManager->createBook() at /var/www/html/src/Service/BookManager.php:184
App\Service\BookManager->consumeBook() at /var/www/html/src/Service/BookManager.php:152
App\Service\BookManager->consumeBooks() at /var/www/html/src/Command/BooksScanCommand.php:57
App\Command\BooksScanCommand->execute() at /var/www/html/vendor/symfony/console/Command/Command.php:326
Symfony\Component\Console\Command\Command->run() at /var/www/html/vendor/symfony/console/Application.php:1096
Symfony\Component\Console\Application->doRunCommand() at /var/www/html/vendor/symfony/framework-bundle/Console/Application.php:126
Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /var/www/html/vendor/symfony/console/Application.php:324
Symfony\Component\Console\Application->doRun() at /var/www/html/vendor/symfony/framework-bundle/Console/Application.php:80
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/html/vendor/symfony/console/Application.php:175
Symfony\Component\Console\Application->run() at /var/www/html/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49
Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /var/www/html/vendor/autoload_runtime.php:29
require_once() at /var/www/html/bin/console:12
books:scan [-b|--book-path BOOK-PATH] [-c|--consume]
SergioMendolia commented
Hello @daedric7 thanks for reporting.
I submitted a fix on the library where the issue originated and added better exception management here.
If you are on :latest
you can pull the latest image which should fix the issue.
daedric7 commented
Seems to be solved! scan was now completed, only 1 warning:
42/84 [==============>-------------] 50% 20 secs/40 secs 200.5 MiB23:53:52 DEBUG [php] Warning: gzuncompress(): data error
[
"exception" => Symfony\Component\ErrorHandler\Exception\SilencedErrorContext^ {
+count: 1
-severity: E_WARNING
trace: {
./vendor/smalot/pdfparser/src/Smalot/PdfParser/RawData/FilterHelper.php:239 { …}
./vendor/smalot/pdfparser/src/Smalot/PdfParser/RawData/FilterHelper.php:72 { …}
}
}
]
23:53:52 DEBUG [php] Warning: gzuncompress(): data error
[
"exception" => Symfony\Component\ErrorHandler\Exception\SilencedErrorContext^ {
+count: 101
-severity: E_WARNING
trace: {
./vendor/smalot/pdfparser/src/Smalot/PdfParser/RawData/FilterHelper.php:239 { …}
./vendor/smalot/pdfparser/src/Smalot/PdfParser/RawData/FilterHelper.php:72 { …}
}
}
]
Error reading archive: /var/www/html/public/books/J R R Tolkien/Other Books/History of Middle Earth (post-Tolkien essays)/JRR Tolkien - History of Middle Earth (post-Tolkien essays).pdf
SergioMendolia commented
Since it's only a warning and the original issue is resolved, I will now close this issue. I will try to find a pdf that has the same output and see if an upgrade of the 3rd party library solves it