Skip to content

“Only run once” snippets runs on save #227

Open
@lightbulbman

Description

@lightbulbman

Current behavior

When creating a run-once snippet, it runs on every save, despite the fact the I just click the “save changes” button(!)

I test with a simple snippet like:

error_log("Test!!");
I make a change and hit execute. This saves and runs the snippet as expected.

Then I make another change eg error_log("Test 2!"); and only hit “Save Changes”. But in the logs I see the new message Test 2! that have never run before. That means that the snippet ran, even though the user just clicked save.

Please note that this happens only after the the snippet is saved and the run once was deliberately used at least once

Expected behavior

When saving a run-once snippet then the snippet should not run and only run when the save and execute button or execute once button is pressed

Steps to reproduce

  1. Create a php snippet and add some code like above
  2. Select Run Once and save - check code has run
  3. Make changes and click save - code will have run again

WordPress version

6.7.2

Code Snippets version

3.6.8

Code Snippets license

Core (free)

Anything else?

Link to WP.org original report: https://wordpress.org/support/topic/only-run-once-snippets-runs-on-save/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions