Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion contribution/style/demo/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class manager
/** @var \phpbb\db\db_interface */
protected $db;

/** @var string */
protected $table_prefix;

/** @var int */
protected $branch;

Expand Down Expand Up @@ -151,9 +154,18 @@ protected function perform_action($action)

$hook_url = $this->ext_config->demo_style_hook[$this->branch];
$context = stream_context_create($options);
$result = file_get_contents($hook_url, false, $context, 0, 50);
// A failing hook must degrade to an error result; the warning would
// otherwise be turned into an exception and lose the JSON reply.
$result = @file_get_contents($hook_url, false, $context, 0, 50);
$this->delete_auth_key($key);
Comment thread
ECYaz marked this conversation as resolved.

if ($result === false)
{
return array(
'id' => 0,
'error' => $this->user->lang('UNKNOWN_ERROR'),
);
}
return $this->get_result($result);
}

Expand Down
22 changes: 15 additions & 7 deletions contribution/style/type.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,25 @@ public function install_demo(\titania_contribution $contrib, \titania_revision $

$demo_url = '';

if ($this->demo_manager->configure($branch, $contrib, $package))
// A demo failure must not abort the approval or the AJAX reply.
try
{
$result = $this->demo_manager->install();

if (empty($result['error']))
if ($this->demo_manager->configure($branch, $contrib, $package))
{
$demo_url = $this->demo_manager->get_demo_url($branch, $result['id']);
$contrib->set_demo_url($branch, $demo_url);
$contrib->submit();
$result = $this->demo_manager->install();

if (empty($result['error']))
{
$demo_url = $this->demo_manager->get_demo_url($branch, $result['id']);
$contrib->set_demo_url($branch, $demo_url);
$contrib->submit();
}
}
}
catch (\Throwable $e)
{
$demo_url = '';
}
$package->cleanup();

return $demo_url;
Expand Down
8 changes: 8 additions & 0 deletions controller/contribution/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,14 @@ protected function install_demo($branch)
$revision->__set_array($this->contrib->download[$branch]);
$demo_url = $this->contrib->type->install_demo($this->contrib, $revision);
}

if ($demo_url === '')
{
return array(
'MESSAGE_TITLE' => $this->user->lang('INFORMATION'),
'MESSAGE_TEXT' => $this->user->lang('DEMO_INSTALL_FAILED'),
);
}
return array(
'url' => $demo_url,
);
Expand Down
1 change: 1 addition & 0 deletions language/en/contributions.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
'DELETE_CONTRIBUTION_EXPLAIN' => 'Permanently remove this contribution (use the contribution status field if you need to hide it).',
'DELETE_REVISION' => 'Delete Revision',
'DELETE_REVISION_EXPLAIN' => 'Permanently remove this revision (use the revision status field if you need to hide it).',
'DEMO_INSTALL_FAILED' => 'The style could not be installed on the demo board.',
'DEMO_URL' => 'Demo URL',
'DEMO_URL_EXPLAIN' => 'Location of the demonstration',
'DEPENDENCIES' => 'Dependencies',
Expand Down
6 changes: 6 additions & 0 deletions misc/style_demo_hooks/phpBB_3.3.x/style_demo_install.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
include($phpbb_root_path . 'includes/style_demo_manager.' . $phpEx);
include($phpbb_root_path . 'includes/style_demo_hook.' . $phpEx);

// acp_styles logs the installation and reads the user's id and ip from the
// session, so one has to exist before the manager runs.
$user->session_begin();
$auth->acl($user->data);
$user->setup();

$hook = new \titania_style_demo_hook($config, $db, $user, $phpbb_root_path, $phpEx);
$result = $hook->run($request->variable('key', ''));

Expand Down
3 changes: 3 additions & 0 deletions misc/style_demo_hooks/style_demo_hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class titania_style_demo_hook
/** @var string */
protected $php_ext;

/** @var titania_demo_manager */
protected $manager;

/**
* Constructor.
*
Expand Down