Skip to content

11828 Fix issue with swatch colour block not showing in admin panel once colour selected (PHP7.1.x issue). #13101

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

Merged
merged 1 commit into from
Jan 17, 2018
Merged

11828 Fix issue with swatch colour block not showing in admin panel once colour selected (PHP7.1.x issue). #13101

merged 1 commit into from
Jan 17, 2018

Conversation

chris-pook
Copy link
Contributor

Description

Using PHP7.1.x the swatch colour block preview in the admin panel attribute will not show the actual colour as the inline style is set to style"b". This is due to PHP no longer allowing strings to be manipulated as arrays.

Fixed Issues (if relevant)

  1. Visual Swatches not showing swatch color in admin #11828: Visual Swatches not showing swatch color in admin

Manual testing scenarios

Preconditions
Magento CE 2.2
PHP 7.1.0
Steps to reproduce
Inside admin, go to Stores->Product and click on an attribute that contains visual swatches.
Expected result
Visual Swatches that have a color assigned should show that color in the swatch box.
Actual result
Although the color swatch values are being saved, the visual representation of the color in the box is colorless.

Contribution checklist

  • [ x] Pull request has a meaningful description of its purpose
  • [ x] All commits are accompanied by meaningful commit messages
  • [ x] All new or changed code is covered with unit/integration tests (if applicable)
  • [ x] All automated tests passed successfully (all builds on Travis CI are green)

@ihor-sviziev
Copy link
Contributor

@chris-pook could you explain what it was returning in php 7.0? There is string to array conversion, so probably we were getting some unexpected result

@chris-pook
Copy link
Contributor Author

chris-pook commented Jan 10, 2018

Hi @ihor-sviziev on php7.0 an array is returned containing the inline style strings as set by the function. The problem is that using php7.1 the strings are truncated due to the odd way they are produced using array notation on $newSwatch which is defined as a string.

To see the issue introduced in php7.1 you can run the following code:

<?php
$str = '';
$str[3] = 'background';
var_dump($str[3]);

With php7.0 this will produce:

string(10) "background"

With php7.1 this will output:

string(1) "b"

@orlangur orlangur self-assigned this Jan 10, 2018
@@ -84,15 +84,15 @@ public function getJsonConfig()
* Parse swatch labels for template
*
* @codeCoverageIgnore
* @param null $swatchStoreValue
* @return string
* @param array $swatchStoreValue
Copy link
Contributor

Choose a reason for hiding this comment

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

It can still be null. Could you also squash changes into single commit and force push?

@chris-pook
Copy link
Contributor Author

@orlangur updated docblock and squashed commits down to 1 (apologies for multiple updates, messed up a local merge).

@magento-team magento-team merged commit ee5fc2e into magento:2.2-develop Jan 17, 2018
magento-team pushed a commit that referenced this pull request Jan 17, 2018
…n admin panel once colour selected (PHP7.1.x issue). #13101
@magento-engcom-team magento-engcom-team added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Jan 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Progress: accept Release Line: 2.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants