Skip to content

Commit 23c359c

Browse files
committed
Merge branch 'PHP-5.6' into PHP-7.0
# Resolved conflicts: # ext/sqlite3/sqlite3.c
2 parents 0d2c4f8 + cc125f2 commit 23c359c

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ PHP NEWS
7878
. Fixed bug #72668 (Spurious warning when exception is thrown in user defined
7979
function). (Laruence)
8080
. Fixed bug #72571 (SQLite3::bindValue, SQLite3::bindParam crash). (Laruence)
81+
. Implemented FR #72653 (SQLite should allow opening with empty filename).
82+
(cmb)
8183

8284
- Standard:
8385
. Fixed bug #72622 (array_walk + array_replace_recursive create references

ext/sqlite3/sqlite3.c

+7-8
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,11 @@ PHP_METHOD(sqlite3, open)
112112

113113
if (db_obj->initialised) {
114114
zend_throw_exception(zend_ce_exception, "Already initialised DB Object", 0);
115-
}
116-
117-
if (strlen(filename) != filename_len) {
118115
return;
119116
}
120-
if (filename_len != sizeof(":memory:")-1 ||
121-
memcmp(filename, ":memory:", sizeof(":memory:")-1) != 0) {
117+
118+
if (filename_len != 0 && (filename_len != sizeof(":memory:")-1 ||
119+
memcmp(filename, ":memory:", sizeof(":memory:")-1) != 0)) {
122120
if (!(fullpath = expand_filepath(filename, NULL))) {
123121
zend_throw_exception(zend_ce_exception, "Unable to expand filepath", 0);
124122
return;
@@ -138,7 +136,8 @@ PHP_METHOD(sqlite3, open)
138136
return;
139137
}
140138
} else {
141-
fullpath = estrdup(filename);
139+
/* filename equals "" or ":memory:" */
140+
fullpath = filename;
142141
}
143142

144143
#if SQLITE_VERSION_NUMBER >= 3005000
@@ -147,7 +146,7 @@ PHP_METHOD(sqlite3, open)
147146
if (sqlite3_open(fullpath, &(db_obj->db)) != SQLITE_OK) {
148147
#endif
149148
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to open database: %s", sqlite3_errmsg(db_obj->db));
150-
if (fullpath) {
149+
if (fullpath != filename) {
151150
efree(fullpath);
152151
}
153152
return;
@@ -172,7 +171,7 @@ PHP_METHOD(sqlite3, open)
172171
sqlite3_set_authorizer(db_obj->db, php_sqlite3_authorizer, NULL);
173172
}
174173

175-
if (fullpath) {
174+
if (fullpath != filename) {
176175
efree(fullpath);
177176
}
178177
}

ext/sqlite3/tests/sqlite3_open_empty_string.phpt

+2-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@ Thijs Feryn <[email protected]>
77
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
88
--FILE--
99
<?php
10-
try{
11-
$db = new SQLite3('');
12-
} catch(Exception $e) {
13-
echo $e->getMessage().PHP_EOL;
14-
}
10+
$db = new SQLite3('');
1511
echo "Done\n";
1612
?>
17-
--EXPECTF--
18-
Unable to expand filepath
13+
--EXPECT--
1914
Done

0 commit comments

Comments
 (0)