• Resolved howto123

    (@howto123)


    Recently this plugin started showing this error for random snippets:

    Cannot use temporary expression in write context

    The error occurred on line 17 of this snippet’s code (highlighted below).

    Please note that it is always the same “…on line 17” error, it doesn’t have anything to do with the context of the code, it will show “on line 17” even if there are fewer than 17 lines.

    A good sign that this is being shown incorrectly is that it shown for the “Completely Disable Comments” snippet offered by the plugin.

    WP code version: 2.1.12 
    WordPress version: 6.5.3
    php version: 8.2.16

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mircea Sandu

    (@gripgrip)

    Hi @howto123,

    I’m sorry you ran into that issue, it can happen for certain errors that we are unable to catch correctly due to the way PHP interprets the code.

    This is likely happening due to another active snippet and from the error message you are likely missing the $ sign in front of a variable. So instead of $var you have var.

    Since it’s always on line 17, you likely need to look at one of the older snippets that you added on the site as those will get loaded earlier. You can filter by active snippets only and then order them by the date when they were added (you can enable that in Screen Options if not available).

    Thread Starter howto123

    (@howto123)

    Hey @gripgrip,

    It was indeed a missing $ sign, but every snippet getting disabled caught me off guard.

    Thanks for the quick reply!

    I suggest adding it as a separate pro-tip under https://wpcode.com/categories/docs/troubleshooting/.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Most snippets fail with “Cannot use temporary expression in write context”’ is closed to new replies.