Manticore 4.2.0 is bugging out when attemtting to connect through PHP.

Manticore 4.2.0 is bugging out when attempting to connect through PHP. It returns the error “Fatal error: Uncaught PDOException: SQLSTATE[08S01]: Communication link failure: 1047 unknown command (code=22)”.
My code works perfectly OK with Manticore versions 3.5.2, 3.5.4, 3.6.0, 4.0.2, but whenever I switch to version 4.2.0 I get this bug.
I can run the Manticore statement by logging into the server manually and that works fine in 4.2.0, but the same statement in PHP bugs out.
The error occurs either on prepare or execute and seems to connect to the Manticore server without issue.

Here’s my code:

$man_opt = [
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, // terminates script
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    PDO::ATTR_EMULATE_PREPARES   => false,
          ];

try {

 $man_conn = new PDO('mysql:host=127.0.0.1;port=9306;charset=utf8mb4', null, null, $man_opt);

} catch (PDOException $e) {

 $error_message = $e->getMessage();
 // send email and log the error
 manticore_error_email_log($error_message);
}

$man_query = 'SELECT country, city, country_code, latitude, longitude, INTEGER((WEIGHT()*120)+(population)) AS myorder FROM geolocations WHERE MATCH(:query) ORDER BY myorder DESC limit 1 OPTION field_weights=(country=10, state=9, county=9, city=9, state_code=9), ranker=expr(\'(sum(lcs*user_weight)*1000+bm25) * IF(country = "united states" OR country = "united kingdom", 1.25, 1)\')';

$man_stmt = $man_conn->prepare($man_query);

$man_stmt->execute(['query' => '@(country,state,county,city,state_code) "^' . $location . '$"/0.75']);

$geocode_data = $man_stmt->fetch();

As mentioned above, if I run the same statement directly inside Manticore 4.2.0 it works e.g

SELECT country, city, country_code, latitude, longitude, INTEGER((WEIGHT()*120)+(population)) 
AS myorder FROM geolocations WHERE MATCH('@(country,state,county,city,state_code) "^Grimsby$"/0.75') ORDER BY myorder DESC limit 1 OPTION field_weights=(country=10, state=9, county=9, city=9, state_code=9), ranker=expr('(sum(lcs*user_weight)*1000+bm25) * IF(country = "united states" OR country = "united kingdom", 1.25, 1)');

Hi. Manticore never supported server-side prepared statements. Please try

 $man_conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);

I reproduced the issue and am not sure why the lack of this didn’t generate a warning in < 4.2.0 (since as I said server-side prepared statements were never supported). Anyway I appreciate you’ve pointed this out. I’ll check with the team on this and we’ll probably update the changelog stating it’s a breaking change. Please let me know if the above workaround works for you.

1 Like

Thanks, that did the trick. 4.2.0 now works with no issues.