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

BUGFIX: Prevent flush force error in production context #2716

Merged

Conversation

gjwnc
Copy link
Contributor

@gjwnc gjwnc commented Feb 28, 2022

What I did

The flow:cache:flush --force command runs Files::emptyDirectoryRecursively($environment->getPathToTemporaryDirectory()); which removes the lock file in the temporary directory too. The call to unlockSite() then causes a PHP warning because of the missing lock file.

Warning: unlink(/…/cbe856ff790c9ba5208811309bdf168b_Flow.lock): No such file or directory in /…/Core/LockManager.php line 145

This PR just add's a bit of error handling to the corresponding unlink of the lock file.

How to verify it

Run ./flow flow:cache:flush --force command in Production context.

Question

Since this is a bugfix, I used branch 6.3. In case of Flow 7, some PHP 8 compatiblity was added which would change the PR to

            try {
                @unlink($this->lockPathAndFilename);
            } catch (\Throwable $e) {
                // PHP 8 apparently throws for unlink even with shutup operator, but we really don't care at this place. It's also the only way to handle this race-condition free.
            }

Should I create another PR if this one is merged to get PHP 8 compatibility?

Checklist

  • Code follows the PSR-2 coding style
  • Tests have been created, run and adjusted as needed
  • The PR is created against the lowest maintained branch

Copy link
Member

@albe albe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I create another PR if this one is merged to get PHP 8 compatibility?

Yes, that would be the way to go.

@albe albe changed the title Bugfix: Prevent flush force error in production context BUGFIX: Prevent flush force error in production context Mar 25, 2022
@albe albe requested review from fcool, kdambekalns and kitsunet March 25, 2022 12:21
Copy link
Member

@kdambekalns kdambekalns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bah, the shut-up operator… But I checked, and despite not wanting to use it, we do use it in 30 places within our actual code. So, let's add one more. ;)

@kdambekalns kdambekalns merged commit 47764c6 into neos:6.3 Mar 25, 2022
@kdambekalns
Copy link
Member

Ignored the Psalm error, as they are clearly unrelated.

@gjwnc
Copy link
Contributor Author

gjwnc commented Mar 29, 2022

@albe @kdambekalns I've created a new PR regarding PHP 8 compatiblity - see #2795

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

Successfully merging this pull request may close these issues.

3 participants