intermittent error: illegal char. in class-wc-eval-math.php
-
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]
The topic ‘intermittent error: illegal char. in class-wc-eval-math.php’ is closed to new replies.