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

Transform Process throws error (recursively?), filling up /tmp directory with failed imagick transforms. #1515

Closed
bryantwells opened this issue Sep 20, 2024 · 7 comments
Labels

Comments

@bryantwells
Copy link

bryantwells commented Sep 20, 2024

Describe the bug

SEOmatic seems to be attempting to generate an image thumbnail from an entry that doesn't have one – resulting in a continuous stream of errors (multiple times per second).

To reproduce

  1. entry type with thumbnail handle set to a matrix field type.
  2. image source SEOmatic setting is custom image on all Content SEO and Global SEO pages.
  3. image transform SEOmatic setting is off on all Content SEO and Global SEO pages.
  4. loading page with entry type results in the following error (in both local and remote environments):
2024-09-20 13:18:42 [web.ERROR] [Twig\Error\RuntimeError] An exception has been thrown during the rendering of a template ("craft\services\Assets::getAssetById(): Argument #1 ($assetId) must be of type int, craft\elements\Entry given, called in /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/helpers/ImageTransform.php on line 306") in "__string_template__7dc26910b55cfe7c5904a7881f8e8693" at line 1. {"trace":["#0 /home/ploi/domain.tld/vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling()","#1 /home/ploi/domain.tld/vendor/twig/twig/src/Template.php(379): Twig\\Template->display()","#2 /home/ploi/domain.tld/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\\Template->render()","#3 /home/ploi/domain.tld/vendor/craftcms/cms/src/web/View.php(684): Twig\\TemplateWrapper->render()","#4 /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/helpers/MetaValue.php(276): craft\\web\\View->renderObjectTemplate()","#5 /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/helpers/MetaValue.php(102): nystudio107\\seomatic\\helpers\\MetaValue::parseMetaString()","#6 /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/helpers/MetaValue.php(149): nystudio107\\seomatic\\helpers\\MetaValue::parseString()","#7 /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/services/MetaContainers.php(545): nystudio107\\seomatic\\helpers\\MetaValue::parseArray()","#8 /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/services/MetaContainers.php(979): nystudio107\\seomatic\\services\\MetaContainers->addMetaBundleToContainers()","#9 /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/services/MetaContainers.php(446): nystudio107\\seomatic\\services\\MetaContainers->loadContentMetaContainers()","#10 [internal function]: nystudio107\\seomatic\\services\\MetaContainers->nystudio107\\seomatic\\services\\{closure}()","#11 /home/ploi/domain.tld/vendor/yiisoft/yii2/caching/Cache.php(608): call_user_func()","#12 /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/services/MetaContainers.php(438): yii\\caching\\Cache->getOrSet()","#13 /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/twigextensions/SeomaticTwigExtension.php(54): nystudio107\\seomatic\\services\\MetaContainers->loadMetaContainers()","#14 /home/ploi/domain.tld/vendor/twig/twig/src/ExtensionSet.php(331): nystudio107\\seomatic\\twigextensions\\SeomaticTwigExtension->getGlobals()","#15 /home/ploi/domain.tld/vendor/twig/twig/src/Environment.php(787): Twig\\ExtensionSet->getGlobals()","#16 /home/ploi/domain.tld/vendor/twig/twig/src/Environment.php(800): Twig\\Environment->getGlobals()","#17 /home/ploi/domain.tld/vendor/twig/twig/src/Template.php(367): Twig\\Environment->mergeGlobals()","#18 /home/ploi/domain.tld/vendor/twig/twig/src/Template.php(379): Twig\\Template->display()","#19 /home/ploi/domain.tld/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\\Template->render()","#20 /home/ploi/domain.tld/vendor/twig/twig/src/Environment.php(280): Twig\\TemplateWrapper->render()","#21 /home/ploi/domain.tld/vendor/craftcms/cms/src/web/View.php(501): Twig\\Environment->render()","#22 /home/ploi/domain.tld/vendor/craftcms/cms/src/web/View.php(554): craft\\web\\View->renderTemplate()","#23 /home/ploi/domain.tld/vendor/craftcms/cms/src/web/TemplateResponseFormatter.php(57): craft\\web\\View->renderPageTemplate()","#24 /home/ploi/domain.tld/vendor/yiisoft/yii2/web/Response.php(1109): craft\\web\\TemplateResponseFormatter->format()","#25 /home/ploi/domain.tld/vendor/craftcms/cms/src/web/Response.php(338): yii\\web\\Response->prepare()","#26 /home/ploi/domain.tld/vendor/yiisoft/yii2/web/Response.php(340): craft\\web\\Response->prepare()","#27 /home/ploi/domain.tld/vendor/yiisoft/yii2/base/Application.php(390): yii\\web\\Response->send()","#28 /home/ploi/domain.tld/public_html/index.php(22): yii\\base\\Application->run()","#29 {main}"],"memory":4527584,"exception":"[object] (Twig\\Error\\RuntimeError(code: 0): An exception has been thrown during the rendering of a template (\"craft\\services\\Assets::getAssetById(): Argument #1 ($assetId) must be of type int, craft\\elements\\Entry given, called in /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/helpers/ImageTransform.php on line 306\") in \"__string_template__7dc26910b55cfe7c5904a7881f8e8693\" at line 1. at /home/ploi/domain.tld/vendor/twig/twig/src/Template.php:408)\n[previous exception] [object] (TypeError(code: 0): craft\\services\\Assets::getAssetById(): Argument #1 ($assetId) must be of type int, craft\\elements\\Entry given, called in /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/helpers/ImageTransform.php on line 306 at /home/ploi/domain.tld/vendor/craftcms/cms/src/services/Assets.php:118)"} 
2024-09-20 13:18:42 [web.ERROR] [nystudio107\seomatic\helpers\MetaValue::parseMetaString] Error rendering `{seomatic.helper.socialTransformWidth(object.entry.thumbnail.collect()[0], seomatic.helper.twitterTransform(), 1, "crop")}` -> An exception has been thrown during the rendering of a template ("craft\services\Assets::getAssetById(): Argument #1 ($assetId) must be of type int, craft\elements\Entry given, called in /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/helpers/ImageTransform.php on line 306") in "__string_template__e55b0213c0883d49ed34ca8f8d6ebf87" at line 1. - {seomatic.helper.socialTransformWidth(object.entry.thumbnail.collect()[0], seomatic.helper.twitterTransform(), 1, "crop")} {"memory":4588432} 

