Skip to content

Conversation

@kiatng
Copy link
Contributor

@kiatng kiatng commented Apr 14, 2020

[edit] This bug affects file deletion of cusotmer attribute in both frontend and backend. It was introduced in ver 1.9.4.1:

        if (!$attribute->isAttributeValidationPassed()) {
            return $this;
        }

in the class Mage_Eav_Model_Attribute_Data_File.

@tmotyl
Copy link
Contributor

tmotyl commented Apr 14, 2020

Hi
Please provide a detailed description of the issue, how to reproduce it and what would you expect to happen.

@kiatng
Copy link
Contributor Author

kiatng commented Apr 15, 2020

[edited]

To reproduce in the ver 1.9.4.x

  1. Execute the MySQL statements below to add a cutomer attribute with attribute_code = 'some_csv'.
  2. Render the attribute in backend customer page. See sample code at the bottom.
  3. Login to backend and navigate to the customer page, upload a file to Some CSV File and press Save and Continue Edit, ensure the file is uploaded.
  4. Select the Delete checkbox and press Save and Continue Edit; we expect file to be deleted, but it is still there

The reason it doesn't delete is because $attribute->isAttributeValidationPassed() is false.

Step 1, add attribute some_csv.

INSERT INTO `eav_attribute` (`attribute_id`, `entity_type_id`, `attribute_code`, `attribute_model`, `backend_model`, `backend_type`, `backend_table`, `frontend_model`, `frontend_input`, `frontend_label`, `frontend_class`, `source_model`, `is_required`, `is_user_defined`, `default_value`, `is_unique`, `note`) 
VALUES (NULL, '1', 'some_csv', NULL, NULL, 'varchar', NULL, NULL, 'file', 'Some CSV File', NULL, NULL, '0', '1', NULL, '0', 'Accept CSV only'); 

# Note the attribute_id from above
INSERT INTO `customer_eav_attribute` (`attribute_id`, `is_visible`, `input_filter`, `multiline_count`, `validate_rules`, `is_system`, `sort_order`, `data_model`) 
VALUES ({{attribute_id}}, '1', NULL, '1', 'a:1:{s:13:\"max_file_size\";i:2000000;}', '0', '4', 'customer/attribute_data_file') 

INSERT INTO `customer_form_attribute` (`form_code`, `attribute_id`) 
VALUES ('adminhtml_customer', {{attribute_id}})

Step 2, render the attribute in backend's customer page:

//  copy paste the following code in line 279 app\code\core\Mage\Adminhtml\Block\Customer\Edit\Tab\Account.php
$fieldset->addField('some_csv', 'file',
    array(
        'name'      => 'some_csv',
        'label'     => 'Some CSV File'
    )
);

}
return true;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To trace the logic, please expand to code below to show the function compactValue, where the delete operation is carried out.

@sreichel sreichel added bug Component: Eav Relates to Mage_Eav labels Jun 5, 2020
@Flyingmana Flyingmana changed the title Fix file delete Fix file delete of customer attribute Sep 28, 2021
@Flyingmana Flyingmana merged commit 7a039a6 into OpenMage:1.9.4.x Sep 28, 2021
@github-actions
Copy link
Contributor

Unit Test Results

1 files  1 suites   0s ⏱️
0 tests 0 ✔️ 0 💤 0 ❌
7 runs  5 ✔️ 2 💤 0 ❌

Results for commit 7a039a6.

spinsch pushed a commit to spinsch/magento-lts that referenced this pull request Oct 13, 2021
* Insert whitespace in class name for styling to work. See pull request OpenMage#594 Remove whitespace in addBodyClass($className)OpenMage#594

* Fix file delete in customer attribute of `frontend_input` = 'file'.
@kiatng kiatng deleted the fix_file_delete branch February 27, 2023 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Component: Eav Relates to Mage_Eav

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants