File tree 4 files changed +111
-0
lines changed
4 files changed +111
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ PDO_sqlite: Testing empty filename
3
+ --EXTENSIONS--
4
+ pdo_sqlite
5
+ --FILE--
6
+ <?php
7
+
8
+ // create with empty filename
9
+ $ db = new PDO ('sqlite: ' );
10
+
11
+ var_dump ($ db ->exec ('CREATE TABLE test1 (id INT); ' ));
12
+
13
+ // create with empty URI
14
+ $ db = new PDO ('sqlite:file:?cache=shared ' );
15
+
16
+ var_dump ($ db ->exec ('CREATE TABLE test1 (id INT); ' ));
17
+ ?>
18
+ --EXPECT--
19
+ int(0)
20
+ int(0)
Original file line number Diff line number Diff line change @@ -5,6 +5,16 @@ pdo_sqlite
5
5
--FILE--
6
6
<?php
7
7
8
+ // create with in-memory database using shared cached
9
+ $ db = new PDO ('sqlite:file::memory:?cache=shared ' );
10
+
11
+ var_dump ($ db ->exec ('CREATE TABLE test1 (id INT); ' ));
12
+
13
+ // create second connection to in-memory database
14
+ $ db = new PDO ('sqlite:file::memory:?cache=shared ' );
15
+
16
+ var_dump ($ db ->exec ('SELECT * from test1 ' ));
17
+
8
18
// create with default read-write|create mode
9
19
$ filename = "file: " . __DIR__ . DIRECTORY_SEPARATOR . "pdo_sqlite_filename_uri.db " ;
10
20
@@ -29,6 +39,8 @@ if (file_exists($filename)) {
29
39
?>
30
40
--EXPECTF--
31
41
int(0)
42
+ int(0)
43
+ int(0)
32
44
33
45
Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in %s
34
46
Stack trace:
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ PDO_sqlite: Testing filenames with open_basedir
3
+ --EXTENSIONS--
4
+ pdo_sqlite
5
+ --INI--
6
+ open_basedir=.
7
+ --FILE--
8
+ <?php
9
+
10
+ // create in basedir
11
+ $ filename = 'pdo_sqlite_filename.db ' ;
12
+
13
+ $ db = new PDO ('sqlite: ' . $ filename );
14
+
15
+ var_dump ($ db ->exec ('CREATE TABLE test1 (id INT); ' ));
16
+
17
+ // create outside basedir
18
+ $ filename = '.. ' . DIRECTORY_SEPARATOR . 'pdo_sqlite_filename.db ' ;
19
+
20
+ new PDO ('sqlite: ' . $ filename );
21
+ ?>
22
+
23
+ --CLEAN--
24
+ <?php
25
+ $ filenames = [
26
+ 'pdo_sqlite_filename.db ' ,
27
+ '.. ' . DIRECTORY_SEPARATOR . 'pdo_sqlite_filename.db ' ,
28
+ ];
29
+ foreach ($ filenames as $ filename ) {
30
+ if (file_exists ($ filename )) {
31
+ unlink ($ filename );
32
+ }
33
+ }
34
+ ?>
35
+ --EXPECTF--
36
+ int(0)
37
+
38
+ Fatal error: Uncaught PDOException: PDO::__construct(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s) in %s:%d
39
+ Stack trace:
40
+ %s
41
+ #1 {main}
42
+
43
+ Next PDOException: open_basedir prohibits opening %s in %s:%d
44
+ Stack trace:
45
+ %s
46
+ #1 {main}
47
+ thrown in %s
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ PDO_sqlite: Testing URIs with open_basedir
3
+ --EXTENSIONS--
4
+ pdo_sqlite
5
+ --INI--
6
+ open_basedir={TMP}
7
+ --FILE--
8
+ <?php
9
+
10
+ // create in basedir
11
+ $ filename = sys_get_temp_dir () . DIRECTORY_SEPARATOR . 'pdo_sqlite_filename.db ' ;
12
+
13
+ new PDO ('sqlite:file: ' . $ filename );
14
+ ?>
15
+
16
+ --CLEAN--
17
+ <?php
18
+ $ filenames = [
19
+ sys_get_temp_dir () . DIRECTORY_SEPARATOR . 'pdo_sqlite_filename.db ' ,
20
+ ];
21
+ foreach ($ filenames as $ filename ) {
22
+ if (file_exists ($ filename )) {
23
+ unlink ($ filename );
24
+ }
25
+ }
26
+ ?>
27
+ --EXPECTF--
28
+ Fatal error: Uncaught PDOException: open_basedir prohibits opening %s in %s:%d
29
+ Stack trace:
30
+ %s
31
+ #1 {main}
32
+ thrown in %s
You can’t perform that action at this time.
0 commit comments