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

TypeError in Assets::getFileKindByExtension() #2764

Closed
ostark opened this issue Apr 18, 2018 · 0 comments
Closed

TypeError in Assets::getFileKindByExtension() #2764

ostark opened this issue Apr 18, 2018 · 0 comments

Comments

@ostark
Copy link
Contributor

ostark commented Apr 18, 2018

Description

After saving an image (Asset editor / HUD) I get a TypeError.

[error][TypeError] TypeError: Argument 1 passed to craft\helpers\Assets::getFileKindByExtension() must be of the type string, null given, called in /Users/os/Projects/Craft/demo/vendor/craftcms/cms/src/elements/Asset.php on line 1215 and defined in /Users/os/Projects/Craft/demo/vendor/craftcms/cms/src/helpers/Assets.php

cms/src/elements/Asset.php

Lines 1214 to 1217 in 5b93c5e

if (!$this->propagating) {
if (AssetsHelper::getFileKindByExtension($this->tempFilePath) === static::KIND_IMAGE &&
\in_array($this->getScenario(), [self::SCENARIO_REPLACE, self::SCENARIO_CREATE], true) &&
null !== $this->tempFilePath) {

Changing the order of the conditions should fix it.

if (null !== $this->tempFilePath && AssetsHelper::getFileKindByExtension($this->tempFilePath) === static::KIND_IMAGE && 
                 \in_array($this->getScenario(), [self::SCENARIO_REPLACE, self::SCENARIO_CREATE], true) )

Additional info

  • Craft version: 3.0.3
  • PHP version: 7.1
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

1 participant