Bug #80754 [Nab]: PDO :: quote should return false, but throws an PDOException instead

From: Date: Tue, 16 Feb 2021 10:32:40 +0000
Subject: Bug #80754 [Nab]: PDO :: quote should return false, but throws an PDOException instead
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-232180@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80754&edit=1

 ID:                 80754
 Updated by:         cmb@php.net
 Reported by:        menschov dot evgeny at yandex dot ru
 Summary:            PDO :: quote should return false, but throws an
                     PDOException instead
 Status:             Not a bug
 Type:               Bug
 Package:            PDO ODBC
 Operating System:   Debian GNU/Linux 10 (buster)
 PHP Version:        8.0.2
 Block user comment: N
 Private report:     N

 New Comment:

> I try set PDO::ATTR_ERRMODE = PDO::ERRMODE_SILENT and on php
> 8.0.1 it generates warning. But on php 7.4 warning does not
> appear.

PDO_ODBC never supported quoting[1], so calling ::quote() is
useless.  Prior to PHP 8.0.0, there was a quoter function which
always failed; as of PHP 8.0.0, this quoter function has been
removed[2].  This is why you are seeing the warning now, but not
before.

[1] <https://www.php.net/manual/en/pdo.quote.php>
[2] <https://github.com/php/php-src/commit/24e2ba26b457da2c93aae75c7193c519b5a0aed9>


Previous Comments:
------------------------------------------------------------------------
[2021-02-16 09:12:22] menschov dot evgeny at yandex dot ru

Code Example:

<?php
$dsn = 'odbc:WEB-TRUNK';
$user = '';
$password = '';

print '<pre>';
var_dump('error_reporting: ' . ini_get('error_reporting'));
var_dump('display_startup_errors: ' . ini_get('display_startup_errors'));
var_dump('PDO::ATTR_ERRMODE: PDO::ERRMODE_SILENT');
print '</pre>';

try {
    $dbh = new PDO($dsn, $user, $password);
    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
    echo $dbh->quote("test");
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}

phpinfo();

------------------------------------------------------------------------
[2021-02-16 09:10:38] menschov dot evgeny at yandex dot ru

I try set PDO::ATTR_ERRMODE = PDO::ERRMODE_SILENT and on php 8.0.1 it generates warning. But on php
7.4 warning does not appear.
https://monosnap.com/file/1xVCHwlg4APTzIhDZdfRcF889HTTLu

------------------------------------------------------------------------
[2021-02-16 08:18:46] requinix@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php

https://www.php.net/manual/en/migration80.incompatible.php
> PHP Data Objects 
>
> * The default error handling mode has been changed from "silent" to
> "exceptions". See Errors and error handling for details.

https://www.php.net/manual/en/pdo.error-handling.php

------------------------------------------------------------------------
[2021-02-16 07:48:47] menschov dot evgeny at yandex dot ru

Description:
------------
I brought up php 8.0.2 in docker, using pdo odbc drivers to connect to database. In php 7.4,
PDO::quote returned false, in 8.0.2 it started throwing an exception, which breaks backward
compatibility. I attach a screenshot of the problem
https://monosnap.com/file/3X2hncrAbPLQ9FFNNbP4usbCcXCdG2



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



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


Thread (7 messages)

« previous php.bugs (#232180) next »