Support » Plugin: Code Snippets » Code Snippet and missing priority check

  • Resolved tapiohuuhaa

    (@tapiohuuhaa)


    My site went broken, when I changed to use as condition
    if(tap_is_mobile(){…}

    The function tap_is_mobile was defined in another Code Snippet. Both had the same priority. The site crashed.

    When I set the priority of the snippet, which calls the snipped, bigger than in the another snippet, site worked again.

    CodeSnippet checks that the PHP is valid and it checks if the function exists, but it doesn’t check if the function is available, when the page is created. If pririoty is wrong, site might crash. There should be also priority check.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    It’s probably a good idea to implement a check that the required functions exist in the snippets themselves. Changing your line to:

    if ( function_exists( 'tap_is_mobile' ) && tap_is_mobile() ) { … }

    would fix this problem.

    Checking each function before running the snippet would cause a drain on page load times, which I would like to avoid.

    Thread Starter tapiohuuhaa

    (@tapiohuuhaa)

    I don’t mean that in running the live page, there would be check but after each editing, there could be priority check, when you save the snippet.

    When saving a snippet, Code Snippet checks that the syntax is ok and functions exists. But because it doesn’t check when saving the snippet, if it has valid priority.

    I saved a snippet. Syntax was ok and a function exist. But site crashed. I took me some time in order to figure, why the site crashed.

    Plugin Author Shea Bunge

    (@bungeshea)

    It looks like we have a second thread on this same issue, so I might mark this one as resolved so we can continue our discussion in a centralised place: https://wordpress.org/support/topic/priority-checking-error/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Code Snippet and missing priority check’ is closed to new replies.