Versions

  • Plugin version: 5.1.2
  • Craft version: 5.3.4

Screen Shot 2024-09-20 at 13 43 29

@philipboomy
Copy link

I wonder if this is related to an error I see as well.

[craft\errors\ImageTransformException] Failed to generate transform with id of 3. {"trace":["#0 /home/ploi/www.website.co.uk/vendor/craftcms/cms/src/elements/Asset.php(2171): craft\\imagetransforms\\ImageTransformer->getTransformUrl()","#1 /home/ploi/www.website.co.uk/vendor/craftcms/cms/src/elements/Asset.php(2098): craft\\elements\\Asset->_url()","#2 /home/ploi/www.balloonsoverbritain.co.uk/vendor/nystudio107/craft-seomatic/src/helpers/ImageTransform.php(151): craft\\elements\\Asset->getUrl()","#3 /home/ploi/www.website.co.uk/vendor/nystudio107/craft-seomatic/src/services/Helper.php(459): nystudio107\\seomatic\\helpers\\ImageTransform::socialTransform()"

@khalwat
Copy link
Collaborator

khalwat commented Sep 25, 2024

@philipboomy probably unrelated, that's just your VPS failing to be able to do a regular old image transform. Check your logs, it could be as simple as an image that's too large for Imagick to handle.

https://x.com/nystudio107/status/1363124167764238337

@khalwat
Copy link
Collaborator

khalwat commented Sep 25, 2024

Formatted @bryantwells's error to be a little more readable. I think I know what's going on here.

2024-09-20 13:18:42 [web.ERROR] [Twig\Error\RuntimeError] An exception has been thrown during the rendering of a template ("craft\services\Assets::getAssetById(): Argument #1 ($assetId) must be of type int, craft\elements\Entry given, called in /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/helpers/ImageTransform.php on line 306") in "__string_template__7dc26910b55cfe7c5904a7881f8e8693" at line 1. {"trace":["
#0 /home/ploi/domain.tld/vendor/twig/twig/src/Template.php(367): Twig\\Template->displayWithErrorHandling()","
#1 /home/ploi/domain.tld/vendor/twig/twig/src/Template.php(379): Twig\\Template->display()","
#2 /home/ploi/domain.tld/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\\Template->render()","
#3 /home/ploi/domain.tld/vendor/craftcms/cms/src/web/View.php(684): Twig\\TemplateWrapper->render()","
#4 /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/helpers/MetaValue.php(276): craft\\web\\View->renderObjectTemplate()","
#5 /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/helpers/MetaValue.php(102): nystudio107\\seomatic\\helpers\\MetaValue::parseMetaString()","
#6 /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/helpers/MetaValue.php(149): nystudio107\\seomatic\\helpers\\MetaValue::parseString()","
#7 /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/services/MetaContainers.php(545): nystudio107\\seomatic\\helpers\\MetaValue::parseArray()","
#8 /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/services/MetaContainers.php(979): nystudio107\\seomatic\\services\\MetaContainers->addMetaBundleToContainers()","
#9 /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/services/MetaContainers.php(446): nystudio107\\seomatic\\services\\MetaContainers->loadContentMetaContainers()","
#10 [internal function]: nystudio107\\seomatic\\services\\MetaContainers->nystudio107\\seomatic\\services\\{closure}()","
#11 /home/ploi/domain.tld/vendor/yiisoft/yii2/caching/Cache.php(608): call_user_func()","
#12 /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/services/MetaContainers.php(438): yii\\caching\\Cache->getOrSet()","
#13 /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/twigextensions/SeomaticTwigExtension.php(54): nystudio107\\seomatic\\services\\MetaContainers->loadMetaContainers()","
#14 /home/ploi/domain.tld/vendor/twig/twig/src/ExtensionSet.php(331): nystudio107\\seomatic\\twigextensions\\SeomaticTwigExtension->getGlobals()","
#15 /home/ploi/domain.tld/vendor/twig/twig/src/Environment.php(787): Twig\\ExtensionSet->getGlobals()","
#16 /home/ploi/domain.tld/vendor/twig/twig/src/Environment.php(800): Twig\\Environment->getGlobals()","
#17 /home/ploi/domain.tld/vendor/twig/twig/src/Template.php(367): Twig\\Environment->mergeGlobals()","
#18 /home/ploi/domain.tld/vendor/twig/twig/src/Template.php(379): Twig\\Template->display()","
#19 /home/ploi/domain.tld/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\\Template->render()","
#20 /home/ploi/domain.tld/vendor/twig/twig/src/Environment.php(280): Twig\\TemplateWrapper->render()","
#21 /home/ploi/domain.tld/vendor/craftcms/cms/src/web/View.php(501): Twig\\Environment->render()","
#22 /home/ploi/domain.tld/vendor/craftcms/cms/src/web/View.php(554): craft\\web\\View->renderTemplate()","
#23 /home/ploi/domain.tld/vendor/craftcms/cms/src/web/TemplateResponseFormatter.php(57): craft\\web\\View->renderPageTemplate()","
#24 /home/ploi/domain.tld/vendor/yiisoft/yii2/web/Response.php(1109): craft\\web\\TemplateResponseFormatter->format()","
#25 /home/ploi/domain.tld/vendor/craftcms/cms/src/web/Response.php(338): yii\\web\\Response->prepare()","
#26 /home/ploi/domain.tld/vendor/yiisoft/yii2/web/Response.php(340): craft\\web\\Response->prepare()","
#27 /home/ploi/domain.tld/vendor/yiisoft/yii2/base/Application.php(390): yii\\web\\Response->send()","
#28 /home/ploi/domain.tld/public_html/index.php(22): yii\\base\\Application->run()","
#29 {main}"],"memory":4527584,"exception":"[object] (Twig\\Error\\RuntimeError(code: 0): An exception has been thrown during the rendering of a template (\"craft\\services\\Assets::getAssetById(): Argument 
#1 ($assetId) must be of type int, craft\\elements\\Entry given, called in /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/helpers/ImageTransform.php on line 306\") in \"__string_template__7dc26910b55cfe7c5904a7881f8e8693\" at line 1. at /home/ploi/domain.tld/vendor/twig/twig/src/Template.php:408)
[previous exception] [object] (TypeError(code: 0): craft\\services\\Assets::getAssetById(): Argument #1 ($assetId) must be of type int, craft\\elements\\Entry given, called in /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/helpers/ImageTransform.php on line 306 at /home/ploi/domain.tld/vendor/craftcms/cms/src/services/Assets.php:118)"} 
2024-09-20 13:18:42 [web.ERROR] [nystudio107\seomatic\helpers\MetaValue::parseMetaString] Error rendering `{seomatic.helper.socialTransformWidth(object.entry.thumbnail.collect()[0], seomatic.helper.twitterTransform(), 1, "crop")}` -> An exception has been thrown during the rendering of a template ("craft\services\Assets::getAssetById(): Argument #1 ($assetId) must be of type int, craft\elements\Entry given, called in /home/ploi/domain.tld/vendor/nystudio107/craft-seomatic/src/helpers/ImageTransform.php on line 306") in "__string_template__e55b0213c0883d49ed34ca8f8d6ebf87" at line 1. - {seomatic.helper.socialTransformWidth(object.entry.thumbnail.collect()[0], seomatic.helper.twitterTransform(), 1, "crop")} {"memory":4588432} 

@khalwat
Copy link
Collaborator

khalwat commented Sep 25, 2024

@bryantwells so it looks like somehow an Entry element is being passed in to a function in SEOmatic that's expecting either an Asset or an asset ID.

When you mention a thumbnail handle that's a Matrix field... is that somehow being set to the SEO image somewhere?

khalwat added a commit that referenced this issue Sep 25, 2024
khalwat added a commit that referenced this issue Sep 25, 2024
khalwat added a commit that referenced this issue Sep 25, 2024
@khalwat
Copy link
Collaborator

khalwat commented Sep 25, 2024

I fixed the obvious error, but I'm still unclear on how it could make it down to that code path.

Give this a whirl and let me know the results, and also address my question above?

Craft CMS 3:

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-seomatic": "dev-develop as 3.5.4”,

Then do a composer clear-cache && composer update

…..

Craft CMS 4:

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-seomatic": "dev-develop-v4 as 4.1.4”,

Then do a composer clear-cache && composer update

…..

Craft CMS 5:

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-seomatic": "dev-develop-v5 as 5.1.4”,

Then do a composer clear-cache && composer update

@khalwat khalwat closed this as completed Sep 25, 2024
@bryantwells
Copy link
Author

That seems to have done the trick! Will update here if i find otherwise.

I wasn't sure how the Entry was being passed to SEOmatic, either. The thumbnail Matrix is being passed to SEOmatic even though I have explicitly set it to use a custom image.

I was wondering if there might be some logic in the plugin that checks for a thumbnail handle by default, regardless of the panel settings?

@khalwat
Copy link
Collaborator

khalwat commented Sep 26, 2024

Nope, it doesn't look for any hard-coded field handles. Very strange.

In any event, glad to hear it got sorted for you!

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

3 participants