2017-02-24 06:40:51 +01:00
|
|
|
--TEST--
|
2017-10-04 23:22:56 +02:00
|
|
|
Free statement twice
|
2017-02-24 06:40:51 +01:00
|
|
|
--FILE--
|
|
|
|
<?php
|
2017-10-04 23:22:56 +02:00
|
|
|
require_once('MsCommon.inc');
|
2020-07-09 04:45:00 +02:00
|
|
|
set_error_handler("warningHandler", E_WARNING);
|
|
|
|
|
|
|
|
// When testing with PHP 8.0 it throws a TypeError instead of a warning. Thus implement a custom
|
|
|
|
// warning handler such that with PHP 7.x the warning would be handled to throw a TypeError.
|
|
|
|
function warningHandler($errno, $errstr)
|
|
|
|
{
|
|
|
|
throw new TypeError($errstr);
|
|
|
|
}
|
2017-02-24 06:40:51 +01:00
|
|
|
|
|
|
|
function CloseTwice()
|
2017-10-04 23:22:56 +02:00
|
|
|
{
|
|
|
|
set_time_limit(0);
|
|
|
|
sqlsrv_configure('WarningsReturnAsErrors', 1);
|
2017-02-24 06:40:51 +01:00
|
|
|
|
|
|
|
// Connect
|
2017-10-04 23:22:56 +02:00
|
|
|
$conn = connect();
|
|
|
|
if (!$conn) {
|
|
|
|
fatalError("Could not connect.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
$tableName = GetTempTableName();
|
|
|
|
|
|
|
|
$stmt = sqlsrv_query($conn, "CREATE TABLE $tableName ([c1_int] int, [c2_tinyint] tinyint)");
|
|
|
|
sqlsrv_free_stmt($stmt);
|
|
|
|
|
|
|
|
$stmt = sqlsrv_query($conn, "SELECT * FROM $tableName");
|
|
|
|
sqlsrv_free_stmt($stmt);
|
|
|
|
sqlsrv_free_stmt($stmt);
|
|
|
|
sqlsrv_close($conn);
|
2017-02-24 06:40:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// Repro
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
function Repro()
|
|
|
|
{
|
2017-10-04 23:22:56 +02:00
|
|
|
startTest("sqlsrv_close_twice");
|
|
|
|
try {
|
2017-02-24 06:40:51 +01:00
|
|
|
CloseTwice();
|
2020-07-09 04:45:00 +02:00
|
|
|
} catch (TypeError $e) {
|
|
|
|
echo $e->getMessage() . PHP_EOL;
|
2017-10-04 23:22:56 +02:00
|
|
|
} catch (Exception $e) {
|
2020-07-09 04:45:00 +02:00
|
|
|
echo $e->getMessage() . PHP_EOL;
|
2017-02-24 06:40:51 +01:00
|
|
|
}
|
|
|
|
echo "\nDone\n";
|
2017-10-04 23:22:56 +02:00
|
|
|
endTest("sqlsrv_close_twice");
|
2017-02-24 06:40:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Repro();
|
|
|
|
|
|
|
|
?>
|
2020-07-09 04:45:00 +02:00
|
|
|
--EXPECT--
|
|
|
|
sqlsrv_free_stmt(): supplied resource is not a valid ss_sqlsrv_stmt resource
|
2017-02-24 06:40:51 +01:00
|
|
|
|
|
|
|
Done
|
2017-05-02 02:01:30 +02:00
|
|
|
Test "sqlsrv_close_twice" completed successfully.
|