Req #64810 [Com]: impossible to load extension via pdo_sqlite

From: Date: Thu, 05 Jul 2018 02:03:35 +0000
Subject: Req #64810 [Com]: impossible to load extension via pdo_sqlite
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216143@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64810&edit=1

 ID:                 64810
 Comment by:         cwt137 at gmail dot com
 Reported by:        kamatoz at gmail dot com
 Summary:            impossible to load extension via pdo_sqlite
 Status:             Open
 Type:               Feature/Change Request
 Package:            PDO SQLite
 Operating System:   any
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

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? https://github.com/php/php-src/pull/3368


Previous Comments:
------------------------------------------------------------------------
[2018-04-25 04:52:25] 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.

------------------------------------------------------------------------
[2016-05-18 21:23:01] bugs dot php dot net at businger dot ch

+1: please make this a php.ini option

------------------------------------------------------------------------
[2014-09-17 14:55:57] benjamin dot morel at gmail dot com

+1
Definitely a show-stopper!

------------------------------------------------------------------------
[2013-10-23 18:14:31] 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.

http://stackoverflow.com/questions/8756146/how-to-load-sqlite-extension-in-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);
    }

------------------------------------------------------------------------
[2013-05-10 07:38:31] kamatoz at gmail dot com

Description:
------------
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("libspatialite.so.3")');
}
catch (PDOException $e) {
    echo "Failed to get DB handle: " . $e->getMessage() . "\n";
    exit;
}

Expected result:
----------------
No exception should be thrown

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



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=64810&edit=1


Thread (8 messages)

« previous php.bugs (#216143) next »