Ticket #1369 (closed defect: fixed)

Opened 10 months ago

Last modified 10 months ago

Bug in Doctrine_Data_Export::prepareData()

Reported by: wolfpakz Owned by: jwage
Priority: minor Milestone:
Component: Attributes Version: 1.0.0
Severity: Keywords:
Cc: Has Test: yes
Status: Pending Core Response Has Patch: yes

Description

This method incorrectly excludes some record information. The cases I have run into so far are empty string fields and boolean fields with a 'false' value. The offending code is commented below:

    public function prepareData($data)
    {
        $preparedData = array();

        foreach ($data AS $className => $classData) {
            foreach ($classData as $record) {
                $className = get_class($record);
                $recordKey = $className . '_' . implode('_', $record->identifier());

                $recordData = $record->toArray(false);

                foreach ($recordData as $key => $value) {
                    /*
                     * This condition is the problem.
                     */
                    if ( ! $value) {
                        continue;
                    }
-- cut --

I expect boolean fields with a false value to dump their values as "false". What actually happens is the boolean field is ommitted entirely. This is also the case with an empty string field. The problem becomes apparent when you later try to load the data. If those fields have 'notnull' on them, you get validation exceptions because the values are completely missing.

Attachments

data_export_patch.txt (0.5 KB) - added by wolfpakz 10 months ago.
data_export_test_patch.txt (1.6 KB) - added by wolfpakz 10 months ago.
data_export_test_model.txt (232 bytes) - added by wolfpakz 10 months ago.

Change History

Changed 10 months ago by wolfpakz

Changed 10 months ago by wolfpakz

Changed 10 months ago by wolfpakz

Changed 10 months ago by jwage

  • status changed from new to closed
  • resolution set to fixed

(In [4808]) fixes #1369

Changed 10 months ago by anonymous

  • milestone New deleted

Milestone New deleted

Note: See TracTickets for help on using tickets.