*/
protected function validateState()
{
- if (!isset($_GET['state'])) {
- throw new StateValidationException('Missing state parameter');
- }
- if (!($sessionState = WCF::getSession()->getVar(self::STATE))) {
- throw new StateValidationException('Missing state in session');
- }
- if (!\hash_equals($sessionState, (string)$_GET['state'])) {
- throw new StateValidationException('Mismatching state');
+ try {
+ if (!isset($_GET['state'])) {
+ throw new StateValidationException('Missing state parameter');
+ }
+ if (!($sessionState = WCF::getSession()->getVar(self::STATE))) {
+ throw new StateValidationException('Missing state in session');
+ }
+ if (!\hash_equals($sessionState, (string)$_GET['state'])) {
+ throw new StateValidationException('Mismatching state');
+ }
+ } finally {
+ WCF::getSession()->unregister(self::STATE);
}
-
- WCF::getSession()->unregister(self::STATE);
}
/**