mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 12:28:52 +00:00
Merge pull request #6350 from rxu/ticket/16688
[ticket/16688] Fix PHP fatal errors on installing extensions via catalog
This commit is contained in:
commit
f7538e7d37
5 changed files with 127 additions and 15 deletions
|
@ -60,7 +60,7 @@
|
||||||
<td style="text-align: center;"><a href="{enabled.U_DETAILS}">{L_DETAILS}</a></td>
|
<td style="text-align: center;"><a href="{enabled.U_DETAILS}">{L_DETAILS}</a></td>
|
||||||
<td style="text-align: center;">
|
<td style="text-align: center;">
|
||||||
<!-- BEGIN actions -->
|
<!-- BEGIN actions -->
|
||||||
<a href="{enabled.actions.U_ACTION}"<!-- IF enabled.actions.L_ACTION_EXPLAIN --> title="{enabled.actions.L_ACTION_EXPLAIN}"<!-- ENDIF -->>{enabled.actions.L_ACTION}</a>
|
<a href="{enabled.actions.U_ACTION}"<!-- IF enabled.actions.ACTION == 'REMOVE' --> style="color: #bc2a4d;"<!-- ENDIF --><!-- IF enabled.actions.L_ACTION_EXPLAIN --> title="{enabled.actions.L_ACTION_EXPLAIN}"<!-- ENDIF -->>{enabled.actions.L_ACTION}</a>
|
||||||
<!-- IF not enabled.actions.S_LAST_ROW --> | <!-- ENDIF -->
|
<!-- IF not enabled.actions.S_LAST_ROW --> | <!-- ENDIF -->
|
||||||
<!-- END actions -->
|
<!-- END actions -->
|
||||||
</td>
|
</td>
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align: center;">
|
<td style="text-align: center;">
|
||||||
<!-- BEGIN actions -->
|
<!-- BEGIN actions -->
|
||||||
<a href="{disabled.actions.U_ACTION}"<!-- IF disabled.actions.L_ACTION_EXPLAIN --> title="{disabled.actions.L_ACTION_EXPLAIN}"<!-- ENDIF -->>{disabled.actions.L_ACTION}</a>
|
<a href="{disabled.actions.U_ACTION}"<!-- IF disabled.actions.ACTION == 'REMOVE' --> style="color: #bc2a4d;"<!-- ENDIF --><!-- IF disabled.actions.L_ACTION_EXPLAIN --> title="{disabled.actions.L_ACTION_EXPLAIN}"<!-- ENDIF -->>{disabled.actions.L_ACTION}</a>
|
||||||
<!-- IF not disabled.actions.S_LAST_ROW --> | <!-- ENDIF -->
|
<!-- IF not disabled.actions.S_LAST_ROW --> | <!-- ENDIF -->
|
||||||
<!-- END actions -->
|
<!-- END actions -->
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -838,10 +838,7 @@ class acp_extensions
|
||||||
{
|
{
|
||||||
$this->output_actions('enabled', [
|
$this->output_actions('enabled', [
|
||||||
'UPDATE' => $this->u_catalog_action . '&action=update&extension=' . urlencode($block_vars['META_NAME']),
|
'UPDATE' => $this->u_catalog_action . '&action=update&extension=' . urlencode($block_vars['META_NAME']),
|
||||||
'REMOVE' => [
|
'REMOVE' => $this->u_catalog_action . '&action=remove&extension=' . urlencode($block_vars['META_NAME']),
|
||||||
'url' => $this->u_catalog_action . '&action=remove&extension=' . urlencode($block_vars['META_NAME']),
|
|
||||||
'color' => '#BC2A4D;',
|
|
||||||
]
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -922,10 +919,7 @@ class acp_extensions
|
||||||
{
|
{
|
||||||
$this->output_actions('disabled', [
|
$this->output_actions('disabled', [
|
||||||
'UPDATE' => $this->u_catalog_action . '&action=update&extension=' . urlencode($block_vars['META_NAME']),
|
'UPDATE' => $this->u_catalog_action . '&action=update&extension=' . urlencode($block_vars['META_NAME']),
|
||||||
'REMOVE' => [
|
'REMOVE' => $this->u_catalog_action . '&action=remove&extension=' . urlencode($block_vars['META_NAME']),
|
||||||
'url' => $this->u_catalog_action . '&action=remove&extension=' . urlencode($block_vars['META_NAME']),
|
|
||||||
'color' => '#BC2A4D;',
|
|
||||||
]
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -997,6 +991,7 @@ class acp_extensions
|
||||||
|
|
||||||
$this->output_actions('disabled', array(
|
$this->output_actions('disabled', array(
|
||||||
'ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . urlencode($name),
|
'ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . urlencode($name),
|
||||||
|
'REMOVE' => $this->u_catalog_action . '&action=remove&extension=' . urlencode($block_vars['META_NAME']),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1009,11 +1004,12 @@ class acp_extensions
|
||||||
*/
|
*/
|
||||||
private function output_actions($block, $actions)
|
private function output_actions($block, $actions)
|
||||||
{
|
{
|
||||||
foreach ($actions as $lang => $url)
|
foreach ($actions as $action => $url)
|
||||||
{
|
{
|
||||||
$this->template->assign_block_vars($block . '.actions', [
|
$this->template->assign_block_vars($block . '.actions', [
|
||||||
'L_ACTION' => $this->user->lang('EXTENSION_' . $lang),
|
'ACTION' => $action,
|
||||||
'L_ACTION_EXPLAIN' => (isset($this->user->lang['EXTENSION_' . $lang . '_EXPLAIN'])) ? $this->user->lang('EXTENSION_' . $lang . '_EXPLAIN') : '',
|
'L_ACTION' => $this->user->lang('EXTENSION_' . $action),
|
||||||
|
'L_ACTION_EXPLAIN' => (isset($this->user->lang['EXTENSION_' . $action . '_EXPLAIN'])) ? $this->user->lang('EXTENSION_' . $action . '_EXPLAIN') : '',
|
||||||
'U_ACTION' => $url,
|
'U_ACTION' => $url,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,9 @@ class installer
|
||||||
{
|
{
|
||||||
if (!$io)
|
if (!$io)
|
||||||
{
|
{
|
||||||
|
$this->restore_cwd();
|
||||||
$io = new null_io();
|
$io = new null_io();
|
||||||
|
$this->move_to_root();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->generate_ext_json_file($packages);
|
$this->generate_ext_json_file($packages);
|
||||||
|
@ -184,6 +186,7 @@ class installer
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
$this->restore_ext_json_file();
|
$this->restore_ext_json_file();
|
||||||
|
$this->restore_cwd();
|
||||||
|
|
||||||
throw new runtime_exception('COMPOSER_CANNOT_INSTALL', [], $e);
|
throw new runtime_exception('COMPOSER_CANNOT_INSTALL', [], $e);
|
||||||
}
|
}
|
||||||
|
@ -191,6 +194,7 @@ class installer
|
||||||
if ($result !== 0)
|
if ($result !== 0)
|
||||||
{
|
{
|
||||||
$this->restore_ext_json_file();
|
$this->restore_ext_json_file();
|
||||||
|
$this->restore_cwd();
|
||||||
|
|
||||||
throw new runtime_exception($io->get_composer_error(), []);
|
throw new runtime_exception($io->get_composer_error(), []);
|
||||||
}
|
}
|
||||||
|
@ -587,6 +591,7 @@ class installer
|
||||||
$repositories[] = [
|
$repositories[] = [
|
||||||
'type' => 'composer',
|
'type' => 'composer',
|
||||||
'url' => $repository,
|
'url' => $repository,
|
||||||
|
'canonical' => $this->packagist ? false : true,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ class manager implements manager_interface
|
||||||
$managed_packages = array_merge($this->get_all_managed_packages(), $packages);
|
$managed_packages = array_merge($this->get_all_managed_packages(), $packages);
|
||||||
ksort($managed_packages);
|
ksort($managed_packages);
|
||||||
|
|
||||||
$this->installer->install($managed_packages, array_keys($packages), $io);
|
$this->installer->install($managed_packages, [], $io);
|
||||||
|
|
||||||
$this->post_install($packages, $io);
|
$this->post_install($packages, $io);
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
|
||||||
$this->login();
|
$this->login();
|
||||||
$this->admin_login();
|
$this->admin_login();
|
||||||
|
|
||||||
$this->add_lang('acp/extensions');
|
$this->add_lang(['acp/common', 'acp/extensions']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_list()
|
public function test_list()
|
||||||
|
@ -254,6 +254,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
|
||||||
|
|
||||||
$form = $crawler->selectButton('Submit')->form();
|
$form = $crawler->selectButton('Submit')->form();
|
||||||
$form['minimum_stability']->select('dev');
|
$form['minimum_stability']->select('dev');
|
||||||
|
$form['repositories'] = 'https://satis.phpbb.com/';
|
||||||
$crawler = self::submit($form);
|
$crawler = self::submit($form);
|
||||||
$this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('div[class="successbox"] > p')->text());
|
$this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('div[class="successbox"] > p')->text());
|
||||||
|
|
||||||
|
@ -264,4 +265,114 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
|
||||||
// Ensure catalog has any records in extensions list
|
// Ensure catalog has any records in extensions list
|
||||||
$this->assertGreaterThan(0, $crawler->filter('tbody > tr > td > strong')->count());
|
$this->assertGreaterThan(0, $crawler->filter('tbody > tr > td > strong')->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_extensions_catalog_installing_extension()
|
||||||
|
{
|
||||||
|
// Lets check page 6 where 'Scroll Page' and 'Scroll To Top' should be listed
|
||||||
|
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=catalog&start=100&sid=' . $this->sid);
|
||||||
|
$this->assertContainsLang('ACP_EXTENSIONS_CATALOG', $this->get_content());
|
||||||
|
|
||||||
|
// Get Install links for both extensions
|
||||||
|
$scrollpage_install_link = $crawler->filter('tr')->reduce(
|
||||||
|
function ($node, $i)
|
||||||
|
{
|
||||||
|
return (bool) (strpos($node->text(), 'Scroll Page') !== false);
|
||||||
|
}
|
||||||
|
)->selectLink($this->lang('INSTALL'))->link();
|
||||||
|
|
||||||
|
$scrolltotop_install_link = $crawler->filter('tr')->reduce(
|
||||||
|
function ($node, $i)
|
||||||
|
{
|
||||||
|
return (bool) (strpos($node->text(), 'Scroll To Top') !== false);
|
||||||
|
}
|
||||||
|
)->selectLink($this->lang('INSTALL'))->link();
|
||||||
|
|
||||||
|
// Attempt to install vse/scrollpage extension
|
||||||
|
$crawler = self::$client->click($scrollpage_install_link);
|
||||||
|
$this->assertContainsLang('EXTENSIONS_INSTALLED', $crawler->filter('.successbox > p')->text());
|
||||||
|
// Assert there's console log output
|
||||||
|
$this->assertStringContainsString('Installing vse/scrollpage', $crawler->filter('.console-output > pre')->text());
|
||||||
|
|
||||||
|
// Attempt to install vse/scrolltotop extension
|
||||||
|
$crawler = self::$client->click($scrolltotop_install_link);
|
||||||
|
$this->assertContainsLang('EXTENSIONS_INSTALLED', $crawler->filter('.successbox > p')->text());
|
||||||
|
// Assert there's console log output
|
||||||
|
$this->assertStringContainsString('Installing vse/scrolltotop', $crawler->filter('.console-output > pre')->text());
|
||||||
|
|
||||||
|
// Ensure installed extension appears in available extensions list
|
||||||
|
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
|
||||||
|
$this->assertStringContainsString('Scroll To Top', $crawler->filter('strong[title="vse/scrolltotop"]')->text());
|
||||||
|
$this->assertStringContainsString('Scroll Page', $crawler->filter('strong[title="vse/scrollpage"]')->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_extensions_catalog_updating_extension()
|
||||||
|
{
|
||||||
|
// Enable 'Scroll Page' extension installed earlier
|
||||||
|
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
|
||||||
|
$extension_enable_link = $crawler->filter('tr')->reduce(
|
||||||
|
function ($node, $i)
|
||||||
|
{
|
||||||
|
return (bool) (strpos($node->text(), 'Scroll Page') !== false);
|
||||||
|
}
|
||||||
|
)->selectLink($this->lang('EXTENSION_ENABLE'))->link();
|
||||||
|
$crawler = self::$client->click($extension_enable_link);
|
||||||
|
$form = $crawler->selectButton($this->lang('EXTENSION_ENABLE'))->form();
|
||||||
|
$crawler = self::submit($form);
|
||||||
|
$this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('.successbox')->text());
|
||||||
|
|
||||||
|
// Update 'Scroll Page' enabled extension
|
||||||
|
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
|
||||||
|
$scrollpage_update_link = $crawler->filter('tr')->reduce(
|
||||||
|
function ($node, $i)
|
||||||
|
{
|
||||||
|
return (bool) (strpos($node->text(), 'Scroll Page') !== false);
|
||||||
|
}
|
||||||
|
)->selectLink($this->lang('EXTENSION_UPDATE'))->link();
|
||||||
|
$crawler = self::$client->click($scrollpage_update_link);
|
||||||
|
$this->assertContainsLang('EXTENSIONS_UPDATED', $crawler->filter('.successbox > p')->text());
|
||||||
|
// Assert there's console log output
|
||||||
|
$this->assertStringContainsString('Updating packages', $crawler->filter('.console-output > pre')->text());
|
||||||
|
|
||||||
|
// Ensure installed extension still appears in available extensions list
|
||||||
|
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
|
||||||
|
$this->assertStringContainsString('Scroll Page', $crawler->filter('strong[title="vse/scrollpage"]')->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_extensions_catalog_removing_extension()
|
||||||
|
{
|
||||||
|
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
|
||||||
|
|
||||||
|
// Check if both enabled and disabled extensions have 'Remove' action available
|
||||||
|
$scrollpage_remove_link = $crawler->filter('tr')->reduce(
|
||||||
|
function ($node, $i)
|
||||||
|
{
|
||||||
|
return (bool) (strpos($node->text(), 'Scroll Page') !== false);
|
||||||
|
}
|
||||||
|
)->selectLink($this->lang('EXTENSION_REMOVE'))->link();
|
||||||
|
|
||||||
|
$scrolltotop_remove_link = $crawler->filter('tr')->reduce(
|
||||||
|
function ($node, $i)
|
||||||
|
{
|
||||||
|
return (bool) (strpos($node->text(), 'Scroll To Top') !== false);
|
||||||
|
}
|
||||||
|
)->selectLink($this->lang('EXTENSION_REMOVE'))->link();
|
||||||
|
|
||||||
|
// Test extensions removal
|
||||||
|
// Remove 'Scroll Page' enabled extension
|
||||||
|
$crawler = self::$client->click($scrollpage_remove_link);
|
||||||
|
$this->assertContainsLang('EXTENSIONS_REMOVED', $crawler->filter('.successbox > p')->text());
|
||||||
|
// Assert there's console log output
|
||||||
|
$this->assertStringContainsString('Deleting ext/vse/scrollpage', $crawler->filter('.console-output > pre')->text());
|
||||||
|
|
||||||
|
// Remove 'Scroll To Top' disabled extension
|
||||||
|
$crawler = self::$client->click($scrolltotop_remove_link);
|
||||||
|
$this->assertContainsLang('EXTENSIONS_REMOVED', $crawler->filter('.successbox > p')->text());
|
||||||
|
// Assert there's console log output
|
||||||
|
$this->assertStringContainsString('Deleting ext/vse/scrolltotop', $crawler->filter('.console-output > pre')->text());
|
||||||
|
|
||||||
|
// Ensure removed extensions do not appear in available extensions list
|
||||||
|
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
|
||||||
|
$this->assertStringNotContainsString('Scroll Page', $this->get_content());
|
||||||
|
$this->assertStringNotContainsString('Scroll To Top', $this->get_content());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue