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
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.
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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: Sat Jun 15 09:01:29 2024 UTC