|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73411 dbase_pack() returns TRUE on failure
Submitted: 2016-10-28 12:14 UTC Modified: 2016-10-28 22:46 UTC
From: Assigned: cmb (profile)
Status: Closed Package: dbase (PECL)
PHP Version: 7.1Git-2016-10-28 (Git) OS: *
Private report: No CVE-ID: None
 [2016-10-28 12:14 UTC]
Contrary to the documentation which states that dbase_pack() returns
TRUE on success and FALSE on failure, it always returns TRUE.
Furthermore, the warning message is confusing at best.

Test script:

$filename = 'test.dbf';

$db = dbase_create($filename, [['NAME', 'C', 50]]);
dbase_add_record($db, ['foo']);
dbase_add_record($db, ['bar']);
dbase_delete_record($db, 1);

$db = dbase_open($filename, 0); // read-only

Expected result:
Warning: dbase_pack(): couldn't write to the file in %s on line %d

Actual result:
Warning: dbase_pack(): dbase_pack() couldn't truncate the file to the right size. Some deleted records may still be left in there in %s on line %d


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-28 12:15 UTC]
-Assigned To: +Assigned To: cmb
 [2016-10-28 22:32 UTC]
Automatic comment from SVN on behalf of cmb
Log: Fix #73411 :dbase_pack() returns TRUE on failure

We fix the return value according to the documentation, and raise a
warning if reading or writing fails, in which case we won't truncate the
file nor update the record count, to limit the damage.
 [2016-10-28 22:46 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 16 02:01:29 2024 UTC