php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80754 PDO :: quote should return false, but throws an PDOException instead
Submitted: 2021-02-16 07:48 UTC Modified: 2021-02-16 13:13 UTC
From: menschov dot evgeny at yandex dot ru Assigned:
Status: Not a bug Package: PDO ODBC
PHP Version: 8.0.2 OS: Debian GNU/Linux 10 (buster)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: menschov dot evgeny at yandex dot ru
New email:
PHP Version: OS:

 

 [2021-02-16 07:48 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-02-16 08:18 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2021-02-16 08:18 UTC] 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 09:10 UTC] 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 09:12 UTC] 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 10:32 UTC] cmb@php.net
> 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>
 [2021-02-16 12:30 UTC] marco at tremani dot nl
The PHP documentation still describes that PDO::quote() will return false if the function is not supported by the PDO driver. It also does not state a warning or exception could be thrown. (https://www.php.net/manual/en/pdo.quote.php)

Is the current behavior then considered correct? If so, should the documentation be updated?
 [2021-02-16 13:13 UTC] nikic@php.net
The warning is due to bug #71941.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 07:01:29 2024 UTC