Skip to content

Commit

Permalink
Fix runWithRoles without api version in config (#26)
Browse files Browse the repository at this point in the history
* prevent overwrting args by using cloned obj, fixes #23

* Update src/OpencastApi/Rest/OcRestClient.php

Co-authored-by: reiferschris <34450887+reiferschris@users.noreply.github.com>

* force no header on aux version call

---------

Co-authored-by: reiferschris <34450887+reiferschris@users.noreply.github.com>
  • Loading branch information
ferishili and reiferschris committed Jun 12, 2024
1 parent f1227e5 commit 5621e07
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/OpencastApi/Rest/OcRestClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ public function hasVersion($version)
{
if (empty($this->version)) {
try {
$defaultVersion = $this->performGet('/api/version/default');
// We have to use an aux object, in order to prevent overwriting arguments of current object.
$aux = clone $this;
$aux->enableNoHeader();
$defaultVersion = $aux->performGet('/api/version/default');
if (!empty($defaultVersion['body']) && isset($defaultVersion['body']->default)) {
$this->setVersion(str_replace(['application/', 'v', '+json'], ['', '', ''], $defaultVersion['body']->default));
} else {
Expand Down

0 comments on commit 5621e07

Please sign in to comment.