Skip to content

Commit

Permalink
Issue CollaboraOnline#56: Throw exception directly from getDiscovery().
Browse files Browse the repository at this point in the history
  • Loading branch information
donquixote committed Nov 12, 2024
1 parent 1b02a0e commit 3968fa7
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/Cool/CoolRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ public function __construct(
*/
public function getWopiClientURL(): string {
$discovery = $this->getDiscovery();
if ($discovery === FALSE) {
throw new CoolRequestException(
'Not able to retrieve the discovery.xml file from the Collabora Online server.',
203,
);
}

$discovery_parsed = simplexml_load_string($discovery);
if (!$discovery_parsed) {
Expand Down Expand Up @@ -118,15 +112,21 @@ protected function getWopiClientServerBaseUrl(): string {
/**
* Gets the contents of discovery.xml from the Collabora server.
*
* @return string|false
* The full contents of discovery.xml, or FALSE on failure.
* @return string
* The full contents of discovery.xml.
*
* @throws \Drupal\collabora_online\Exception\CoolRequestException
* The client url cannot be retrieved.
*/
protected function getDiscovery(): string|false {
protected function getDiscovery(): string {
$discovery_url = $this->getWopiClientServerBaseUrl() . '/hosting/discovery';

$default_config = $this->configFactory->get('collabora_online.settings');
if ($default_config === NULL) {
return FALSE;
throw new CoolRequestException(
'Not able to retrieve the discovery.xml file from the Collabora Online server.',
203,
);
}
$disable_checks = (bool) $default_config->get('cool')['disable_cert_check'];

Expand All @@ -149,6 +149,10 @@ protected function getDiscovery(): string|false {

if ($res === FALSE) {
$this->logger->error('Cannot fetch from @url.', ['@url' => $discovery_url]);
throw new CoolRequestException(
'Not able to retrieve the discovery.xml file from the Collabora Online server.',
203,
);
}
return $res;
}
Expand Down

0 comments on commit 3968fa7

Please sign in to comment.