php.net |  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: cmb@php.net Assigned: cmb (profile)
Status: Closed Package: dbase (PECL)
PHP Version: 7.1Git-2016-10-28 (Git) OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
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:

 

 [2016-10-28 12:14 UTC] cmb@php.net
Description:
------------
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:
---------------
<?php

$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);
dbase_close($db);

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


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

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
bool(true)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-28 12:15 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2016-10-28 22:32 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=340781
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] cmb@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Oct 09 16:01:27 2024 UTC