• Resolved nesdon

    (@nesdon)


    I’ve gotten reports from customers unable to check out, reporting this message:
    “Error found in: /home/localcarbon/public_html/wp-content/plugins/woocommerce/includes/libraries/class-wc-eval-math.php, nfx, 123
    Warning: illegal character ‘[‘ in /home/localcarbon/public_html/wp-content/plugins/woocommerce/includes/libraries/class-wc-eval-math.php on line 321”

    When reported, I’ve gone to the site and made test orders that went through smoothly, and dismissed the complaint. But as it has kept happening, I’ve tried using different browsers and email addresses, and eventually, messing around changing the shipping address and other data, I can get it to error the same way, showing that code 3 times in three rows.

    Sometimes, it will keep the CC dialog area greyed out, and while this has seemed to happen only when the “use a different shipping address” box is checked, I haven’t been able to clearly identify what triggers these two error states.

    Here is faulty action in that class-eval-math.php file:

    /**
    * Evaluate postfix notation.
    *
    * @param mixed $tokens
    * @param array $vars
    *
    * @return mixed
    */
    private static function pfx( $tokens, $vars = array() ) {
    if ( false == $tokens ) {
    return false;
    }
    $stack = new WC_Eval_Math_Stack;

    foreach ( $tokens as $token ) { // nice and easy
    // if the token is a binary operator, pop two values off the stack, do the operation, and push the result back on
    if ( in_array( $token, array( ‘+’, ‘-‘, ‘*’, ‘/’, ‘^’ ) ) ) {
    if ( is_null( $op2 = $stack->pop() ) ) {
    return self::trigger( “internal error” );
    }
    if ( is_null( $op1 = $stack->pop() ) ) {
    return self::trigger( “internal error” );
    }
    switch ( $token ) {
    case ‘+’:
    $stack->push( $op1 + $op2 );
    break;
    case ‘-‘:
    $stack->push( $op1 – $op2 );
    break;
    case ‘*’:
    $stack->push( $op1 * $op2 );
    break;
    case ‘/’:
    if ( 0 == $op2 ) {
    return self::trigger( ‘division by zero’ );
    }
    $stack->push( $op1 / $op2 );
    break;
    case ‘^’:
    $stack->push( pow( $op1, $op2 ) );
    break;
    }
    // if the token is a unary operator, pop one value off the stack, do the operation, and push it back on
    } elseif ( ‘_’ === $token ) {
    $stack->push( -1 * $stack->pop() );
    // if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on
    } elseif ( ! preg_match( “/^([a-z]\w*)\($/”, $token, $matches ) ) {
    if ( is_numeric( $token ) ) {
    $stack->push( $token );
    } elseif ( array_key_exists( $token, self::$v ) ) {
    $stack->push( self::$v[ $token ] );
    } elseif ( array_key_exists( $token, $vars ) ) {
    $stack->push( $vars[ $token ] );
    } else {
    return self::trigger( “undefined variable ‘$token'” );
    }
    }
    }
    // when we’re out of tokens, the stack should have a single element, the final result
    if ( 1 != $stack->count ) {
    return self::trigger( “internal error” );
    }
    return $stack->pop();
    }

    /**
    * Trigger an error, but nicely, if need be.
    *
    * @param string $msg
    *
    * @return bool
    */
    private static function trigger( $msg ) {
    self::$last_error = $msg;
    if ( defined( ‘WP_DEBUG’ ) && WP_DEBUG ) {
    echo “\nError found in:”;
    self::debugPrintCallingFunction();
    trigger_error( $msg, E_USER_WARNING );
    }
    return false;
    }

    line 321 referred to in the error is the last: “trigger_error( $msg, E_USERWARNING )”

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • con

    (@conschneider)

    Engineer

    Hi there,

    An intermittent error that is coupled with errors from WooCommerce core files points to a weak server / shared hosting plan. Every time there are too many server resources in use (by you or another customer on your shared hosting plan) your site gets interrupted. It happens randomly because there is no consistent activity pattern among the sites that share the server with you.

    I recommend to upgrade your hosting plan and move away from shared hosting.

    Thread Starter nesdon

    (@nesdon)

    Thanks, Con.

    I’ve found if I use an incognito or private window in my browser it works as it should (at least with half a dozen tests). It also always works correctly when I am logged in to my administrator acct.

    Is there a reason why an overwhelmed server would only error when handling IDs?

    One repeatable fault I can find (when it is not throwing that eval error) is that it dims out the order summary and CC entry dialog when I uncheck the ship to a different address checkbox, but this too only in a non-incognito window.

    con

    (@conschneider)

    Engineer

    Hi again,

    It is good practice to test a couple of times with Google Chrome Incognito window, so 👍.

    The good news is that your site and setup are probably sound since you are unable to reproduce. I think your problem is more backend than front end in a sense that your site / server has trouble processing requests.

    The dimming of your checkout is probably Javascript that is a bit bulky and has trouble rendering the forms quickly. So this is front end only (I think).

    What you can also try is check your error logs.
    WooCommerce attempts to log any fatal errors. You can find these under WooCommerce > Status >> Logs (click on the tab). After clicking on the logs tab examine the dropdown on the right for any “fatal-errors” entry.

    Additionally you can also reset all sessions in your WooCommerce. Navigate to /wp-admin/admin.php?page=wc-status&tab=tools and look for: “Clear customer sessions”

    Kind regards,

    Thread Starter nesdon

    (@nesdon)

    Woo support helped me find the error. Looks like we had some stray asterix in some of the flat rate shipping costs so that the intermittency was being caused by whether the state or zip code entered directed it to one of the shipping zones with the illegal *. I hope I found it all, thanks for the help!

    laceyrod

    (@laceyrod)

    Automattic Happiness Engineer

    Hi there,

    Thanks for the update! I’m glad that you were able to find a culprit 🙂

    I’m going to mark this thread as Resolved now. Please feel free to open a new one if you have any further questions.

    Cheers!

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

The topic ‘intermittent error: illegal char. in class-wc-eval-math.php’ is closed to new replies.