[ticket/16688] Fix PHP fatal errors on installing extensions via catalog

PHPBB3-16688
This commit is contained in:
rxu 2021-12-18 12:18:24 +07:00
parent 7911c9cb73
commit d4d26987e5
No known key found for this signature in database
GPG key ID: 955F0567380E586A
2 changed files with 21 additions and 1 deletions

View file

@ -152,7 +152,9 @@ class installer
{
if (!$io)
{
$this->restore_cwd();
$io = new null_io();
$this->move_to_root();
}
$this->generate_ext_json_file($packages);
@ -183,6 +185,7 @@ class installer
}
catch (\Exception $e)
{
$this->restore_cwd();
$this->restore_ext_json_file();
throw new runtime_exception('COMPOSER_CANNOT_INSTALL', [], $e);
@ -190,6 +193,7 @@ class installer
if ($result !== 0)
{
$this->restore_cwd();
$this->restore_ext_json_file();
throw new runtime_exception($io->get_composer_error(), []);

View file

@ -76,7 +76,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
$this->login();
$this->admin_login();
$this->add_lang('acp/extensions');
$this->add_lang(['acp/common', 'acp/extensions']);
}
public function test_list()
@ -264,4 +264,20 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
// Ensure catalog has any records in extensions list
$this->assertGreaterThan(0, $crawler->filter('tbody > tr > td > strong')->count());
}
public function test_extensions_catalog_installing_extension()
{
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=catalog&sid=' . $this->sid);
$this->assertContainsLang('ACP_EXTENSIONS_CATALOG', $this->get_content());
// Ensure catalog has any records in extensions list
$this->assertGreaterThan(0, $crawler->filter('tbody > tr > td > strong')->count());
// Attempt to install any extension which is 1st in the list
$extension_install_link = $crawler->filter('tbody')->selectLink($this->lang('INSTALL'))->link();
$crawler = self::$client->click($extension_install_link);
// Assert any action result is presented regardless of success
$this->assertTrue(strlen($crawler->filter('.console-output > pre')->text()) > 0, $this->get_content());
}
}