From 2631805b26189a589ab7ee9046c3f507838641e5 Mon Sep 17 00:00:00 2001 From: alojua Date: Thu, 23 Nov 2017 11:13:42 +0100 Subject: [PATCH 01/11] Add argument on app:config:dump to specify which types to dump. That allows to dump only scope and theme while skipping system for easier maintainability. --- .../Command/App/ApplicationDumpCommand.php | 48 ++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php b/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php index 9d13c97790fa4..c3492019455f2 100644 --- a/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php +++ b/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php @@ -12,6 +12,7 @@ use Magento\Framework\Config\File\ConfigFilePool; use Magento\Framework\Console\Cli; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -20,6 +21,18 @@ */ class ApplicationDumpCommand extends Command { + const INPUT_CONFIG_TYPES = 'config-types'; + + /** + * @var array + */ + private $configTypes = [ + \Magento\Store\App\Config\Type\Scopes::CONFIG_TYPE, + \Magento\Deploy\Source\Themes::TYPE, + \Magento\Translation\App\Config\Type\Translation::CONFIG_TYPE, + \Magento\Config\App\Config\Type\System::CONFIG_TYPE, + ]; + /** * @var Writer */ @@ -60,6 +73,12 @@ protected function configure() { $this->setName('app:config:dump'); $this->setDescription('Create dump of application'); + $this->addArgument( + self::INPUT_CONFIG_TYPES, + InputArgument::OPTIONAL | InputArgument::IS_ARRAY, + sprintf('Space-separated list of config types or omit to dump all [%s]', + implode(', ', $this->configTypes)) + ); parent::configure(); } @@ -74,11 +93,14 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { $this->groupSourcesByPool(); - + $dumpedTypes = []; foreach ($this->sources as $pool => $sources) { $dump = []; $comments = []; foreach ($sources as $sourceData) { + if ($this->skipDump($input, $sourceData)) { + continue; + } /** @var ConfigSourceInterface $source */ $source = $sourceData['source']; $namespace = $sourceData['namespace']; @@ -95,15 +117,21 @@ protected function execute(InputInterface $input, OutputInterface $output) null, $comments ); + $dumpedTypes = array_unique($dumpedTypes + array_keys($dump)); if (!empty($comments)) { $output->writeln($comments); } } + if (!$dumpedTypes) { + $output->writeln('Nothing dumped. Check the config types specified and try again'); + return Cli::RETURN_FAILURE; + } + // Generate and save new hash of deployment configuration. $this->configHash->regenerate(); - $output->writeln('Done.'); + $output->writeln(sprintf('Done. Config types dumped: %s', implode(', ', $dumpedTypes))); return Cli::RETURN_SUCCESS; } @@ -127,4 +155,20 @@ private function groupSourcesByPool() $this->sources = $sources; } + + /** + * Check whether the dump source should be skipped + * + * @param InputInterface $input + * @param array $sourceData + * @return bool + */ + private function skipDump(InputInterface $input, array $sourceData): bool + { + $allowedTypes = $input->getArgument(self::INPUT_CONFIG_TYPES); + if ($allowedTypes && !in_array($sourceData['namespace'], $allowedTypes)) { + return true; + } + return false; + } } From 8bfbc774462c92111c2d0dc1a0d92630eab7579e Mon Sep 17 00:00:00 2001 From: alojua Date: Sat, 25 Nov 2017 11:18:17 +0100 Subject: [PATCH 02/11] Fix failing tests --- .../Deploy/Console/Command/App/ApplicationDumpCommand.php | 3 +-- .../Test/Unit/Console/Command/ApplicationDumpCommandTest.php | 2 +- .../Deploy/Console/Command/App/ApplicationDumpCommandTest.php | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php b/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php index c3492019455f2..e47f534a40793 100644 --- a/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php +++ b/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php @@ -76,8 +76,7 @@ protected function configure() $this->addArgument( self::INPUT_CONFIG_TYPES, InputArgument::OPTIONAL | InputArgument::IS_ARRAY, - sprintf('Space-separated list of config types or omit to dump all [%s]', - implode(', ', $this->configTypes)) + sprintf('Space-separated list of config types or omit to dump all [%s]', implode(', ', $this->configTypes)) ); parent::configure(); } diff --git a/app/code/Magento/Deploy/Test/Unit/Console/Command/ApplicationDumpCommandTest.php b/app/code/Magento/Deploy/Test/Unit/Console/Command/ApplicationDumpCommandTest.php index 67c3796e7c6b9..85cae275932fa 100644 --- a/app/code/Magento/Deploy/Test/Unit/Console/Command/ApplicationDumpCommandTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Console/Command/ApplicationDumpCommandTest.php @@ -130,7 +130,7 @@ public function testExport() ->method('writeln') ->withConsecutive( [['system' => 'Some comment message']], - ['Done.'] + ['Done. Config types dumped: system'] ); $method = new \ReflectionMethod(ApplicationDumpCommand::class, 'execute'); diff --git a/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php b/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php index cb40b110f5fc6..5602e77eb702c 100644 --- a/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php @@ -176,7 +176,7 @@ public function testExecute() ->with(['system' => $comment]); $outputMock->expects($this->at(1)) ->method('writeln') - ->with('Done.'); + ->with('Done. Config types dumped: scopes, themes, system, i18n'); /** @var ApplicationDumpCommand command */ $command = $this->objectManager->create(ApplicationDumpCommand::class); From d3c53f847b05502c39c3ada06671627c9bfa82ef Mon Sep 17 00:00:00 2001 From: alojua Date: Tue, 28 Nov 2017 09:30:39 +0100 Subject: [PATCH 03/11] Remove hard dependencies to set configTypes and get them dynamically instead --- .../Command/App/ApplicationDumpCommand.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php b/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php index e47f534a40793..4eb965b21d53a 100644 --- a/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php +++ b/app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php @@ -23,16 +23,6 @@ class ApplicationDumpCommand extends Command { const INPUT_CONFIG_TYPES = 'config-types'; - /** - * @var array - */ - private $configTypes = [ - \Magento\Store\App\Config\Type\Scopes::CONFIG_TYPE, - \Magento\Deploy\Source\Themes::TYPE, - \Magento\Translation\App\Config\Type\Translation::CONFIG_TYPE, - \Magento\Config\App\Config\Type\System::CONFIG_TYPE, - ]; - /** * @var Writer */ @@ -60,10 +50,10 @@ public function __construct( array $sources, Hash $configHash = null ) { - parent::__construct(); $this->writer = $writer; $this->sources = $sources; $this->configHash = $configHash ?: ObjectManager::getInstance()->get(Hash::class); + parent::__construct(); } /** @@ -73,10 +63,12 @@ protected function configure() { $this->setName('app:config:dump'); $this->setDescription('Create dump of application'); + + $configTypes = array_unique(array_column($this->sources, 'namespace')); $this->addArgument( self::INPUT_CONFIG_TYPES, InputArgument::OPTIONAL | InputArgument::IS_ARRAY, - sprintf('Space-separated list of config types or omit to dump all [%s]', implode(', ', $this->configTypes)) + sprintf('Space-separated list of config types or omit to dump all [%s]', implode(', ', $configTypes)) ); parent::configure(); } From 0cbf318c2b82e1a54162b75f293003754874ac30 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Thu, 26 Apr 2018 10:54:39 +0300 Subject: [PATCH 04/11] magento/magento2#14807: Fixed integration test fail --- .../Deploy/Console/Command/App/ApplicationDumpCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php b/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php index 5602e77eb702c..7a09d0cf131c6 100644 --- a/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php @@ -176,7 +176,7 @@ public function testExecute() ->with(['system' => $comment]); $outputMock->expects($this->at(1)) ->method('writeln') - ->with('Done. Config types dumped: scopes, themes, system, i18n'); + ->with('Done. Config types dumped: scopes, system, themes, i18n'); /** @var ApplicationDumpCommand command */ $command = $this->objectManager->create(ApplicationDumpCommand::class); From 5c4c91cbcfc2b5fb776c4f3214d15e8b199c8db8 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Thu, 26 Apr 2018 11:48:20 +0300 Subject: [PATCH 05/11] ENGCOM-1360: [Forwardport] Add argument on app:config:dump to skip dumping all system settings. #14807 --- .../Deploy/Console/Command/App/ApplicationDumpCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php b/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php index 7a09d0cf131c6..c4551ac49d156 100644 --- a/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php +++ b/dev/tests/integration/testsuite/Magento/Deploy/Console/Command/App/ApplicationDumpCommandTest.php @@ -176,7 +176,7 @@ public function testExecute() ->with(['system' => $comment]); $outputMock->expects($this->at(1)) ->method('writeln') - ->with('Done. Config types dumped: scopes, system, themes, i18n'); + ->with($this->matchesRegularExpression('/Done. Config types dumped: [a-z0-9,\s]+<\/info>/')); /** @var ApplicationDumpCommand command */ $command = $this->objectManager->create(ApplicationDumpCommand::class); From 0abb68250cd1b8ed94bcda557b1ec4b2849e2969 Mon Sep 17 00:00:00 2001 From: Riccardo Tempesta Date: Sat, 28 Apr 2018 21:49:49 +0200 Subject: [PATCH 06/11] Fix issue #14895 - Change Password warning message appear two times The password change notice was a sticky message activated by admin_user_authenticate_after event. The password change page requires the current user password and thus triggering admin_user_authenticate_after while saving. One message was added every time the user was saved. --- app/code/Magento/User/Model/User.php | 2 ++ app/code/Magento/User/Observer/Backend/AuthObserver.php | 8 ++++++-- .../Observer/Backend/TrackAdminNewPasswordObserver.php | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/User/Model/User.php b/app/code/Magento/User/Model/User.php index a5dd6ac2e7813..29618c981a2b9 100644 --- a/app/code/Magento/User/Model/User.php +++ b/app/code/Magento/User/Model/User.php @@ -48,6 +48,8 @@ class User extends AbstractModel implements StorageInterface, UserInterface /** @deprecated */ const XML_PATH_RESET_PASSWORD_TEMPLATE = 'admin/emails/reset_password_template'; + const MESSAGE_ID_PASSWORD_EXPIRED = 'magento_user_password_expired'; + /** * Model event prefix * diff --git a/app/code/Magento/User/Observer/Backend/AuthObserver.php b/app/code/Magento/User/Observer/Backend/AuthObserver.php index 6021302a5aeb7..feffdcee31f76 100644 --- a/app/code/Magento/User/Observer/Backend/AuthObserver.php +++ b/app/code/Magento/User/Observer/Backend/AuthObserver.php @@ -152,7 +152,7 @@ public function execute(EventObserver $observer) /** * Update locking information for the user * - * @param \Magento\User\Model\User $user + * @param User $user * @return void */ private function _updateLockingInformation($user) @@ -198,10 +198,14 @@ private function _checkExpiredPassword($latestPassword) $myAccountUrl = $this->url->getUrl('adminhtml/system_account/'); $message = __('It\'s time to change your password.', $myAccountUrl); } + + // Avoid duplicating the message + $this->messageManager->getMessages()->deleteMessageByIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED); + $this->messageManager->addNoticeMessage($message); $message = $this->messageManager->getMessages()->getLastAddedMessage(); if ($message) { - $message->setIdentifier('magento_user_password_expired')->setIsSticky(true); + $message->setIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED)->setIsSticky(true); $this->authSession->setPciAdminUserIsPasswordExpired(true); } } diff --git a/app/code/Magento/User/Observer/Backend/TrackAdminNewPasswordObserver.php b/app/code/Magento/User/Observer/Backend/TrackAdminNewPasswordObserver.php index 09605372df181..059879ab9613f 100644 --- a/app/code/Magento/User/Observer/Backend/TrackAdminNewPasswordObserver.php +++ b/app/code/Magento/User/Observer/Backend/TrackAdminNewPasswordObserver.php @@ -8,6 +8,7 @@ use Magento\Framework\Event\Observer as EventObserver; use Magento\Framework\Event\ObserverInterface; +use Magento\User\Model\User; /** * User backend observer model for passwords @@ -74,7 +75,7 @@ public function execute(EventObserver $observer) $passwordHash = $user->getPassword(); if ($passwordHash && !$user->getForceNewPassword()) { $this->userResource->trackPassword($user, $passwordHash); - $this->messageManager->getMessages()->deleteMessageByIdentifier('magento_user_password_expired'); + $this->messageManager->getMessages()->deleteMessageByIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED); $this->authSession->unsPciAdminUserIsPasswordExpired(); } } From 8d8706efe5330a62217603bfea8ee511ae138bd5 Mon Sep 17 00:00:00 2001 From: Riccardo Tempesta Date: Sun, 29 Apr 2018 17:26:18 +0200 Subject: [PATCH 07/11] Single call for getMessages() app/code/Magento/User/Test/Unit/Observer/Backend/AuthObserverTest.php is checking for a single getMessages() call --- app/code/Magento/User/Observer/Backend/AuthObserver.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/User/Observer/Backend/AuthObserver.php b/app/code/Magento/User/Observer/Backend/AuthObserver.php index feffdcee31f76..06b15a477d84d 100644 --- a/app/code/Magento/User/Observer/Backend/AuthObserver.php +++ b/app/code/Magento/User/Observer/Backend/AuthObserver.php @@ -199,11 +199,13 @@ private function _checkExpiredPassword($latestPassword) $message = __('It\'s time to change your password.', $myAccountUrl); } - // Avoid duplicating the message - $this->messageManager->getMessages()->deleteMessageByIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED); + $messages = $this->messageManager->getMessages(); + + // Remove existing messages with same ID to avoid duplication + $messages->deleteMessageByIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED); $this->messageManager->addNoticeMessage($message); - $message = $this->messageManager->getMessages()->getLastAddedMessage(); + $message = $messages->getLastAddedMessage(); if ($message) { $message->setIdentifier(User::MESSAGE_ID_PASSWORD_EXPIRED)->setIsSticky(true); $this->authSession->setPciAdminUserIsPasswordExpired(true); From 0b859217153c9b1ef97a0392166d76272d5a2ac8 Mon Sep 17 00:00:00 2001 From: James Halsall Date: Mon, 23 Apr 2018 15:15:45 +0100 Subject: [PATCH 08/11] Add default schedule config for sitemap_generate job --- app/code/Magento/Sitemap/Model/Observer.php | 10 +++++----- app/code/Magento/Sitemap/etc/config.xml | 11 +++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Sitemap/Model/Observer.php b/app/code/Magento/Sitemap/Model/Observer.php index 840a6a1858fae..755b858398c95 100644 --- a/app/code/Magento/Sitemap/Model/Observer.php +++ b/app/code/Magento/Sitemap/Model/Observer.php @@ -17,11 +17,6 @@ class Observer */ const XML_PATH_GENERATION_ENABLED = 'sitemap/generate/enabled'; - /** - * Cronjob expression configuration - */ - const XML_PATH_CRON_EXPR = 'crontab/default/jobs/generate_sitemaps/schedule/cron_expr'; - /** * Error email template configuration */ @@ -64,6 +59,11 @@ class Observer */ protected $inlineTranslation; + /** + * @var \Magento\Cron\Model\ScheduleFactory + */ + private $scheduleFactory; + /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Sitemap\Model\ResourceModel\Sitemap\CollectionFactory $collectionFactory diff --git a/app/code/Magento/Sitemap/etc/config.xml b/app/code/Magento/Sitemap/etc/config.xml index 73468baadcb90..6f14ff728ac4f 100644 --- a/app/code/Magento/Sitemap/etc/config.xml +++ b/app/code/Magento/Sitemap/etc/config.xml @@ -42,5 +42,16 @@ + + + + + + 0 0 * * * + + + + + From 01f6fc21a691923663faafdc5e8e1df1073d3f23 Mon Sep 17 00:00:00 2001 From: James Halsall Date: Tue, 24 Apr 2018 12:06:38 +0100 Subject: [PATCH 09/11] Cleanup --- app/code/Magento/Sitemap/Model/Observer.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/code/Magento/Sitemap/Model/Observer.php b/app/code/Magento/Sitemap/Model/Observer.php index 755b858398c95..c3eb34602e94c 100644 --- a/app/code/Magento/Sitemap/Model/Observer.php +++ b/app/code/Magento/Sitemap/Model/Observer.php @@ -59,11 +59,6 @@ class Observer */ protected $inlineTranslation; - /** - * @var \Magento\Cron\Model\ScheduleFactory - */ - private $scheduleFactory; - /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Sitemap\Model\ResourceModel\Sitemap\CollectionFactory $collectionFactory From a324f86feb372a52b6b8bacf470639c8fd6d77a9 Mon Sep 17 00:00:00 2001 From: James Halsall Date: Tue, 24 Apr 2018 16:04:46 +0100 Subject: [PATCH 10/11] Fixup --- app/code/Magento/Sitemap/Model/Observer.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/code/Magento/Sitemap/Model/Observer.php b/app/code/Magento/Sitemap/Model/Observer.php index c3eb34602e94c..a536ec998b827 100644 --- a/app/code/Magento/Sitemap/Model/Observer.php +++ b/app/code/Magento/Sitemap/Model/Observer.php @@ -17,6 +17,13 @@ class Observer */ const XML_PATH_GENERATION_ENABLED = 'sitemap/generate/enabled'; + /** + * Cronjob expression configuration + * + * @deprecated Use \Magento\Cron\Model\Config\Backend\Sitemap::CRON_STRING_PATH instead. + */ + const XML_PATH_CRON_EXPR = 'crontab/default/jobs/generate_sitemaps/schedule/cron_expr'; + /** * Error email template configuration */ From aa99c01f30b382d73128901058c4aeac533d5a70 Mon Sep 17 00:00:00 2001 From: Jeroen Date: Tue, 1 May 2018 18:30:05 +0200 Subject: [PATCH 11/11] Move customer.account.dashboard.info.extra block to contact information --- .../view/frontend/templates/account/dashboard/info.phtml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/Magento/Customer/view/frontend/templates/account/dashboard/info.phtml b/app/code/Magento/Customer/view/frontend/templates/account/dashboard/info.phtml index 7881b7e857fd9..ac8e1298b29b9 100644 --- a/app/code/Magento/Customer/view/frontend/templates/account/dashboard/info.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/account/dashboard/info.phtml @@ -20,6 +20,7 @@ escapeHtml($block->getName()) ?>
escapeHtml($block->getCustomer()->getEmail()) ?>

+ getChildHtml('customer.account.dashboard.info.extra'); ?>