Using Craft CMS 3.5.0RC1, the SEOmatic plugin uses ->enabledForSite() which is now deprecated:
https://github.com/nystudio107/craft-seomatic/blob/v3/src/seoelements/SeoEntry.php#L227
return Entry::find()
->section($metaBundle->sourceHandle)
->id($elementId)
->siteId($siteId)
->enabledForSite(true)
->limit(1)
->one();
}
The `enabledForSite` element query param has been deprecated. `status()` should be used instead.
...which is fine. But it results in a hard error, rather than a deprecation notice and a mapping to the new intended behavior:
2020-07-23 10:46:41 [-][-][-][error][craft\queue\QueueLogBehavior::afterError] [8823] Generating notFound sitemap (attempt: 1) - Error (time: 0.086s): The `enabledForSite` element query param has been deprecated. `status()` should be used instead.
2020-07-23 10:46:41 [-][-][-][error][craft\errors\DeprecationException] craft\errors\DeprecationException: The `enabledForSite` element query param has been deprecated. `status()` should be used instead. in /home/forge/devmode.fm/releases/35afa05cf9c7234620d6d94438ca93d6dd7b7d0f/vendor/nystudio107/craft-seomatic/src/seoelements/SeoEntry.php:198
Stack trace:
#0 /home/forge/devmode.fm/releases/35afa05cf9c7234620d6d94438ca93d6dd7b7d0f/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1024): craft\services\Deprecator->log('ElementQuery::e...', 'The `enabledFor...')
#1 /home/forge/devmode.fm/releases/35afa05cf9c7234620d6d94438ca93d6dd7b7d0f/vendor/nystudio107/craft-seomatic/src/seoelements/SeoEntry.php(198): craft\elements\db\ElementQuery->enabledForSite(true)
Is this intended? If so, is moving to ->status() backwards compatible?
Looking at the code, it does look like it's just deprecated:
/**
* @inheritdoc
* @uses $enabledForSite
*/
public function enabledForSite(bool $value = true)
{
Craft::$app->getDeprecator()->log('ElementQuery::enabledForSite()', 'The `enabledForSite` element query param has been deprecated. `status()` should be used instead.');
$this->enabledForSite = $value;
return $this;
}
...but it looks like because a DeprecationException was thrown in the queue job, Craft thinks the Queue Job failed with an error. Seems like DeprecationException should be exempt from this?
This is happening on live production on devMode.fm -> https://github.com/nystudio107/devmode/blob/master/cms/config/app.php#L31
verified devMode is off on that site, so it shouldn't be throwing errors from the deprecator
Figured it out. We're doing this:
'components' => [
'deprecator' => [
'throwExceptions' => YII_DEBUG,
],
Which normally would be fine but...
<?php
/**
* Yii console bootstrap file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
defined('YII_DEBUG') or define('YII_DEBUG', true);
For console requests, Yii2 apparently specifically sets YII_DEBUG to true -- and since I'm running queues via a CLI task runner... any queue jobs will be run with YII_DEBUG set true and thus any the deprecator will throw hard errors.
I'm changing this to be more explicit:
'deprecator' => [
'throwExceptions' => App::env('DEV_MODE'),
],
nice path :)
actually, that was me, one of my more 'cloudy' places -- so you get an extra thumbs up also 馃尨馃悷
Most helpful comment
Figured it out. We're doing this:
Which normally would be fine but...
For console requests, Yii2 apparently specifically sets
YII_DEBUGtotrue-- and since I'm running queues via a CLI task runner... any queue jobs will be run withYII_DEBUGsettrueand thus any the deprecator will throw hard errors.I'm changing this to be more explicit: