wp_crontrol fails to save with 403 error due to logical operator order

[ad_1]

Hi,

I’ve come across this issue numerous times in the past but not been aware of this support forum to report it.

Problem
The problem appears to be related to the ordering of the “not equal to” comparison operator when bracketed and included in a multi-condition statement. Specifically when the first value in the comparison is a string.

This is the simplified case that I’m currently experiencing. It will induce the 403 error when saving with this simple statement.

if( isset( $item->category ) && ( ” != $item->category ) ) return;

But remove the inner brackets

if( isset( $item->category ) && ” != $item->category ) return;

or change the order of the values

if( isset( $item->category ) && ( $item->category != ” ) ) return;

and all is fine.

I’m sure I’ve seen it in the past in other not quite the same conditions but this is the one I’m able to narrow it down to at the moment.

Are you aware of this behaviour and can you shed any light on why it’s happening?

Background

Historically, it has only on one client site. But these sites are all hosted by the same provider and so have the same php version and have been running the same wp_crontrol. This occurs in multiple versions of wp_crontrol including 1.14.0 which is what I’m dealing with now. Also, across multiple WP and WC versions.

We only had one site experiencing the issue and I’d always have to test/rework whether any script updates would save correctly for that one client, but now experiencing it on another.

I’ve just come across it again today while trying to save an updated cron script through wp_crontrol. This script has had significant “beautification” in the last update and so I’m not looking forward to having to rip it apart and revert…

In essence, when saving the script, a 403 forbidden error is thrown up. No reason is given for the failure and no write to debug.

The script compiles just fine in dev and our plugin itself, with the same syntax included, also works without issue on the site.

Cheers

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer