Skip to content

Commit

Permalink
Issue CollaboraOnline#56: Let getWopiSrcUrl() always return string|null.
Browse files Browse the repository at this point in the history
  • Loading branch information
donquixote committed Nov 12, 2024
1 parent ee4d7f5 commit 31bddca
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Cool/CoolRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function getWopiClientURL() {
);
}

$wopi_src = (string) $this->getWopiSrcUrl($discovery_parsed, 'text/plain')[0];
$wopi_src = $this->getWopiSrcUrl($discovery_parsed, 'text/plain');
if (!$wopi_src) {
throw new CoolRequestException(
'The requested mime type is not handled.',
Expand Down Expand Up @@ -132,14 +132,14 @@ protected function getDiscovery($server) {
* @param string $mimetype
* MIME type for which to fetch the WOPI url. E.g. 'text/plain'.
*
* @return mixed|null
* @return string|null
* WOPI url as configured for this MIME type in discovery.xml, or NULL if
* none was found for the given MIME type.
*/
protected function getWopiSrcUrl($discovery_parsed, $mimetype) {
$result = $discovery_parsed->xpath(sprintf('/wopi-discovery/net-zone/app[@name=\'%s\']/action', $mimetype));
if ($result && count($result) > 0) {
return $result[0]['urlsrc'];
return (string) $result[0]['urlsrc'][0];
}
return NULL;
}
Expand Down

0 comments on commit 31bddca

Please sign in to comment.