sqlite3_40_setauthorizer.phpt · GitHub

Original file line numberDiff line numberDiff line change

@@ -117,6 +117,11 @@ PHP 8.3 UPGRADE NOTES

117117

. The ZipArchive::FL_RECOMPRESS constant is deprecated and will be removed

118118

in a future version of libzip

119119
120+

- SQLite3

121+

. Using exceptions is now preferred, warnings will be removed in the future.

122+

Calling SQLite3::enableExceptions(false) will trigger a depreciation warning

123+

in this version.

124+
120125

========================================

121126

5. Changed Functions

122127

========================================

@@ -262,6 +267,12 @@ PHP 8.3 UPGRADE NOTES

262267

9. Other Changes to Extensions

263268

========================================

264269
270+

- SQLite3

271+

. The SQLite3 class now throws \SQLite3Exception (extends \Exception) instead

272+

of \Exception.

273+

. The SQLite error code is now passed in the exception error code instead of being

274+

included in the error message.

275+
265276

========================================

266277

10. New Global Constants

267278

========================================

Original file line numberDiff line numberDiff line change

@@ -68,6 +68,13 @@

6868

const SQLITE3_DETERMINISTIC = UNKNOWN;

6969

#endif

7070
71+

/**

72+

* @strict-properties

73+

*/

74+

class SQLite3Exception extends \Exception

75+

{

76+

}

77+
7178

/** @not-serializable */

7279

class SQLite3

7380

{

Original file line numberDiff line numberDiff line change

@@ -18,7 +18,7 @@ echo "Error Msg: " . $db->lastErrorMsg() . "\n";

1818

--EXPECTF--

1919

SELECTING from invalid table

2020
21-

Warning: SQLite3::query(): Unable to prepare statement: 1, no such table: non_existent_table in %sbug69972.php on line %d

21+

Warning: SQLite3::query(): Unable to prepare statement: no such table: non_existent_table in %sbug69972.php on line %d

2222

Closing database

2323

bool(true)

2424

Done

Original file line numberDiff line numberDiff line change

@@ -17,10 +17,10 @@ try {

1717

$st->bindValue("a", ":memory:");

1818

$st->execute();

1919

var_dump($db->exec('create table db2.r (id int)'));

20-

} catch (Exception $ex) {

20+

} catch (SQLite3Exception $ex) {

2121

echo $ex->getMessage(), PHP_EOL;

2222

}

2323

?>

2424

--EXPECT--

2525

bool(true)

26-

Unable to prepare statement: 23, not authorized

26+

Unable to prepare statement: not authorized

Original file line numberDiff line numberDiff line change

@@ -20,7 +20,7 @@ echo "Done\n";

2020

--EXPECTF--

2121

SELECTING from invalid table

2222
23-

Warning: SQLite3::query(): Unable to prepare statement: 1, no such table: non_existent_table in %s on line %d

23+

Warning: SQLite3::query(): Unable to prepare statement: no such table: non_existent_table in %s on line %d

2424

Error Code: 1

2525

Error Msg: no such table: non_existent_table

2626

Closing database

Original file line numberDiff line numberDiff line change

@@ -20,10 +20,10 @@ $db = new SQLite3(':memory:');

2020
2121

try {

2222

$db->loadExtension("");

23-

} catch (Extension $ex) {

23+

} catch (\Throwable $ex) {

2424

var_dump($ex->getMessage());

2525

}

2626
2727

?>

2828

--EXPECTF--

29-

Warning: SQLite3::loadExtension(): Empty string as an extension in %s on line %d

29+

string(61) "SQLite3::loadExtension(): Argument #1 ($name) cannot be empty"

Original file line numberDiff line numberDiff line change

@@ -24,4 +24,4 @@ try {

2424
2525

?>

2626

--EXPECTF--

27-

Warning: SQLite3::loadExtension(): SQLite Extension are disabled in %s on line %d

27+

Warning: SQLite3::loadExtension(): SQLite Extensions are disabled in %s on line %d

Original file line numberDiff line numberDiff line change

@@ -71,7 +71,7 @@ try {

7171

?>

7272

--EXPECT--

7373

int(1)

74-

Unable to prepare statement: 23, not authorized

74+

Unable to prepare statement: not authorized

7575

bool(true)

7676

int(42)

7777

string(6) "SELECT"

@@ -98,7 +98,7 @@ string(28) "sqlite_master,rootpage,main,"

9898

string(4) "READ"

9999

string(28) "sqlite_master,rootpage,main,"

100100

bool(true)

101-

Unable to prepare statement: 23, not authorized

101+

Unable to prepare statement: not authorized

102102

The authorizer callback returned an invalid type: expected int

103-

Unable to prepare statement: 23, not authorized

104-

The authorizer callback returned an invalid value

103+

Unable to prepare statement: not authorized

104+

The authorizer callback returned an invalid value: 4200

Read the original on github.com ↗