php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80156 Incomplete records may be written
Submitted: 2020-09-27 12:16 UTC Modified: 2020-09-27 12:49 UTC
From: cmb@php.net Assigned: cmb (profile)
Status: Closed Package: dbase (PECL)
PHP Version: 7.4.10 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cmb@php.net
New email:
PHP Version: OS:

 

 [2020-09-27 12:16 UTC] cmb@php.net
Description:
------------
As of PHP 7.4.0, __toString() methods are allowed to throw
exceptions, what is not handled properly by the dbase extension,
so that incomplete records may be written to the database.

That also affects dbase_create(), but missing to handle exceptions
here only leads to confusing warnings.


Test script:
---------------
<?php
class Foo {
    public function __toString() {
        throw new Exception("not allowed");
    }
}
$def = [["name1", "c", 10], ["name2", "c", 10]];
$dbase = dbase_create(__DIR__ . "/dbase.dbf", $def);
try {
    dbase_add_record($dbase, ["cmb", new Foo]);
} catch (Exception $ex) {}
var_dump(dbase_numrecords($dbase));
?>


Expected result:
----------------
int(0)


Actual result:
--------------
int(1)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-27 12:26 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-09-27 12:49 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [2021-04-06 10:18 UTC] git@php.net
Automatic comment on behalf of 
Revision: https://github.com/php/pecl-database-dbase/commit/9c83dee4c48cc8deda59170f684f07b4da8f9ac6
Log: Fix #80156: Incomplete records may be written
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 10:01:28 2024 UTC