-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for issue 19983 Can't upload customer Image attribute programmatically #19988
Conversation
Hi @Nazar65. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
@@ -146,7 +146,7 @@ protected function _validateByRules($value) | |||
return $this->_fileValidator->getMessages(); | |||
} | |||
|
|||
if (!empty($value['tmp_name']) && !is_uploaded_file($value['tmp_name'])) { | |||
if (empty($value['tmp_name']) && !is_uploaded_file($value['tmp_name'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this ever evaluate to true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes on event where empty value of ['tmp_name'] and file not uploaded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition looks correct to me. If you really need a check for empty($value['tmp_name'])
- make it a separate condition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I'd leave php side as it is
@@ -16,7 +16,8 @@ define([ | |||
'Magento_Ui/js/form/element/abstract', | |||
'mage/backend/notification', | |||
'mage/translate', | |||
'jquery/file-uploader' | |||
'jquery/file-uploader', | |||
'mage/adminhtml/tools' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why need tools?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Base64 is not defined" when try upload image -> caused by line 173 ->
if (!file.id && file.name) {
file.id = Base64.mageEncode(file.name);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is core issue for -> #18688
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's interesting, there are more js files using Base64
without dependency on mage/adminhtml/tools
- probably those files require to be fixed too
Hi @orlangur I was leave a comment |
@orlangur any updates ? |
@magento-engcom-team give me test instance |
Hi @sivaschenko. Thank you for your request. I'm working on Magento instance for you |
Hi @sivaschenko, here is your new Magento instance. |
@@ -146,7 +146,7 @@ protected function _validateByRules($value) | |||
return $this->_fileValidator->getMessages(); | |||
} | |||
|
|||
if (!empty($value['tmp_name']) && !is_uploaded_file($value['tmp_name'])) { | |||
if (empty($value['tmp_name']) && !is_uploaded_file($value['tmp_name'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition looks correct to me. If you really need a check for empty($value['tmp_name'])
- make it a separate condition
@@ -146,7 +146,7 @@ protected function _validateByRules($value) | |||
return $this->_fileValidator->getMessages(); | |||
} | |||
|
|||
if (!empty($value['tmp_name']) && !is_uploaded_file($value['tmp_name'])) { | |||
if (empty($value['tmp_name']) && !is_uploaded_file($value['tmp_name'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I'd leave php side as it is
@@ -16,7 +16,8 @@ define([ | |||
'Magento_Ui/js/form/element/abstract', | |||
'mage/backend/notification', | |||
'mage/translate', | |||
'jquery/file-uploader' | |||
'jquery/file-uploader', | |||
'mage/adminhtml/tools' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's interesting, there are more js files using Base64
without dependency on mage/adminhtml/tools
- probably those files require to be fixed too
Hi @Nazar65 thanks for the contribution please see my code review notes |
@sivaschenko Well, I will provide a better fix for this problem, thank you |
@sivaschenko Base64 defined by adminhtml tools please loook ->
There is no difference, all other files are using mage/adminhtml |
@Nazar65 you are completely right about Base64, I just mentioned that it appears there may be more bugs in Magento because of Base64 usage without dependency on |
@sivaschenko i'm added adminhtml/tools where is used but not defined, what about php part ? for me this is the good condition on "if" statement. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Nazar65 thanks for your updates, please see my comment with the suggestion regarding the php condition
Co-Authored-By: Nazar65 <nazarn96@gmail.com>
@sivaschenko I'm found the core problem of issue, the function is_uploaded_file return false because -> |
@Nazar65 I am not sure there is a difference between |
@sivaschenko yes, but function is_uploaded_file return false but file exist. this function check if file uploaded via HTTP POST action |
@sivaschenko |
@sivaschenko so basically to fix this issue we need just add the following condition
|
@orlangur or @sivaschenko any update on this ? |
What is the fix? I can't do any development because I can't change themes. |
Sorry for delay @Nazar65 the pull request is approved and will be further processed internally |
Hi @sivaschenko, thank you for the review. |
Hi @Nazar65, thank you for your contribution! |
…e programmatically #19988
@magento-engcom-team give me test instance |
Hi @sivaschenko. Thank you for your request. I'm working on Magento instance for you |
Description (*)
Could not load image for customer attribute, error: Base64 is not defined "
Fixed Issues (if relevant)
Manual testing scenarios (*)
1-Create customer attribute type file ->
2. try to upload image on adminhtml customer edit.
Expected Result
No errors in Console, Image uploaded
Contribution checklist (*)