Skip to content
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

[5.x]: Cannot assign null to property craft\behaviors\RevisionBehavior::$revisionNum of type int #16200

Closed
tibbis opened this issue Nov 23, 2024 · 4 comments
Assignees
Labels

Comments

@tibbis
Copy link

tibbis commented Nov 23, 2024

What happened?

Description

When I add a new site or resave/all sections in a site, I get an error in the queue: "Cannot assign null to property craft\behaviors\RevisionBehavior::$revisionNum of type int" on two specific sections:

Image

Have tried running craft gc and resaving but always get this. I can release the job and the cms still works as expected but seems odd that I get this problem.

Craft CMS version

5.5.0.1

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@tibbis tibbis added the bug label Nov 23, 2024
@i-just
Copy link
Contributor

i-just commented Nov 25, 2024

Hi, thanks for reaching out! Could you please share the full stack trace for this error?

@tibbis
Copy link
Author

tibbis commented Nov 25, 2024

2024-11-25 10:28:23 [queue.INFO] [craft\queue\QueueLogBehavior::beforeExec]  [680940] Resaving Article entries (batch 1 of 7) (attempt: 1, pid: 49679) - Started {"memory":8873312} 
2024-11-25 10:28:23 [queue.ERROR] [craft\queue\QueueLogBehavior::afterError]  [680940] Resaving Article entries (batch 1 of 7) (attempt: 1, pid: 49679) - Error (time: 0.127s): Cannot assign null to property craft\behaviors\RevisionBehavior::$revisionNum of type int {"memory":9184008} 
2024-11-25 10:28:23 [queue.ERROR] [TypeError] TypeError: Cannot assign null to property craft\behaviors\RevisionBehavior::$revisionNum of type int in /var/www/html/vendor/yiisoft/yii2/BaseYii.php:557
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure()
#1 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(2345): yii\base\BaseObject->__construct()
#2 /var/www/html/vendor/craftcms/cms/src/elements/db/NestedElementQueryTrait.php(309): craft\elements\db\ElementQuery->createElement()
#3 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(3551): craft\elements\db\EntryQuery->createElement()
#4 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1778): craft\elements\db\ElementQuery->_createElements()
#5 /var/www/html/vendor/yiisoft/yii2/db/Query.php(251): craft\elements\db\ElementQuery->populate()
#6 /var/www/html/vendor/craftcms/cms/src/db/Query.php(292): yii\db\Query->all()
#7 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1851): craft\db\Query->all()
#8 /var/www/html/vendor/craftcms/cms/src/db/QueryBatcher.php(85): craft\elements\db\ElementQuery->all()
#9 /var/www/html/vendor/craftcms/cms/src/queue/BaseBatchedJob.php(117): craft\db\QueryBatcher->getSlice()
#10 /var/www/html/vendor/yiisoft/yii2-queue/src/Queue.php(243): craft\queue\BaseBatchedJob->execute()
#11 /var/www/html/vendor/yiisoft/yii2-queue/src/cli/Queue.php(162): yii\queue\Queue->handleMessage()
#12 /var/www/html/vendor/yiisoft/yii2-queue/src/cli/Command.php(146): yii\queue\cli\Queue->execute()
#13 [internal function]: yii\queue\cli\Command->actionExec()
#14 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#15 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#16 /var/www/html/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction()
#17 /var/www/html/vendor/craftcms/cms/src/console/ControllerTrait.php(88): yii\console\Controller->runAction()
#18 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): craft\queue\Command->runAction()
#19 /var/www/html/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction()
#20 /var/www/html/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction()
#21 /var/www/html/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction()
#22 /var/www/html/vendor/craftcms/cms/src/console/Application.php(122): yii\console\Application->handleRequest()
#23 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest()
#24 /var/www/html/craft(13): yii\base\Application->run()
#25 {main} {"memory":9184224,"exception":"[object] (TypeError(code: 0): Cannot assign null to property craft\\behaviors\\RevisionBehavior::$revisionNum of type int at /var/www/html/vendor/yiisoft/yii2/BaseYii.php:557)"} 
2024-11-25 10:28:23 [queue.INFO] [yii\db\Connection::open] Opening DB connection: mysql:host=db;dbname=db;port=3306 {"memory":9191704} 
2024-11-25 10:28:23 [queue.ERROR] [TypeError] TypeError: Cannot assign null to property craft\behaviors\RevisionBehavior::$revisionNum of type int in /var/www/html/vendor/yiisoft/yii2/BaseYii.php:557
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure()
#1 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(2345): yii\base\BaseObject->__construct()
#2 /var/www/html/vendor/craftcms/cms/src/elements/db/NestedElementQueryTrait.php(309): craft\elements\db\ElementQuery->createElement()
#3 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(3551): craft\elements\db\EntryQuery->createElement()
#4 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1778): craft\elements\db\ElementQuery->_createElements()
#5 /var/www/html/vendor/yiisoft/yii2/db/Query.php(251): craft\elements\db\ElementQuery->populate()
#6 /var/www/html/vendor/craftcms/cms/src/db/Query.php(292): yii\db\Query->all()
#7 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1851): craft\db\Query->all()
#8 /var/www/html/vendor/craftcms/cms/src/db/QueryBatcher.php(85): craft\elements\db\ElementQuery->all()
#9 /var/www/html/vendor/craftcms/cms/src/queue/BaseBatchedJob.php(117): craft\db\QueryBatcher->getSlice()
#10 /var/www/html/vendor/yiisoft/yii2-queue/src/Queue.php(243): craft\queue\BaseBatchedJob->execute()
#11 /var/www/html/vendor/yiisoft/yii2-queue/src/cli/Queue.php(162): yii\queue\Queue->handleMessage()
#12 /var/www/html/vendor/yiisoft/yii2-queue/src/cli/Command.php(146): yii\queue\cli\Queue->execute()
#13 [internal function]: yii\queue\cli\Command->actionExec()
#14 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#15 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams()
#16 /var/www/html/vendor/yiisoft/yii2/console/Controller.php(180): yii\base\Controller->runAction()
#17 /var/www/html/vendor/craftcms/cms/src/console/ControllerTrait.php(88): yii\console\Controller->runAction()
#18 /var/www/html/vendor/yiisoft/yii2/base/Module.php(552): craft\queue\Command->runAction()
#19 /var/www/html/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction()
#20 /var/www/html/vendor/craftcms/cms/src/console/Application.php(91): yii\console\Application->runAction()
#21 /var/www/html/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction()
#22 /var/www/html/vendor/craftcms/cms/src/console/Application.php(122): yii\console\Application->handleRequest()
#23 /var/www/html/vendor/yiisoft/yii2/base/Application.php(384): craft\console\Application->handleRequest()
#24 /var/www/html/craft(13): yii\base\Application->run()
#25 {main} {"memory":9233104,"exception":"[object] (TypeError(code: 0): Cannot assign null to property craft\\behaviors\\RevisionBehavior::$revisionNum of type int at /var/www/html/vendor/yiisoft/yii2/BaseYii.php:557)"} 

@i-just
Copy link
Contributor

i-just commented Nov 26, 2024

Thanks! I’m not able to replicate this. Any chance you could send your composer.json, composer.lock and database export to support@craftcms.com so we can try to reproduce and dig deeper?

@i-just i-just self-assigned this Nov 26, 2024
@tibbis
Copy link
Author

tibbis commented Nov 26, 2024

For anyone else, this solved it:
delete elements from elements left join revisions on elements.revisionId = revisions.id where elements.revisionId is not null and revisions.id is null

@tibbis tibbis closed this as completed Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants