php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47223 Dbase corrupted - columns / date
Submitted: 2009-01-27 10:32 UTC Modified: 2009-01-27 11:24 UTC
From: Nicolas dot breuer at belcenter dot be Assigned:
Status: Not a bug Package: dBase related
PHP Version: 5.2.8 OS: Linux
Private report: No CVE-ID: None
 [2009-01-27 10:32 UTC] Nicolas dot breuer at belcenter dot be
Description:
------------
 Hello,

 This bug is present in the PHP source code since
 the release of PHP 5.2.4. We worked with 5.2.3 because
 we can put a newer release in prod. Today i tried to install
 the 5.2.8 and same problem so i publish now a bug report.

 -----

 I add one or more record to a DBase file.
 The header was already on the server 

 Problem is when i opened the file, the columns were truncated.

 Header of dbf file (empty of course)

 Array
(
    [0] => Array
        (
            [name] => NUM
            [type] => number
            [length] => 8
            [precision] => 0
            [format] => %8s
            [offset] => 1
        )

    [1] => Array
        (
            [name] => JNL
            [type] => character
            [length] => 10
            [precision] => 0
            [format] => %-10s
            [offset] => 9
        )

    [2] => Array
        (
            [name] => NUMBER
            [type] => number
            [length] => 10
            [precision] => 0
            [format] => %10s
            [offset] => 19
        )

    [3] => Array
        (
            [name] => DATE
            [type] => date
            [length] => 8
            [precision] => 0
            [format] => %8s
            [offset] => 29
        )

    [4] => Array
        (
            [name] => THIRDGROUP
            [type] => character
            [length] => 10
            [precision] => 0
            [format] => %-10s
            [offset] => 37
        )

    [5] => Array
        (
            [name] => ARTID
            [type] => character
            [length] => 20
            [precision] => 0
            [format] => %-20s
            [offset] => 47
        )

    [6] => Array
        (
            [name] => QTY
            [type] => number
            [length] => 10
            [precision] => 0
            [format] => %10s
            [offset] => 67
        )

    [7] => Array
        (
            [name] => UNITPRICE
            [type] => number
            [length] => 12
            [precision] => 2
            [format] => %12s
            [offset] => 77
        )

    [8] => Array
        (
            [name] => VATID
            [type] => character
            [length] => 10
            [precision] => 0
            [format] => %-10s
            [offset] => 89
        )

    [9] => Array
        (
            [name] => VATPC
            [type] => character
            [length] => 10
            [precision] => 0
            [format] => %-10s
            [offset] => 99
        )

    [10] => Array
        (
            [name] => DISCOUNT
            [type] => character
            [length] => 5
            [precision] => 0
            [format] => %-5s
            [offset] => 109
        )

    [11] => Array
        (
            [name] => ARTNAME
            [type] => character
            [length] => 60
            [precision] => 0
            [format] => %-60s
            [offset] => 114
        )

    [12] => Array
        (
            [name] => D_PMTAUTO
            [type] => character
            [length] => 1
            [precision] => 0
            [format] => %-1s
            [offset] => 174
        )

    [13] => Array
        (
            [name] => DATEPAY
            [type] => date
            [length] => 8
            [precision] => 0
            [format] => %8s
            [offset] => 175
        )

    [14] => Array
        (
            [name] => YOURREF
            [type] => character
            [length] => 10
            [precision] => 0
            [format] => %-10s
            [offset] => 183
        )



Reproduce code:
---------------
$dbname = "temp/test.dbf";
$dbh = dbase_open($dbname, 2)
or die("Error! Could not open dbase database file '$dbname'."); 

$reg=array("1","FAC","20090150","01/01/2009","TEST INPUT","TEST ARTI ID","1","50","0","0","0","Test input char","","-","-"); 
dbase_add_record($dbh,$reg); 
$reg=array("1","FAC","20090150","01/01/2009","TEST INPUT","TEST ARTI ID","1","50","0","0","0","Test input char","","-","-"); 
dbase_add_record($dbh,$reg); 




Expected result:
----------------
 Each value correctly in each column.

Actual result:
--------------
 NUM	JNL	NUMBER	DATE	THIRDGROUP	ARTID	QTY	UNITPRICE	VATID	VATPC	DISCOUNT	ARTNAME	D_PMTAUTO	DATEPAY	YOURREF

1	FAC	20090150		01/01/20TE	ST INPUTTEST ARTI ID		1	      500	        0		   0    Test input char			


1	FAC	20090150		01/01/20TE	ST INPUTTEST ARTI ID		1	      500	        0		   0    Test input char		

 Date column was empty
 and the real date (truncated) was put on THIRDGROUP column.
 Thirdgroup value was put on ArtID column, etc.

 	

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-27 10:42 UTC] felipe@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-01-27 11:14 UTC] Nicolas dot breuer at belcenter dot be
Yes problem was completely solved in CSV 5.2.9-dev

 I compared the two dbf_head.c files (5.2.8 > 5.2.9-dev)
 and i see few lines removed. I suppose it was the problem.
>>> REMOVED 

            case 'D':
                dbf->db_flen = 8;
                break;
            case 'L':
                dbf->db_flen = 1;
                break;
>>> REMOVED 


 Do you have an idea for the official release of 5.2.9 ?

 Thanks
 [2009-01-27 11:24 UTC] felipe@php.net
> Do you have an idea for the official release of 5.2.9 ?
http://marc.info/?l=php-internals&m=123237646001210&w=2

Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC