Skip to content
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

Merged
merged 7 commits into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/code/Magento/Eav/Model/Attribute/Data/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Copy link
Contributor

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?

Copy link
Member Author

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

Copy link
Member

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

Copy link
Member

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

Nazar65 marked this conversation as resolved.
Show resolved Hide resolved
return [__('"%1" is not a valid file.', $label)];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Contributor

Choose a reason for hiding this comment

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

Why need tools?

Copy link
Member Author

@Nazar65 Nazar65 Dec 27, 2018

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);
            }

Copy link
Member Author

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

Copy link
Member

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

], function ($, _, utils, uiAlert, validator, Element, notification, $t) {
'use strict';

Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/Variable/view/adminhtml/web/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ define([
'Magento_Variable/js/custom-directive-generator',
'Magento_Ui/js/lib/spinner',
'jquery/ui',
'prototype'
'prototype',
'mage/adminhtml/tools'
], function (jQuery, notification, $t, wysiwyg, registry, mageApply, utils, configGenerator, customGenerator, loader) {
'use strict';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ define([
'Magento_Variable/js/config-directive-generator',
'Magento_Variable/js/custom-directive-generator',
'wysiwygAdapter',
'jquery'
'jquery',
'mage/adminhtml/tools'
], function (configDirectiveGenerator, customDirectiveGenerator, wysiwyg, jQuery) {
return function (config) {
tinymce.create('tinymce.plugins.magentovariable', {
Expand Down