-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Fixed issue #19481: After composer installation sample data can't be installed from command line #27481
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
Fixed issue #19481: After composer installation sample data can't be installed from command line #27481
Conversation
… sampledata can't be installed from command line
Hi @andrewbess. Thank you for your contribution
For more details, please, review the Magento Contributor Guide documentation. |
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.
There's just a minor change + code lint that is going to be detected by Static Tests.
Logic and the approach is - in my opinion - correct. Especially taking into consideration additional notice about missing version
node.
$rootJson = json_decode( | ||
$this->filesystem->getDirectoryRead( | ||
DirectoryList::ROOT | ||
)->readFile("composer.json") | ||
); |
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.
Could you use Json Serializer from Magento package?
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.
Hello @lbajsarowicz
Thank you for your review.
I fixed it. Please check.
Thank you in advance.
$output->writeln('<info>' . 'Git installations must deploy sample data from GitHub; see https://devdocs.magento.com/guides/v2.3/install-gde/install/sample-data-after-clone.html for more information.' . '</info>'); | ||
return; | ||
$magentoProductPackage = array_filter( | ||
(array) $rootJson->require, |
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.
I'm not sure if you linted your code properly (let's wait for Static tests)
Hi @lbajsarowicz, thank you for the review.
|
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 only issue I see is the serializer interface. That should be explicit JSON
, as Magento is going to - sooner or later - replace the serializer preference.
*/ | ||
public function __construct( | ||
Filesystem $filesystem, | ||
Dependency $sampleDataDependency, | ||
ArrayInputFactory $arrayInputFactory, | ||
ApplicationFactory $applicationFactory | ||
ApplicationFactory $applicationFactory, | ||
SerializerInterface $serializer |
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.
I think Magento is not the guy you'd like to trust when it comes to Serializer interface :-P
Use the one \Magento\Framework\Serialize\Serializer\Json
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.
Hello @lbajsarowicz
Thank you for your review.
I changed SerializerInterface to Serializer\Json. Please check.
Thank you in advance.
return [ | ||
'command' => 'config', | ||
'setting-key' => 'version', | ||
'setting-value' => ['0.0.1'], | ||
'--quiet' => 1 | ||
]; |
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 can be just private const STUB_EXPECTED_COMPOSER_CONFIG
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.
Hello @lbajsarowicz
Thank you for your review.
I fixed it. Please check.
Thank you in advance.
Hi @lbajsarowicz, thank you for the review.
|
6bbeb54
to
05b1190
Compare
* @return void | ||
*/ | ||
private function updateMemoryLimit() | ||
{ | ||
if (function_exists('ini_set')) { | ||
@ini_set('display_errors', 1); |
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.
Hello @lbajsarowicz
I changed @ini_set
to ini_alter
(that's the alias of ini_set) and added throwing an exception when ini_set returns an error.
Please check it.
Thank you in advance.
* @return void | ||
*/ | ||
private function updateMemoryLimit() | ||
{ | ||
if (function_exists('ini_set')) { | ||
@ini_set('display_errors', 1); |
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.
Please use // phpcs:ignore Magento2.Functions.DiscouragedFunction
for the legacy code. ini_alter
should be added to the discouraged list as well https://github.com/magento/magento-coding-standard/blob/develop/Magento2/Sniffs/Functions/DiscouragedFunctionSniff.php
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.
Hello @lenaorobei
Thank you for your remark.
I have reverted ini_alter to ini_set (without @
).
Also, today I am going to add all alias to discouraged functions
Hi @slavvka, thank you for the review. |
@magento run all tests |
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.
My mistake
Hi @slavvka, thank you for the review. |
…ata can't be installed from command line #27481
Hi @andrewbess, thank you for your contribution! |
Description (*)
This PR fixes the problem when sample data aren't deploying if the field "version" has removed from composer.json.
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
bin/magento sampledata:deploy
Actual result
Result after fix
The field "version" has been restored in
composer.json
;The sample data have been deployed successfully.
Questions or comments
Contribution checklist (*)