diff --git a/.gitignore b/.gitignore index d4e35bd33d65e..f7484667bb592 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,8 @@ atlassian* /.grunt /Gruntfile.js /package.json +/.php_cs +/.php_cs.cache /grunt-config.json /dev/tools/grunt/configs/local-themes.js diff --git a/.htaccess b/.htaccess index af9470488c632..90b9c16a5a8c0 100644 --- a/.htaccess +++ b/.htaccess @@ -222,7 +222,7 @@ order allow,deny deny from all - + order allow,deny deny from all diff --git a/.htaccess.sample b/.htaccess.sample index f3dbe217081ac..3b61bb672ec8a 100644 --- a/.htaccess.sample +++ b/.htaccess.sample @@ -198,7 +198,7 @@ order allow,deny deny from all - + order allow,deny deny from all diff --git a/.php_cs b/.php_cs deleted file mode 100644 index 4bd705bb09a2f..0000000000000 --- a/.php_cs +++ /dev/null @@ -1,52 +0,0 @@ -name('*.phtml') - ->exclude('dev/tests/functional/generated') - ->exclude('dev/tests/functional/var') - ->exclude('dev/tests/functional/vendor') - ->exclude('dev/tests/integration/tmp') - ->exclude('dev/tests/integration/var') - ->exclude('lib/internal/Cm') - ->exclude('lib/internal/Credis') - ->exclude('lib/internal/Less') - ->exclude('lib/internal/LinLibertineFont') - ->exclude('pub/media') - ->exclude('pub/static') - ->exclude('setup/vendor') - ->exclude('var'); - -return Symfony\CS\Config\Config::create() - ->finder($finder) - ->level(Symfony\CS\FixerInterface::PSR2_LEVEL) - ->fixers([ - 'double_arrow_multiline_whitespaces', - 'duplicate_semicolon', - 'extra_empty_lines', - 'include', - 'join_function', - 'namespace_no_leading_whitespace', - 'new_with_braces', - 'object_operator', - 'operators_spaces', - 'remove_leading_slash_use', - 'remove_lines_between_uses', - 'single_array_no_trailing_comma', - 'spaces_before_semicolon', - 'standardize_not_equal', - 'ternary_spaces', - 'unused_use', - 'whitespacy_lines', - 'concat_with_spaces', - 'multiline_spaces_before_semicolon', - 'ordered_use', - 'short_array_syntax', - ]); diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 0000000000000..095bfa8f1c6b5 --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,49 @@ +name('*.phtml') + ->exclude('dev/tests/functional/generated') + ->exclude('dev/tests/functional/var') + ->exclude('dev/tests/functional/vendor') + ->exclude('dev/tests/integration/tmp') + ->exclude('dev/tests/integration/var') + ->exclude('lib/internal/Cm') + ->exclude('lib/internal/Credis') + ->exclude('lib/internal/Less') + ->exclude('lib/internal/LinLibertineFont') + ->exclude('pub/media') + ->exclude('pub/static') + ->exclude('setup/vendor') + ->exclude('var'); + +return PhpCsFixer\Config::create() + ->setFinder($finder) + ->setRules([ + '@PSR2' => true, + 'array_syntax' => ['syntax' => 'short'], + 'concat_space' => ['spacing' => 'one'], + 'include' => true, + 'new_with_braces' => true, + 'no_empty_statement' => true, + 'no_extra_consecutive_blank_lines' => true, + 'no_leading_import_slash' => true, + 'no_leading_namespace_whitespace' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_singleline_whitespace_before_semicolons' => true, + 'no_trailing_comma_in_singleline_array' => true, + 'no_unused_imports' => true, + 'no_whitespace_in_blank_line' => true, + 'object_operator_without_whitespace' => true, + 'ordered_imports' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + ]); diff --git a/app/code/Magento/AdminNotification/i18n/en_US.csv b/app/code/Magento/AdminNotification/i18n/en_US.csv index 7b55e96976cad..1afb8104bfef6 100644 --- a/app/code/Magento/AdminNotification/i18n/en_US.csv +++ b/app/code/Magento/AdminNotification/i18n/en_US.csv @@ -1,13 +1,13 @@ "Read Details","Read Details" "Mark as Read","Mark as Read" "Are you sure?","Are you sure?" -Remove,Remove +"Remove","Remove" "Messages Inbox","Messages Inbox" "You have %1 new system messages","You have %1 new system messages" "You have %1 new system message","You have %1 new system message" "Incoming Message","Incoming Message" -close,close -Notifications,Notifications +"close","close" +"Notifications","Notifications" "The message has been marked as Read.","The message has been marked as Read." "We couldn't mark the notification as Read because of an error.","We couldn't mark the notification as Read because of an error." "Please select messages.","Please select messages." @@ -20,10 +20,10 @@ Notifications,Notifications "6 Hours","6 Hours" "12 Hours","12 Hours" "24 Hours","24 Hours" -critical,critical -major,major -minor,minor -notice,notice +"critical","critical" +"major","major" +"minor","minor" +"notice","notice" "Wrong message type","Wrong message type" "Wrong notification ID specified.","Wrong notification ID specified." "{{base_url}} is not recommended to use in a production environment to declare the Base Unsecure URL / Base Secure URL. We highly recommend changing this value in your Magento configuration.","{{base_url}} is not recommended to use in a production environment to declare the Base Unsecure URL / Base Secure URL. We highly recommend changing this value in your Magento configuration." @@ -33,7 +33,7 @@ notice,notice "Synchronization of media storages has been completed.","Synchronization of media storages has been completed." "Your web server is set up incorrectly and allows unauthorized access to sensitive files. Please contact your hosting provider.","Your web server is set up incorrectly and allows unauthorized access to sensitive files. Please contact your hosting provider." "Close popup","Close popup" -Close,Close +"Close","Close" "System Messages:","System Messages:" "Critical System Messages","Critical System Messages" "Major System Messages","Major System Messages" @@ -45,7 +45,7 @@ Close,Close "Use HTTPS to Get Feed","Use HTTPS to Get Feed" "Update Frequency","Update Frequency" "Last Update","Last Update" -Severity,Severity +"Severity","Severity" "Date Added","Date Added" -Message,Message -Actions,Actions +"Message","Message" +"Actions","Actions" diff --git a/app/code/Magento/Checkout/Block/Cart/AbstractCart.php b/app/code/Magento/Checkout/Block/Cart/AbstractCart.php index 5f83aefbffb12..34f8926e7f441 100644 --- a/app/code/Magento/Checkout/Block/Cart/AbstractCart.php +++ b/app/code/Magento/Checkout/Block/Cart/AbstractCart.php @@ -40,7 +40,7 @@ class AbstractCart extends \Magento\Framework\View\Element\Template protected $_customerSession; /** - * @var \Magento\Customer\Model\Session + * @var \Magento\Checkout\Model\Session */ protected $_checkoutSession; diff --git a/app/code/Magento/Directory/Setup/InstallData.php b/app/code/Magento/Directory/Setup/InstallData.php index ba259af6f8500..f193ae67cab9d 100644 --- a/app/code/Magento/Directory/Setup/InstallData.php +++ b/app/code/Magento/Directory/Setup/InstallData.php @@ -808,7 +808,28 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface ['BR', 'SP', 'São Paulo'], ['BR', 'SE', 'Sergipe'], ['BR', 'TO', 'Tocantins'], - ['BR', 'DF', 'Distrito Federal'] + ['BR', 'DF', 'Distrito Federal'], + ['HR', 'HR-01', 'Zagrebačka županija'], + ['HR', 'HR-02', 'Krapinsko-zagorska županija'], + ['HR', 'HR-03', 'Sisačko-moslavačka županija'], + ['HR', 'HR-04', 'Karlovačka županija'], + ['HR', 'HR-05', 'Varaždinska županija'], + ['HR', 'HR-06', 'Koprivničko-križevačka županija'], + ['HR', 'HR-07', 'Bjelovarsko-bilogorska županija'], + ['HR', 'HR-08', 'Primorsko-goranska županija'], + ['HR', 'HR-09', 'Ličko-senjska županija'], + ['HR', 'HR-10', 'Virovitičko-podravska županija'], + ['HR', 'HR-11', 'Požeško-slavonska županija'], + ['HR', 'HR-12', 'Brodsko-posavska županija'], + ['HR', 'HR-13', 'Zadarska županija'], + ['HR', 'HR-14', 'Osječko-baranjska županija'], + ['HR', 'HR-15', 'Šibensko-kninska županija'], + ['HR', 'HR-16', 'Vukovarsko-srijemska županija'], + ['HR', 'HR-17', 'Splitsko-dalmatinska županija'], + ['HR', 'HR-18', 'Istarska županija'], + ['HR', 'HR-19', 'Dubrovačko-neretvanska županija'], + ['HR', 'HR-20', 'Međimurska županija'], + ['HR', 'HR-21', 'Grad Zagreb'] ]; foreach ($data as $row) { diff --git a/app/code/Magento/Directory/etc/zip_codes.xml b/app/code/Magento/Directory/etc/zip_codes.xml index 1976c2cb46b25..d03e6be4a7dd2 100644 --- a/app/code/Magento/Directory/etc/zip_codes.xml +++ b/app/code/Magento/Directory/etc/zip_codes.xml @@ -277,8 +277,9 @@ - ^[a-zA-Z]{3}\s[0-9]{3}$ - ^[a-zA-Z]{3}\s[0-9]{2}$ + ^[a-zA-Z]{3}\s[0-9]{4}$ + ^[a-zA-Z]{3}\s[0-9]{3}$ + ^[a-zA-Z]{3}\s[0-9]{2}$ diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/ArrayBackend.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/ArrayBackend.php index c387631e693cd..16eb425d6f4b1 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/ArrayBackend.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/ArrayBackend.php @@ -23,7 +23,9 @@ public function beforeSave($object) $attributeCode = $this->getAttribute()->getAttributeCode(); $data = $object->getData($attributeCode); if (is_array($data)) { - $data = array_filter($data); + $data = array_filter($data, function ($value) { + return $value === '0' || !empty($value); + }); $object->setData($attributeCode, implode(',', $data)); } diff --git a/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js b/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js index ed0933c77e897..ddda297ee4776 100644 --- a/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js +++ b/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js @@ -309,12 +309,12 @@ define([ _create: function () { var options = this.options, gallery = $('[data-gallery-role=gallery-placeholder]', '.column.main'), - isProductViewExist = $('body.catalog-product-view').size() > 0, - $main = isProductViewExist ? + productData = this._determineProductData(), + $main = productData.isInProductView ? this.element.parents('.column.main') : this.element.parents('.product-item-info'); - if (isProductViewExist) { + if (productData.isInProductView) { gallery.data('gallery') ? this._onGalleryLoaded(gallery) : gallery.on('gallery:loaded', this._onGalleryLoaded.bind(this, gallery)); @@ -328,6 +328,34 @@ define([ this.inProductList = this.productForm.length > 0; }, + /** + * Determine product id and related data + * + * @returns {{productId: *, isInProductView: bool}} + * @private + */ + _determineProductData: function () { + // Check if product is in a list of products. + var productId, + product, + isInProductView = false; + + productId = this.element.parents('.product-item-details') + .find('.price-box.price-final_price').attr('data-product-id'); + + if (!productId) { + // Check individual product. + product = document.getElementsByName('product')[0]; + productId = product ? product.value : undefined; + isInProductView = productId > 0; + } + + return { + productId: productId, + isInProductView: isInProductView + }; + }, + /** * Render controls * @@ -897,7 +925,7 @@ define([ var $widget = this, $this = $widget.element, attributes = {}, - productId = 0, + productData = this._determineProductData(), mediaCallData, mediaCacheKey, @@ -911,7 +939,7 @@ define([ if (!(mediaCacheKey in $widget.options.mediaCache)) { $widget.options.mediaCache[mediaCacheKey] = data; } - $widget._ProductMediaCallback($this, data); + $widget._ProductMediaCallback($this, data, productData.isInProductView); $widget._DisableProductMediaLoader($this); }; @@ -925,17 +953,8 @@ define([ attributes[$selected.attr('attribute-code')] = $selected.attr('option-selected'); }); - if ($('body.catalog-product-view').size() > 0) { - //Product Page - productId = document.getElementsByName('product')[0].value; - } else { - //Category View - productId = $this.parents('.product.details.product-item-details') - .find('.price-box.price-final_price').attr('data-product-id'); - } - mediaCallData = { - 'product_id': productId, + 'product_id': productData.productId, 'attributes': attributes, 'additional': $.parseQuery() }; @@ -1001,11 +1020,11 @@ define([ * * @param {Object} $this * @param {String} response + * @param {Boolean} isInProductView * @private */ - _ProductMediaCallback: function ($this, response) { - var isProductViewExist = $('body.catalog-product-view').size() > 0, - $main = isProductViewExist ? $this.parents('.column.main') : $this.parents('.product-item-info'), + _ProductMediaCallback: function ($this, response, isInProductView) { + var $main = isInProductView ? $this.parents('.column.main') : $this.parents('.product-item-info'), $widget = this, images = [], @@ -1020,7 +1039,7 @@ define([ }; if (_.size($widget) < 1 || !support(response)) { - this.updateBaseImage(this.options.mediaGalleryInitial, $main, isProductViewExist); + this.updateBaseImage(this.options.mediaGalleryInitial, $main, isInProductView); return; } @@ -1045,7 +1064,7 @@ define([ }); } - this.updateBaseImage(images, $main, isProductViewExist); + this.updateBaseImage(images, $main, isInProductView); }, /** @@ -1070,16 +1089,16 @@ define([ * Update [gallery-placeholder] or [product-image-photo] * @param {Array} images * @param {jQuery} context - * @param {Boolean} isProductViewExist + * @param {Boolean} isInProductView */ - updateBaseImage: function (images, context, isProductViewExist) { + updateBaseImage: function (images, context, isInProductView) { var justAnImage = images[0], initialImages = this.options.mediaGalleryInitial, gallery = context.find(this.options.mediaGallerySelector).data('gallery'), imagesToUpdate, isInitial; - if (isProductViewExist) { + if (isInProductView) { imagesToUpdate = images.length ? this._setImageType($.extend(true, [], images)) : []; isInitial = _.isEqual(imagesToUpdate, initialImages); diff --git a/app/code/Magento/Theme/Block/Html/Topmenu.php b/app/code/Magento/Theme/Block/Html/Topmenu.php index dcdff0cb39f2e..239911670d9d6 100644 --- a/app/code/Magento/Theme/Block/Html/Topmenu.php +++ b/app/code/Magento/Theme/Block/Html/Topmenu.php @@ -187,7 +187,7 @@ protected function _addSubMenu($child, $childLevel, $childrenWrapClass, $limit) $colStops = $this->_columnBrake($child->getChildren(), $limit); } - $html .= '