Skip to content

Commit 13d75d1

Browse files
committed
Fixed issue with mysqli::ping being deprecated since PHP 8.4
1 parent c1ff432 commit 13d75d1

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tests/ElasticApmTests/ComponentTests/MySQLiAutoInstrumentationTest.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ public function testPrerequisitesSatisfied(): void
134134
AmbientContextForTests::testConfig()->mysqlDb
135135
);
136136
self::assertNotNull($mySQLi);
137-
self::assertTrue($mySQLi->ping());
137+
// Method mysqli::ping() is deprecated since PHP 8.4
138+
if (PHP_VERSION_ID < 80400) {
139+
self::assertTrue($mySQLi->ping());
140+
}
138141
}
139142

140143
public function testIsAutoInstrumentationEnabled(): void
@@ -351,7 +354,11 @@ public static function appCodeForTestAutoInstrumentation(MixedMap $appCodeArgs):
351354
$mySQLiApiFacade = new ApiFacade($isOOPApi);
352355
$mySQLi = $mySQLiApiFacade->connect($host, $port, $user, $password, $connectDbName);
353356
self::assertNotNull($mySQLi);
354-
self::assertTrue($mySQLi->ping());
357+
358+
// Method mysqli::ping() is deprecated since PHP 8.4
359+
if (PHP_VERSION_ID < 80400) {
360+
self::assertTrue($mySQLi->ping());
361+
}
355362

356363
if ($connectDbName !== $workDbName) {
357364
self::assertTrue($mySQLi->query(self::CREATE_DATABASE_IF_NOT_EXISTS_SQL_PREFIX . $workDbName));
@@ -447,7 +454,11 @@ private function implTestAutoInstrumentation(MixedMap $testArgs): void
447454
$expectedSpans = [];
448455
if ($isInstrumentationEnabled) {
449456
$expectedSpans[] = $expectationsBuilder->fromNames('mysqli', '__construct', 'mysqli_connect');
450-
$expectedSpans[] = $expectationsBuilder->fromNames('mysqli', 'ping');
457+
458+
// Method mysqli::ping() is deprecated since PHP 8.4
459+
if (PHP_VERSION_ID < 80400) {
460+
$expectedSpans[] = $expectationsBuilder->fromNames('mysqli', 'ping');
461+
}
451462

452463
if ($connectDbName !== $workDbName) {
453464
$expectedSpans[] = $expectationsBuilder->fromStatement(self::CREATE_DATABASE_IF_NOT_EXISTS_SQL_PREFIX . $workDbName);

0 commit comments

Comments
 (0)