craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 635 forks source link

[5.x]: Invalid numeric value after upgrading Craft CMS from 3 to 4 and then 4 to 5. #15152

Closed 23d1 closed 5 months ago

23d1 commented 5 months ago

What happened?

Description

Getting this after updating Craft CMS from 3 to 4 and then 4 to 5;

Invalid Argument – [yii\base\InvalidArgumentException](https://www.yiiframework.com/doc-2.0/yii-base-invalidargumentexception.html)
Invalid numeric value:

Here's the stack trace;

yii\base\InvalidArgumentException: Invalid numeric value:  in /Users/a/Sites/23d/craft/vendor/craftcms/cms/src/helpers/Db.php:608
Stack trace:
#0 /Users/a/Sites/23d/craft/vendor/craftcms/cms/src/helpers/Db.php(873): craft\helpers\Db::parseParam('elements.id', Object(craft\elements\Entry), '=', false, 'integer')
#1 /Users/a/Sites/23d/craft/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1538): craft\helpers\Db::parseNumericParam('elements.id', Object(craft\elements\Entry))
#2 /Users/a/Sites/23d/craft/vendor/yiisoft/yii2/db/QueryBuilder.php(227): craft\elements\db\ElementQuery->prepare(Object(craft\db\mysql\QueryBuilder))
#3 /Users/a/Sites/23d/craft/vendor/yiisoft/yii2/db/Query.php(157): yii\db\QueryBuilder->build(Object(benf\neo\elements\db\BlockQuery))
#4 /Users/a/Sites/23d/craft/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Query->createCommand(Object(craft\db\Connection))
#5 /Users/a/Sites/23d/craft/vendor/craftcms/cms/src/db/Query.php(247): yii\db\Query->all(NULL)
#6 /Users/a/Sites/23d/craft/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1739): craft\db\Query->all(NULL)
#7 /Users/a/Sites/23d/craft/vendor/spicyweb/craft-neo/src/elements/db/BlockQuery.php(255): craft\elements\db\ElementQuery->all(NULL)
#8 /Users/a/Sites/23d/craft/vendor/spicyweb/craft-neo/src/elements/db/BlockQuery.php(603): benf\neo\elements\db\BlockQuery->benf\neo\elements\db\{closure}()
#9 /Users/a/Sites/23d/craft/vendor/spicyweb/craft-neo/src/elements/db/BlockQuery.php(255): benf\neo\elements\db\BlockQuery->_setFilteredResultIfUsingMemoized(Object(Closure))
#10 /Users/a/Sites/23d/craft/vendor/twig/twig/src/Extension/CoreExtension.php(1635): benf\neo\elements\db\BlockQuery->all()
#11 /Users/a/Sites/23d/craft/vendor/craftcms/cms/src/helpers/Template.php(141): twig_get_attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(benf\neo\elements\db\BlockQuery), 'all', Array, 'method', false, false, false, 6)
#12 /Users/a/Sites/23d/craft/storage/runtime/compiled_templates/35/356673cc3c1a1e49d75697cd12746252.php(64): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(benf\neo\elements\db\BlockQuery), 'all', Array, 'method', false, false, false, 6)
#13 /Users/a/Sites/23d/craft/vendor/twig/twig/src/Template.php(394): __TwigTemplate_a054ae0a6a7fff1e0fc4f139c3531357->doDisplay(Array, Array)
#14 /Users/a/Sites/23d/craft/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
#15 /Users/a/Sites/23d/craft/storage/runtime/compiled_templates/81/81071d7e079a5c5c04d40d6ea436e62f.php(117): Twig\Template->display(Array)
#16 /Users/a/Sites/23d/craft/vendor/twig/twig/src/Template.php(394): __TwigTemplate_43039ac88838b197625124d7dc54f6d3->doDisplay(Array, Array)
#17 /Users/a/Sites/23d/craft/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
#18 /Users/a/Sites/23d/craft/storage/runtime/compiled_templates/4b/4bc4db0cabbf3747be84f03d61119cba.php(280): Twig\Template->display(Array)
#19 /Users/a/Sites/23d/craft/vendor/twig/twig/src/Template.php(171): __TwigTemplate_db87fe35c845154e6d32cfb5bb1ef275->block_header(Array, Array)
#20 /Users/a/Sites/23d/craft/storage/runtime/compiled_templates/4b/4bc4db0cabbf3747be84f03d61119cba.php(200): Twig\Template->displayBlock('header', Array, Array)
#21 /Users/a/Sites/23d/craft/vendor/twig/twig/src/Template.php(394): __TwigTemplate_db87fe35c845154e6d32cfb5bb1ef275->doDisplay(Array, Array)
#22 /Users/a/Sites/23d/craft/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
#23 /Users/a/Sites/23d/craft/storage/runtime/compiled_templates/3e/3eca4263732ff0dd4f7e5801b96fdeb5.php(43): Twig\Template->display(Array, Array)
#24 /Users/a/Sites/23d/craft/vendor/twig/twig/src/Template.php(394): __TwigTemplate_fccc7b100454240f43515e8ccd2e7948->doDisplay(Array, Array)
#25 /Users/a/Sites/23d/craft/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array)
#26 /Users/a/Sites/23d/craft/vendor/twig/twig/src/Template.php(379): Twig\Template->display(Array)
#27 /Users/a/Sites/23d/craft/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render(Array)
#28 /Users/a/Sites/23d/craft/vendor/twig/twig/src/Environment.php(280): Twig\TemplateWrapper->render(Array)
#29 /Users/a/Sites/23d/craft/vendor/craftcms/cms/src/web/View.php(482): Twig\Environment->render('index', Array)
#30 /Users/a/Sites/23d/craft/vendor/craftcms/cms/src/web/View.php(535): craft\web\View->renderTemplate('index', Array)
#31 /Users/a/Sites/23d/craft/vendor/craftcms/cms/src/web/TemplateResponseFormatter.php(57): craft\web\View->renderPageTemplate('index', Array, 'site')
#32 /Users/a/Sites/23d/craft/vendor/yiisoft/yii2/web/Response.php(1100): craft\web\TemplateResponseFormatter->format(Object(craft\web\Response))
#33 /Users/a/Sites/23d/craft/vendor/craftcms/cms/src/web/Response.php(338): yii\web\Response->prepare()
#34 /Users/a/Sites/23d/craft/vendor/yiisoft/yii2/web/Response.php(340): craft\web\Response->prepare()
#35 /Users/a/Sites/23d/craft/vendor/yiisoft/yii2/base/Application.php(390): yii\web\Response->send()
#36 /Users/a/Sites/23d/web/index.php(12): yii\base\Application->run()
#37 /Users/a/.composer/vendor/laravel/valet/server.php(250): require('/Users/a/Sites/...')
#38 {main}

Steps to reproduce

  1. Upgrade from 3 to 4 — Error started happening on most pages/URLs (not /admin/*)
  2. Upgrade from 4 to 5 — Error is persistent on all pages/URLs (not /admin/*)

Craft CMS version

5.1.9

PHP version

8.2.19

Operating system and version

macOS 14.5

Database type and version

MariaDB 11.4.2

Image driver and version

GD 8.2.19

Installed plugins and versions

ether/seo v5.0.0-rc3 spicyweb/craft-embedded-assets 5.1.0 putyourlightson/craft-blitz 5.3.1 spicyweb/craft-neo 5.0.1 verbb/buttonbox 5.0.0 lewisjenkins/craft-dynamic-fields 5.0.1 lewisjenkins/craft-range-slider 5.0.0 craftcms/ckeditor 4.0.6 vlucas/phpdotenv 5.6.0

23d1 commented 5 months ago

Ugh... I had missed the fact that twig had changed how to treat if statements in for loops, which is now handled by filters. And the ID error above is another example.