|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64810 impossible to load extension via pdo_sqlite
Submitted: 2013-05-10 07:38 UTC Modified: 2016-08-29 14:31 UTC
Avg. Score:4.7 ± 0.6
Reproduced:37 of 38 (97.4%)
Same Version:17 (45.9%)
Same OS:19 (51.4%)
From: kamatoz at gmail dot com Assigned:
Status: Open Package: PDO SQLite
PHP Version: Irrelevant OS: any
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-05-10 07:38 UTC] kamatoz at gmail dot com
Currently if you use php pdo_sqlite it's impossible to load an sqlite extension 
to sqlite. It's good practice to turn off this opportunity by default, but it 
should be possible to override the behavior via config file

Test script:
$pdo = new PDO('sqlite:test.db','','',[PDO::ATTR_ERRMODE=> PDO::ERRMODE_EXCEPTION]);

try {
    $result = $pdo->query('select load_extension("")');
catch (PDOException $e) {
    echo "Failed to get DB handle: " . $e->getMessage() . "\n";

Expected result:
No exception should be thrown

Actual result:
Failed to get DB handle: SQLSTATE[HY000]: General error: 1 not authorized


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-23 18:14 UTC] jwhite at tdc-group dot com
Very much need this too.  Would it be possible, if this is disabled for security concerns, to offer a flag in the php.ini to enable this feature?

I'm not sure how helpful this is, but someone has hacked their own copy of php to allow the load_extension function to work with PDO.

--- php-5.3.7.old/ext/pdo_sqlite/sqlite_driver.c    2012-01-06 11:04:44.000000000 -0500
+++ sqlite_driver.c 2012-01-06 08:16:58.000000000 -0500
@@ -718,6 +718,8 @@
        goto cleanup;

+   sqlite3_enable_load_extension(H->db, 1);
    if (PG(safe_mode) || (PG(open_basedir) && *PG(open_basedir))) {
        sqlite3_set_authorizer(H->db, authorizer, NULL);
 [2014-09-17 14:55 UTC] benjamin dot morel at gmail dot com
Definitely a show-stopper!
 [2016-05-18 21:23 UTC] bugs dot php dot net at businger dot ch
+1: please make this a php.ini option
 [2016-08-29 14:31 UTC]
-Package: PDO related +Package: PDO SQLite
 [2018-04-25 04:52 UTC] zach at zachlanich dot com
+1 This is a huge problem for us Laravel users who need Spatial Calculation. I've spent days trying to find a work-around for my unit tests. My whole suite runs unbearably slow due to needing to use an actual MySQL database for most tests. It's currently not possible/probable to use the raw SQLite3 php class instead of PDO in Laravel, nor would it be practical to attempt to do so. Ability to override via config would be huge for us.
 [2018-07-05 02:03 UTC] cwt137 at gmail dot com
Hello. I submitted a PR for this. The unit test still fail. If someone knows the PHP internals, can they please have a look at this?
 [2018-10-30 14:50 UTC] cwt137 at gmail dot com

I fixed all the issues with this PR. Please check it out and comment on it.
 [2018-12-21 15:20 UTC]
The following pull request has been associated:

Patch Name: Implemented request #64810 (impossible to load extension via pdo_sqlite)
On GitHub:
 [2020-05-28 07:31 UTC] arnoutboks at gmail dot com
If you want a workaround for this feature, see for a possibility. I wouldn't recommend using this trick in production though.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jul 19 04:01:28 2024 UTC