Skip to content

Commit 0380252

Browse files
MAGETWO-68928: Fatal error after disabling module
1 parent ea57b46 commit 0380252

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

lib/internal/Magento/Framework/Console/Cli.php

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,33 @@ class Cli extends Console\Application
6666
/**
6767
* @param string $name the application name
6868
* @param string $version the application version
69+
* @SuppressWarnings(PHPMD.ExitExpression)
6970
*/
7071
public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
7172
{
72-
$configuration = require BP . '/setup/config/application.config.php';
73-
$bootstrapApplication = new Application();
74-
$application = $bootstrapApplication->bootstrap($configuration);
75-
$this->serviceManager = $application->getServiceManager();
76-
77-
$this->assertCompilerPreparation();
78-
$this->initObjectManager();
79-
$this->assertGenerationPermissions();
80-
81-
if ($version == 'UNKNOWN') {
82-
$directoryList = new DirectoryList(BP);
83-
$composerJsonFinder = new ComposerJsonFinder($directoryList);
84-
$productMetadata = new ProductMetadata($composerJsonFinder);
85-
$version = $productMetadata->getVersion();
73+
try {
74+
$configuration = require BP . '/setup/config/application.config.php';
75+
$bootstrapApplication = new Application();
76+
$application = $bootstrapApplication->bootstrap($configuration);
77+
$this->serviceManager = $application->getServiceManager();
78+
79+
$this->assertCompilerPreparation();
80+
$this->initObjectManager();
81+
$this->assertGenerationPermissions();
82+
83+
if ($version == 'UNKNOWN') {
84+
$directoryList = new DirectoryList(BP);
85+
$composerJsonFinder = new ComposerJsonFinder($directoryList);
86+
$productMetadata = new ProductMetadata($composerJsonFinder);
87+
$version = $productMetadata->getVersion();
88+
}
89+
} catch (\Exception $exception) {
90+
$output = new Console\Output\ConsoleOutput();
91+
$output->writeln(
92+
'<error>' . $exception->getMessage() . '</error>'
93+
);
94+
95+
exit(static::RETURN_FAILURE);
8696
}
8797

8898
parent::__construct($name, $version);

lib/internal/Magento/Framework/Console/Exception/GenerationDirectoryAccessException.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Framework\Exception\FileSystemException;
1010
use Magento\Framework\Phrase;
1111

12+
/**
13+
* The default exception for missing write permissions on compilation generated folder.
14+
*/
1215
class GenerationDirectoryAccessException extends FileSystemException
1316
{
1417
/**
@@ -18,7 +21,7 @@ public function __construct(Phrase $phrase = null, \Exception $cause = null, $co
1821
{
1922
$phrase = $phrase ?: new Phrase(
2023
'Command line user does not have read and write permissions on '
21-
. $this->getDefaultDirectoryPath(DirectoryList::GENERATED_CODE) . ' directory. '
24+
. $this->getDefaultDirectoryPath(DirectoryList::GENERATED) . ' directory. '
2225
. 'Please address this issue before using Magento command line.'
2326
);
2427

0 commit comments

Comments
 (0)