Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix wrong type for "images" option in ProductFixture#9553

Merged
pamil merged 1 commit into
Sylius:1.1from
teohhanhui:fix/product-fixture-images
Jul 11, 2018
Merged

Fix wrong type for "images" option in ProductFixture#9553
pamil merged 1 commit into
Sylius:1.1from
teohhanhui:fix/product-fixture-images

Conversation

@teohhanhui
Copy link
Copy Markdown
Contributor

Q A
Branch? 1.1
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets N/A
License MIT

It wasn't actually working with ProductExampleFactory, but the tests don't catch it.

Copy link
Copy Markdown
Contributor

@pamil pamil left a comment

Choose a reason for hiding this comment

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

Given that current ProductFixture implementation does not work, I started to wonder about the current configuration structure.

images:
 - ['path1.jpg', 'main']
 - ['path2.jpg', 'thumbnail']
 - ['path3.jpg', 'thumbnail']

looks worse to me than alternatives:

images:
  'path1.jpg': 'main'
  'path2.jpg': 'thumbnail'
  'path3.jpg': 'thumbnail'

or the best one:

images:
  - { path: 'path1.jpg', type: 'main' }
  - { path: 'path2.jpg', type: 'thumbnail' }
  - { path: 'path3.jpg', type: 'thumbnail' }

The last one looks the best for me, so I think we should make it work that way while keeping and deprecating the first way in ProductExampleFactory. WDYT?

@teohhanhui
Copy link
Copy Markdown
Contributor Author

The best to me would be:

images:
    main: 'path1.jpg'
    thumbnail: 'path2.jpg'

@teohhanhui
Copy link
Copy Markdown
Contributor Author

But yeah, it'd be a problem when we want to leave the type empty. So I'll go with your second option.

@pamil
Copy link
Copy Markdown
Contributor

pamil commented Jul 5, 2018

Yeah, that was my first thought too, but the type is nullable and is not unique.

@teohhanhui teohhanhui force-pushed the fix/product-fixture-images branch 2 times, most recently from 0d98bc0 to d8f064e Compare July 10, 2018 12:14
{
foreach ($options['images'] as $image) {
$imagePath = array_shift($image);
$imagePath = array_key_exists('path', $image) ? $image['path'] : array_shift($image);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@pamil Should we actually @trigger_error here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍, if there's no path key in that array.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But is it okay to add deprecation in a bug fix? 😆

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could add the deprecation in another PR targeting master, WDYT?

Copy link
Copy Markdown
Contributor

@pamil pamil Jul 10, 2018

Choose a reason for hiding this comment

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

Ah, that's right indeed! Let's add the deprecation in an another PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@teohhanhui teohhanhui force-pushed the fix/product-fixture-images branch from d8f064e to 8630cbf Compare July 10, 2018 12:19
@teohhanhui teohhanhui force-pushed the fix/product-fixture-images branch from 8630cbf to dd45c48 Compare July 10, 2018 13:10
@pamil pamil added Potential Bug Potential bugs or bugfixes, that needs to be reproduced. and removed Potential Bug labels Jul 11, 2018
@pamil pamil merged commit a95c17b into Sylius:1.1 Jul 11, 2018
@pamil
Copy link
Copy Markdown
Contributor

pamil commented Jul 11, 2018

Thanks, Teoh! 🥇

@pamil
Copy link
Copy Markdown
Contributor

pamil commented Jul 11, 2018

Created #9581 for that deprecation addition.

@teohhanhui teohhanhui deleted the fix/product-fixture-images branch July 11, 2018 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Potential Bug Potential bugs or bugfixes, that needs to be reproduced.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants