Skip to content

Commit

Permalink
Merge pull request #9654 from nextcloud/backport/9360/stable13
Browse files Browse the repository at this point in the history
[stable13] Fix "Invalid argument supplied for foreach()"
  • Loading branch information
MorrisJobke authored May 30, 2018
2 parents 3acfcc4 + 0b25317 commit 4c1f88e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions apps/user_ldap/lib/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ public function handlePasswordExpiry($params) {
$uid = $params['uid'];
if(isset($uid) && $uid === $this->getUsername()) {
//retrieve relevant user attributes
$result = $this->access->search('objectclass=*', $this->dn, ['pwdpolicysubentry', 'pwdgraceusetime', 'pwdreset', 'pwdchangedtime']);
$result = $this->access->search('objectclass=*', array($this->dn), ['pwdpolicysubentry', 'pwdgraceusetime', 'pwdreset', 'pwdchangedtime']);

if(array_key_exists('pwdpolicysubentry', $result[0])) {
$pwdPolicySubentry = $result[0]['pwdpolicysubentry'];
Expand All @@ -631,7 +631,7 @@ public function handlePasswordExpiry($params) {
$cacheKey = 'ppolicyAttributes' . $ppolicyDN;
$result = $this->connection->getFromCache($cacheKey);
if(is_null($result)) {
$result = $this->access->search('objectclass=*', $ppolicyDN, ['pwdgraceauthnlimit', 'pwdmaxage', 'pwdexpirewarning']);
$result = $this->access->search('objectclass=*', array($ppolicyDN), ['pwdgraceauthnlimit', 'pwdmaxage', 'pwdexpirewarning']);
$this->connection->writeToCache($cacheKey, $result);
}

Expand Down
8 changes: 4 additions & 4 deletions apps/user_ldap/tests/User/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1132,15 +1132,15 @@ public function testHandlePasswordExpiryWarningDefaultPolicy() {
$this->access->expects($this->any())
->method('search')
->will($this->returnCallback(function($filter, $base) {
if($base === 'uid=alice') {
if($base === array('uid=alice')) {
return array(
array(
'pwdchangedtime' => array((new \DateTime())->sub(new \DateInterval('P28D'))->format('Ymdhis').'Z'),
'pwdgraceusetime' => [],
),
);
}
if($base === 'cn=default,ou=policies,dc=foo,dc=bar') {
if($base === array('cn=default,ou=policies,dc=foo,dc=bar')) {
return array(
array(
'pwdmaxage' => array('2592000'),
Expand Down Expand Up @@ -1202,7 +1202,7 @@ public function testHandlePasswordExpiryWarningCustomPolicy() {
$this->access->expects($this->any())
->method('search')
->will($this->returnCallback(function($filter, $base) {
if($base === 'uid=alice') {
if($base === array('uid=alice')) {
return array(
array(
'pwdpolicysubentry' => array('cn=custom,ou=policies,dc=foo,dc=bar'),
Expand All @@ -1211,7 +1211,7 @@ public function testHandlePasswordExpiryWarningCustomPolicy() {
)
);
}
if($base === 'cn=custom,ou=policies,dc=foo,dc=bar') {
if($base === array('cn=custom,ou=policies,dc=foo,dc=bar')) {
return array(
array(
'pwdmaxage' => array('2592000'),
Expand Down

0 comments on commit 4c1f88e

Please sign in to comment.