Skip to content

Cron captcha_delete_expired_images not working after Magento 2.4.8 update. #40192

@gimanik

Description

@gimanik

Preconditions and environment

  • Magento 2.4.8-p1 +

Steps to reproduce

Captcha files are not deleted anymore after update to Magento 2.4.8-p1 causing folder /media/captcha/base to grow over time.
(It IS still reproducible on 2.4-develop)
This commit runed it:
ab0fb9d
Issue is here:
Magento\Captcha\Cron\DeleteExpiredImages::_deleteExpiredImagesForWebsite

if ($this->_mediaDirectory->isFile($filePath)
    && $this->_fileInfo->getPathInfo($filePath, PATHINFO_EXTENSION) == 'png'
    && $this->_mediaDirectory->stat($filePath)['mtime'] < $expire
) {
    $this->_mediaDirectory->delete($filePath);
}

this is never gonna be true, because of condition:
$this->_fileInfo->getPathInfo($filePath, PATHINFO_EXTENSION) == 'png'
method getPathInfo always returns array, so comparsion to string "png" will always result in false.
@see Magento\Framework\Filesystem\Io\File::getPathInfo

public function getPathInfo($path)
{
    return pathinfo($path);
}

To fix it we should add another optional param to getPathInfo or change condition:

$this->_fileInfo->getPathInfo($filePath, PATHINFO_EXTENSION) == 'png'

to:

$this->_fileInfo->getPathInfo($filePath)['extension'] == 'png'

or bring back as it used to be before commit mentioned above (ab0fb9d):

pathinfo($filePath, PATHINFO_EXTENSION) == 'png'

Expected result

Captcha files are deleted by CRON captcha_delete_expired_images

Actual result

Captcha files are not deleted by captcha_delete_expired_images CRON

Additional information

No response

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: AccountComponent: CronIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Reported on 2.4.8-p1Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

    Type

    No type

    Projects

    Status

    Ready for Development

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions