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

[4.x]: AssetIndexer::indexFile includes filename into directory #11365

Closed
wsydney76 opened this issue Jun 1, 2022 · 4 comments
Closed

[4.x]: AssetIndexer::indexFile includes filename into directory #11365

wsydney76 opened this issue Jun 1, 2022 · 4 comments

Comments

@wsydney76
Copy link

What happened?

Description

We retrieve images from an external source via Guzzle and indexed them in V3 via

$asset = Craft::$app->assetIndexer->indexFile($volume, 'examples/' );

The Asset Index now looks like this:

image

Source:

 $listing = new FsListing([
            'dirname' => $path,
            'basename' => pathinfo($path, PATHINFO_BASENAME),
            'type' => 'file',
            'dateModified' => $fs->getDateModified($path),
            'fileSize' => $fs->getFileSize($path),
        ]);

Looks like it should be 'dirname' => dirname($path), ?

PS.
The $sessionId is now required, although the doc block says it is optional.

Steps to reproduce

  1. Index a file via AssetIndexer::indexFile

Expected behavior

Index directory matches real life.

Actual behavior

Creates a directory with the filename, which does not exist.

/Mel

Craft CMS version

4.0.3

PHP version

8.0.15

Operating system and version

Windows 10 Pro

Database type and version

MySQL 5.7.14

Image driver and version

Imagick 3.7.0 (ImageMagick 7.1.0-18)

Installed plugins and versions

No response

@brandonkelly
Copy link
Member

Not really sure I’m following the issue. Do you mind submitting a PR with the fix?

@wsydney76
Copy link
Author

@brandonkelly Not familiar with creating PRs, but i think it is just one line:

'dirname' => $path,

Patching this to 'dirname' => dirname($path) fixes the issue for me (local filesystem, if that matters)

And it looks like the comment in line 482 (optional) and the method signature (no default for $sessionId) in line 491 do not match.

/Mel

@brandonkelly
Copy link
Member

Alright thanks! Fixed for the next release.

@brandonkelly
Copy link
Member

Craft 4.0.4 is out now with that fix.

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

No branches or pull requests

2 participants