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

Exception thrown on garbage collection #5684

Closed
Saboteur777 opened this issue Feb 19, 2020 · 6 comments
Closed

Exception thrown on garbage collection #5684

Saboteur777 opened this issue Feb 19, 2020 · 6 comments

Comments

@Saboteur777
Copy link
Contributor

Saboteur777 commented Feb 19, 2020

Description

./craft gc
Delete all trashed items? (yes|no) [no]:yes
Running garbage collection ... Exception 'TypeError' with message 'Argument 1 passed to craft\services\Elements::deleteElement() must implement interface craft\base\ElementInterface, null given, called in /var/www/vendor/craftcms/cms/src/services/Drafts.php on line 471'

in /var/www/vendor/craftcms/cms/src/services/Elements.php:1201

Stack trace:
#0 /var/www/vendor/craftcms/cms/src/services/Drafts.php(471): craft\services\Elements->deleteElement(NULL, true)
#1 /var/www/vendor/craftcms/cms/src/services/Gc.php(57): craft\services\Drafts->purgeUnsavedDrafts()
#2 /var/www/vendor/craftcms/cms/src/console/controllers/GcController.php(56): craft\services\Gc->run(true)
#3 [internal function]: craft\console\controllers\GcController->actionRun()
#4 /var/www/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#5 /var/www/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#6 /var/www/vendor/yiisoft/yii2/console/Controller.php(164): yii\base\Controller->runAction('', Array)
#7 /var/www/vendor/craftcms/cms/src/console/Controller.php(187): yii\console\Controller->runAction('', Array)
#8 /var/www/vendor/yiisoft/yii2/base/Module.php(528): craft\console\Controller->runAction('', Array)
#9 /var/www/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('gc', Array)
#10 /var/www/vendor/craftcms/cms/src/console/Application.php(87): yii\console\Application->runAction('gc', Array)
#11 /var/www/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('gc', Array)
#12 /var/www/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#13 /var/www/craft(22): yii\base\Application->run()
#14 {main}

Steps to reproduce

  1. Run ./craft gc on Craft CMS 3.4.6.1

Additional info

  • Craft version: 3.4.6.1
  • PHP version: 7.3.6
  • Database driver & version: MySQL 5.5.5
@brandonkelly
Copy link
Member

Not able to reproduce this. Please send in a database backup along with your composer.json and composer.lock files to support@craftcms.com.

@SayChi
Copy link

SayChi commented Feb 20, 2020

I've had a similar problem (not 3.4.6.1 though) before, if you look in the database in the craft_drafts table you'll likely see some rows where sourceId is null, deleting those fixed the issue for me (without messing anything else up as far as I could tell).

In my case I'm pretty sure I messed something up with a module that I was working on, so deleted some entries incorrectly

@Saboteur777
Copy link
Contributor Author

@SayChi I do use a custom module and yes, I do delete entries - what was the solution in your case?

@brandonkelly Must be because my module: I will let you know what was the issue, don't want to waste your time on this until I am sure it's a bug in Craft not in my code.

@SayChi
Copy link

SayChi commented Feb 20, 2020

@Saboteur777 Don't think I've actually solved the issue in the module I was building, customer request ended up changing so I had to change my implementation. But you can manually fix it by looking in the craft_drafts table and just throwing out any row that doesn't have an id in the sourceId column.

@Saboteur777
Copy link
Contributor Author

@SayChi Sure, I will do that - I am just afraid that it will happen in the future and would like to avoid it happening.

@brandonkelly
Copy link
Member

We just released Craft 3.4.7 with a fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants