Skip to content

Invalidate file cache upon copying folders#74

Merged
Hackwar merged 1 commit intojoomla-framework:3.x-devfrom
janschoenherr:patch-1
Jul 11, 2025
Merged

Invalidate file cache upon copying folders#74
Hackwar merged 1 commit intojoomla-framework:3.x-devfrom
janschoenherr:patch-1

Conversation

@janschoenherr
Copy link
Copy Markdown
Contributor

@Llewellynvdm
Copy link
Copy Markdown

Llewellynvdm commented Jan 29, 2025

Can we make this behavior optional? Instead of always performing this action, we could introduce an alternative method or an additional argument in the copy method to allow developers to enable or disable it as needed.

@janschoenherr
Copy link
Copy Markdown
Contributor Author

janschoenherr commented Jan 30, 2025

@Llewellynvdm WordPress seems to be doing that. They have a separate function move_dir() which does the invalidation, while the base filesystem does not.

For me it's just a concern, that the Installer Adapters in Joomla do not seem to invalidate the opcache after copying the files through Folder::move().

@richard67
Copy link
Copy Markdown
Contributor

Maybe an alternative would be just to use the File::copy method, i.e. instead of

                case 'file':
                    if ($useStreams) {
                        Stream::getStream()->copy($sfid, $dfid);
                    } else {
                        if (!@copy($sfid, $dfid)) {
                            throw new FilesystemException('Copy file failed', -1);
                        }
                        File::invalidateFileCache($dfid);
                    }

                    break;

use

                case 'file':
                    if (File::copy($sfid, $dfid, null, $useStreams) !== true) {
                        // File::copy throws an error
                        return false;
                    }

                    break;

We do similar already in the Folder::delete method where we call File::delete.

File::copy does also include the opcache invalidation, in opposite to this PR here also for the case if stream is used.

@janschoenherr
Copy link
Copy Markdown
Contributor Author

Thanks, I updated the PR. I wouldn't call File::copy, because it would cause quite a bit of overhead.

@Hackwar Hackwar merged commit ef00d74 into joomla-framework:3.x-dev Jul 11, 2025
2 checks passed
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.

4 participants