Skip to content

Commit

Permalink
Fix: do not unset authScheme property
Browse files Browse the repository at this point in the history
Also unset loop variables bound by reference to array elements after the
loop to avoid possible surprises in the future.
  • Loading branch information
mstilkerich committed Aug 17, 2022
1 parent 801420b commit 6123ede
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
@@ -1,9 +1,12 @@
# Changelog for CardDAV client library for PHP ("PHP-CardDavClient")

## Version 1.X.Y (to 1.2.2)
## Version 1.2.3 (to 1.2.2)

- Fix: Throw an exception in the Discovery service in case no addressbook home could be discovered. Previously, an empty
list would be returned without indication that the discovery was not successful.
- Fix: After failure to authenticate with the server, the CardDavClient object might be left in a state that causes a
PHP warning on next usage (a property of the object was unintentionally deleted in that case and the warning
would be triggered on next attempt to access that property).

## Version 1.2.2 (to 1.2.1)

Expand Down
2 changes: 1 addition & 1 deletion src/HttpClientAdapterGuzzle.php
Expand Up @@ -183,7 +183,7 @@ public function sendRequest(string $method, string $uri, array $options = []): P

if ($response->getStatusCode() >= 400) {
Config::$logger->debug("None of the available auth schemes worked");
unset($this->authScheme);
$this->authScheme = null;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/Services/Sync.php
Expand Up @@ -152,6 +152,7 @@ private function synchronizeOneBatch(
] = $abook->getCard($objref["uri"]);
}
}
unset($objref);

if ($syncResult->createVCards() === false) {
Config::$logger->warning("Not for all changed objects, the VCard data was provided by the server");
Expand Down Expand Up @@ -365,6 +366,7 @@ function (array $changeObj): string {
Config::$logger->warning("Server did not return data for $couri");
}
}
unset($objref);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/Services/SyncResult.php
Expand Up @@ -90,6 +90,7 @@ public function createVCards(): bool
}
}
}
unset($obj);

return $ret;
}
Expand Down
1 change: 1 addition & 0 deletions tests/TestLogger.php
Expand Up @@ -127,6 +127,7 @@ public function expectMessage(string $expLevel, string $expMsg): void
break;
}
}
unset($recMsg);

TestCase::assertTrue($found, "The expected log entry containing '$expMsg' with level $expLevel was not found");
}
Expand Down

0 comments on commit 6123ede

Please sign in to comment.