Skip to content

ApiController::actionSearch() try/catch placement #34

@boehmi1988

Description

@boehmi1988

In ApiController::actionSearch() the try/catch block is placed around code that will not throw an exception ever - the actual Exception coming from $fileSystem->get() is never catched / ignored.

So the search crashes, if there is a FileflyHashmap record which references a file that does not exists

` foreach ($query->all() as $item) {

        // check read permissions or is folder
        if (!$fileSystem->grantAccess($item['path'],
                Filefly::ACCESS_READ) || $fileSystem->get($item['path'])->isDir()) {
            continue;
        }

        try {
            $item['id'] = $item['path'];
            $item['mime'] = '';
            $result[] = $item;
        } catch (FileNotFoundException $e) {
            \Yii::warning($e->getMessage(), __METHOD__);
            continue;
        }
    }`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions