Skip to content

Commit

Permalink
Try to get rid of "Invalid argument supplied for foreach()" from Gollem.
Browse files Browse the repository at this point in the history
For one, we have been using an invalid flag for $session->get(). Make sure it returns an array.
Besides that, store the passwords array in the session, even if empty.

Bug: 14523
  • Loading branch information
yunosh committed Jan 13, 2017
1 parent cc9d6db commit 35ddcfa
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions gollem/lib/Auth.php
Expand Up @@ -332,12 +332,10 @@ protected static function _getBackends()
{
global $session;

if ($backends = $session->get('gollem', 'backends', $session::TYPE_ARRAY)) {
$passwords = $session->get('gollem', 'backends_password', $session::ENCRYPT);
if ($passwords) {
foreach ($passwords as $key => $val) {
$backends[$key]['params']['password'] = $val;
}
if (($backends = $session->get('gollem', 'backends', $session::TYPE_ARRAY)) &&
($passwords = $session->get('gollem', 'backends_password', $session::TYPE_ARRAY))) {
foreach ($passwords as $key => $val) {
$backends[$key]['params']['password'] = $val;
}
}

Expand All @@ -362,9 +360,7 @@ protected static function _setBackends($backends)
}

$session->set('gollem', 'backends', $backends);
if (!empty($passwords)) {
$session->set('gollem', 'backends_password', $passwords, $session::ENCRYPT);
}
$session->set('gollem', 'backends_password', $passwords, $session::ENCRYPT);
}

}

0 comments on commit 35ddcfa

Please sign in to comment.