Skip to content

fix: stop file-based execution after snippet deactivation - #562

Open
robertstaddon wants to merge 3 commits into
codesnippetspro:core-betafrom
robertstaddon:fix/file-based-deactivate-index/core
Open

robertstaddon wants to merge 3 commits into
codesnippetspro:core-betafrom
robertstaddon:fix/file-based-deactivate-index/core

Conversation

@robertstaddon

Copy link
Copy Markdown

Fixes #561

Changes

  • Flush the snippet object cache before get_snippet() in deactivate_snippet(), and set the snippet inactive before the file-based deactivate hook runs.
  • Force $snippet->active = false in Snippet_Files::deactivate_snippet() so a stale cached object cannot be written into index.php as still active.
  • Replace each type’s on-disk index with the currently active set when file-based files are rebuilt, instead of merging into leftover entries.

Verification

  • Confirmed the same deactivate_snippet() order is still present on core-beta.
  • Applied the same edits on a Code Snippets Pro 3.10.2 site with file-based execution enabled. After deactivating a global PHP snippet that printed a footer marker, the marker was gone on the front end and php/index.php recorded the snippet as inactive. Rebuilding the files did not mark it active again.

Made with Cursor

Flush the snippet object cache before writing the on-disk index, force the snippet inactive, and replace indexes on rebuild so a deactivated snippet cannot stay marked active.

Fixes codesnippetspro#561

Co-authored-by: Cursor <cursoragent@cursor.com>
@ramiy

ramiy commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Ideally, I would initially add a test that check file-based execution for deactivated snippets. The test should fail.

In a separate PR, which fixes the issue, the test should no longer fail.

@robertstaddon

Copy link
Copy Markdown
Author

Thank you!

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.

File-based execution keeps running snippets after they are deactivated

2 participants