From 03b3b38db17c5fc554f54aed3f3fc1941279a04e Mon Sep 17 00:00:00 2001
From: hubaishan <saeed@hubaishan.com>
Date: Wed, 1 Nov 2017 08:48:21 +0300
Subject: [PATCH] [ticket/15433] Fix phpbbcli can enable non-existent extension

Fix phpbbcli can enable non-existent extension

PHPBB3-15433
---
 phpBB/language/en/cli.php                        | 1 +
 phpBB/phpbb/console/command/extension/enable.php | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/phpBB/language/en/cli.php b/phpBB/language/en/cli.php
index 1655855edb..505d12e8ff 100644
--- a/phpBB/language/en/cli.php
+++ b/phpBB/language/en/cli.php
@@ -117,6 +117,7 @@ $lang = array_merge($lang, array(
 	'CLI_EXTENSION_ENABLE_FAILURE'		=> 'Could not enable extension %s',
 	'CLI_EXTENSION_ENABLE_SUCCESS'		=> 'Successfully enabled extension %s',
 	'CLI_EXTENSION_ENABLED'				=> 'Extension %s is already enabled',
+	'CLI_EXTENSION_NOT_EXIST'			=> 'Extension %s does not exist',
 	'CLI_EXTENSION_NAME'				=> 'Name of the extension',
 	'CLI_EXTENSION_PURGE_FAILURE'		=> 'Could not purge extension %s',
 	'CLI_EXTENSION_PURGE_SUCCESS'		=> 'Successfully purged extension %s',
diff --git a/phpBB/phpbb/console/command/extension/enable.php b/phpBB/phpbb/console/command/extension/enable.php
index f92de0069c..a6f5b10e86 100644
--- a/phpBB/phpbb/console/command/extension/enable.php
+++ b/phpBB/phpbb/console/command/extension/enable.php
@@ -37,6 +37,13 @@ class enable extends command
 		$io = new SymfonyStyle($input, $output);
 
 		$name = $input->getArgument('extension-name');
+
+		if (!$this->manager->is_available($name))
+		{
+			$io->error($this->user->lang('CLI_EXTENSION_NOT_EXIST', $name));
+			return 1;
+		}
+
 		$extension = $this->manager->get_extension($name);
 
 		if (!$extension->is_enableable())