-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Implemented request #64810 (impossible to load extension via pdo_sqlite) #3368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f4295ab
Initial code to implement PDO::sqliteLoadExtension
cwt137 c0a294f
Fixed unit tests and compilation error
cwt137 4cdba49
More compilation fixes
cwt137 fd97d00
Merge branch 'master' into pdo_sqlite-loadExtension
cwt137 cfc704e
Merge branch 'master' into pdo_sqlite-loadExtension
cwt137 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ ARG_WITH("pdo-sqlite", "for pdo_sqlite support", "no"); | |
|
||
if (PHP_PDO_SQLITE != "no") { | ||
if (SETUP_SQLITE3("pdo_sqlite", PHP_PDO_SQLITE, PHP_PDO_SQLITE_SHARED)) { | ||
ADD_FLAG('CFLAGS_PDO_SQLITE', "/D SQLITE_THREADSAFE=" + (PHP_ZTS == "yes" ? "1" : "0") + " "); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I understand the purpose of this change. As we no longer bundle libsqlite3 nowadays, does this even have an effect? |
||
EXTENSION("pdo_sqlite", "pdo_sqlite.c sqlite_driver.c sqlite_statement.c"); | ||
|
||
ADD_EXTENSION_DEP('pdo_sqlite', 'pdo'); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--TEST-- | ||
PDO_sqlite: Testing sqliteLoadExtension() | ||
--SKIPIF-- | ||
<?php | ||
<?php if (!extension_loaded('pdo_sqlite')) print 'skip not loaded'; ?> | ||
?> | ||
--INI-- | ||
open_basedir=. | ||
pdo_sqlite.extension_dir=. | ||
--FILE-- | ||
<?php | ||
|
||
$db = new pdo('sqlite::memory:'); | ||
|
||
$directory = __DIR__; | ||
|
||
touch($directory . '/myext.txt'); | ||
|
||
try { | ||
$db->sqliteLoadExtension('myext.txt'); | ||
} catch (Extension $ex) { | ||
var_dump($ex->getMessage()); | ||
} | ||
unlink($directory . '/myext.txt'); | ||
|
||
echo "Done\n"; | ||
?> | ||
--EXPECTF-- | ||
Warning: PDO::sqliteLoadExtension(): Unable to load extension at '.%emyext.txt' in %s on line %d | ||
Done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--TEST-- | ||
PDO_sqlite: Testing sqliteLoadExtension() with empty extension test | ||
--CREDITS-- | ||
Jelle Lampaert | ||
#Belgian Testfest 2009 | ||
--INI-- | ||
pdo_sqlite.extension_dir=/tmp | ||
--SKIPIF-- | ||
<?php if (!extension_loaded('pdo_sqlite')) print 'skip not loaded'; ?> | ||
--FILE-- | ||
<?php | ||
|
||
$db = new pdo('sqlite::memory:'); | ||
|
||
try { | ||
$db->sqliteLoadExtension(""); | ||
} catch (Extension $ex) { | ||
var_dump($ex->getMessage()); | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Warning: PDO::sqliteLoadExtension(): Empty string as an extension in %s on line %d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--TEST-- | ||
PDO_sqlite: Testing sqliteLoadExtension() with disabled extensions | ||
--CREDITS-- | ||
Jelle Lampaert | ||
#Belgian Testfest 2009 | ||
--SKIPIF-- | ||
<?php if (!extension_loaded('pdo_sqlite')) print 'skip not loaded'; ?> | ||
--FILE-- | ||
<?php | ||
|
||
$db = new pdo('sqlite::memory:'); | ||
|
||
try { | ||
$db->sqliteLoadExtension(""); | ||
} catch (Extension $ex) { | ||
var_dump($ex->getMessage()); | ||
} | ||
|
||
?> | ||
--EXPECTF-- | ||
Warning: PDO::sqliteLoadExtension(): SQLite Extension are disabled in %s on line %d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--TEST-- | ||
PDO_sqlite: Testing sqliteLoadExtension() with wrong parameter type | ||
--CREDITS-- | ||
Thijs Feryn <[email protected]> | ||
#TestFest PHPBelgium 2009 | ||
--SKIPIF-- | ||
<?php if (!extension_loaded('pdo_sqlite')) print 'skip not loaded'; ?> | ||
--FILE-- | ||
<?php | ||
$db = new pdo('sqlite::memory:'); | ||
var_dump($db->sqliteLoadExtension(array())); | ||
echo "Done\n"; | ||
?> | ||
--EXPECTF-- | ||
Warning: PDO::sqliteLoadExtension() expects parameter 1 to be string, array given in %s on line %d | ||
bool(false) | ||
Done | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit odd, we'd usually go for a positive define instead.
HAVE_SQLITE3_LOAD_EXTENSION
would be typical.