Merge pull request #8072 from nextcloud/type-casting
Use type casting instead of *val() method
This commit is contained in:
commit
9be6050cc4
6 changed files with 35 additions and 35 deletions
|
@ -195,7 +195,7 @@ class Access extends LDAPUtility implements IUserTools {
|
|||
$this->abandonPagedSearch();
|
||||
// openLDAP requires that we init a new Paged Search. Not needed by AD,
|
||||
// but does not hurt either.
|
||||
$pagingSize = intval($this->connection->ldapPagingSize);
|
||||
$pagingSize = (int)$this->connection->ldapPagingSize;
|
||||
// 0 won't result in replies, small numbers may leave out groups
|
||||
// (cf. #12306), 500 is default for paging and should work everywhere.
|
||||
$maxResults = $pagingSize > 20 ? $pagingSize : 500;
|
||||
|
@ -352,7 +352,7 @@ class Access extends LDAPUtility implements IUserTools {
|
|||
* @throws \Exception
|
||||
*/
|
||||
public function setPassword($userDN, $password) {
|
||||
if(intval($this->connection->turnOnPasswordChange) !== 1) {
|
||||
if((int)$this->connection->turnOnPasswordChange !== 1) {
|
||||
throw new \Exception('LDAP password changes are disabled.');
|
||||
}
|
||||
$cr = $this->connection->getConnectionResource();
|
||||
|
@ -573,7 +573,7 @@ class Access extends LDAPUtility implements IUserTools {
|
|||
}
|
||||
|
||||
if($isUser) {
|
||||
$usernameAttribute = strval($this->connection->ldapExpertUsernameAttr);
|
||||
$usernameAttribute = (string)$this->connection->ldapExpertUsernameAttr;
|
||||
if ($usernameAttribute !== '') {
|
||||
$username = $this->readAttribute($fdn, $usernameAttribute);
|
||||
$username = $username[0];
|
||||
|
@ -751,9 +751,9 @@ class Access extends LDAPUtility implements IUserTools {
|
|||
} else {
|
||||
natsort($usedNames);
|
||||
$lastName = array_pop($usedNames);
|
||||
$lastNo = intval(substr($lastName, strrpos($lastName, '_') + 1));
|
||||
$lastNo = (int)substr($lastName, strrpos($lastName, '_') + 1);
|
||||
}
|
||||
$altName = $name.'_'.strval($lastNo+1);
|
||||
$altName = $name.'_'. (string)($lastNo+1);
|
||||
unset($usedNames);
|
||||
|
||||
$attempts = 1;
|
||||
|
@ -1051,7 +1051,7 @@ class Access extends LDAPUtility implements IUserTools {
|
|||
}
|
||||
|
||||
//check whether paged search should be attempted
|
||||
$pagedSearchOK = $this->initPagedSearch($filter, $base, $attr, intval($limit), $offset);
|
||||
$pagedSearchOK = $this->initPagedSearch($filter, $base, $attr, (int)$limit, $offset);
|
||||
|
||||
$linkResources = array_pad(array(), count($base), $cr);
|
||||
$sr = $this->invokeLDAPMethod('search', $linkResources, $base, $filter, $attr);
|
||||
|
@ -1099,7 +1099,7 @@ class Access extends LDAPUtility implements IUserTools {
|
|||
$this->pagedSearchedSuccessful = true;
|
||||
}
|
||||
} else {
|
||||
if(!is_null($limit) && intval($this->connection->ldapPagingSize) !== 0) {
|
||||
if(!is_null($limit) && (int)$this->connection->ldapPagingSize !== 0) {
|
||||
\OC::$server->getLogger()->debug(
|
||||
'Paged search was not available',
|
||||
[ 'app' => 'user_ldap' ]
|
||||
|
@ -1131,7 +1131,7 @@ class Access extends LDAPUtility implements IUserTools {
|
|||
private function count($filter, $base, $attr = null, $limit = null, $offset = null, $skipHandling = false) {
|
||||
\OCP\Util::writeLog('user_ldap', 'Count filter: '.print_r($filter, true), \OCP\Util::DEBUG);
|
||||
|
||||
$limitPerPage = intval($this->connection->ldapPagingSize);
|
||||
$limitPerPage = (int)$this->connection->ldapPagingSize;
|
||||
if(!is_null($limit) && $limit < $limitPerPage && $limit > 0) {
|
||||
$limitPerPage = $limit;
|
||||
}
|
||||
|
@ -1174,7 +1174,7 @@ class Access extends LDAPUtility implements IUserTools {
|
|||
$counter = 0;
|
||||
|
||||
foreach($searchResults as $res) {
|
||||
$count = intval($this->invokeLDAPMethod('countEntries', $this->connection->getConnectionResource(), $res));
|
||||
$count = (int)$this->invokeLDAPMethod('countEntries', $this->connection->getConnectionResource(), $res);
|
||||
$counter += $count;
|
||||
}
|
||||
|
||||
|
@ -1194,7 +1194,7 @@ class Access extends LDAPUtility implements IUserTools {
|
|||
* @throws ServerNotAvailableException
|
||||
*/
|
||||
public function search($filter, $base, $attr = null, $limit = null, $offset = null, $skipHandling = false) {
|
||||
$limitPerPage = intval($this->connection->ldapPagingSize);
|
||||
$limitPerPage = (int)$this->connection->ldapPagingSize;
|
||||
if(!is_null($limit) && $limit < $limitPerPage && $limit > 0) {
|
||||
$limitPerPage = $limit;
|
||||
}
|
||||
|
@ -1287,7 +1287,7 @@ class Access extends LDAPUtility implements IUserTools {
|
|||
&& !is_null($limit)
|
||||
)
|
||||
) {
|
||||
$findings = array_slice($findings, intval($offset), $limit);
|
||||
$findings = array_slice($findings, (int)$offset, $limit);
|
||||
}
|
||||
return $findings;
|
||||
}
|
||||
|
@ -1829,7 +1829,7 @@ class Access extends LDAPUtility implements IUserTools {
|
|||
}
|
||||
$offset -= $limit;
|
||||
//we work with cache here
|
||||
$cacheKey = 'lc' . crc32($base) . '-' . crc32($filter) . '-' . intval($limit) . '-' . intval($offset);
|
||||
$cacheKey = 'lc' . crc32($base) . '-' . crc32($filter) . '-' . (int)$limit . '-' . (int)$offset;
|
||||
$cookie = '';
|
||||
if(isset($this->cookies[$cacheKey])) {
|
||||
$cookie = $this->cookies[$cacheKey];
|
||||
|
@ -1876,7 +1876,7 @@ class Access extends LDAPUtility implements IUserTools {
|
|||
private function setPagedResultCookie($base, $filter, $limit, $offset, $cookie) {
|
||||
// allow '0' for 389ds
|
||||
if(!empty($cookie) || $cookie === '0') {
|
||||
$cacheKey = 'lc' . crc32($base) . '-' . crc32($filter) . '-' .intval($limit) . '-' . intval($offset);
|
||||
$cacheKey = 'lc' . crc32($base) . '-' . crc32($filter) . '-' . (int)$limit . '-' . (int)$offset;
|
||||
$this->cookies[$cacheKey] = $cookie;
|
||||
$this->lastCookie = $cookie;
|
||||
}
|
||||
|
@ -1904,7 +1904,7 @@ class Access extends LDAPUtility implements IUserTools {
|
|||
private function initPagedSearch($filter, $bases, $attr, $limit, $offset) {
|
||||
$pagedSearchOK = false;
|
||||
if($this->connection->hasPagedResultSupport && ($limit !== 0)) {
|
||||
$offset = intval($offset); //can be null
|
||||
$offset = (int)$offset; //can be null
|
||||
\OCP\Util::writeLog('user_ldap',
|
||||
'initializing paged search for Filter '.$filter.' base '.print_r($bases, true)
|
||||
.' attr '.print_r($attr, true). ' limit ' .$limit.' offset '.$offset,
|
||||
|
@ -1956,7 +1956,7 @@ class Access extends LDAPUtility implements IUserTools {
|
|||
$this->abandonPagedSearch();
|
||||
// in case someone set it to 0 … use 500, otherwise no results will
|
||||
// be returned.
|
||||
$pageSize = intval($this->connection->ldapPagingSize) > 0 ? intval($this->connection->ldapPagingSize) : 500;
|
||||
$pageSize = (int)$this->connection->ldapPagingSize > 0 ? (int)$this->connection->ldapPagingSize : 500;
|
||||
$pagedSearchOK = $this->invokeLDAPMethod('controlPagedResult',
|
||||
$this->connection->getConnectionResource(),
|
||||
$pageSize, false, '');
|
||||
|
|
|
@ -1008,7 +1008,7 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD
|
|||
return array();
|
||||
}
|
||||
$search = $this->access->escapeFilterPart($search, true);
|
||||
$pagingSize = intval($this->access->connection->ldapPagingSize);
|
||||
$pagingSize = (int)$this->access->connection->ldapPagingSize;
|
||||
if (!$this->access->connection->hasPagedResultSupport || $pagingSize <= 0) {
|
||||
return $this->getGroupsChunk($search, $limit, $offset);
|
||||
}
|
||||
|
|
|
@ -194,11 +194,11 @@ class User {
|
|||
$displayName = $displayName2 = '';
|
||||
$attr = strtolower($this->connection->ldapUserDisplayName);
|
||||
if(isset($ldapEntry[$attr])) {
|
||||
$displayName = strval($ldapEntry[$attr][0]);
|
||||
$displayName = (string)$ldapEntry[$attr][0];
|
||||
}
|
||||
$attr = strtolower($this->connection->ldapUserDisplayName2);
|
||||
if(isset($ldapEntry[$attr])) {
|
||||
$displayName2 = strval($ldapEntry[$attr][0]);
|
||||
$displayName2 = (string)$ldapEntry[$attr][0];
|
||||
}
|
||||
if ($displayName !== '') {
|
||||
$this->composeAndStoreDisplayName($displayName);
|
||||
|
@ -281,7 +281,7 @@ class User {
|
|||
* @throws \Exception
|
||||
*/
|
||||
public function getHomePath($valueFromLDAP = null) {
|
||||
$path = strval($valueFromLDAP);
|
||||
$path = (string)$valueFromLDAP;
|
||||
$attr = null;
|
||||
|
||||
if (is_null($valueFromLDAP)
|
||||
|
@ -387,7 +387,7 @@ class User {
|
|||
$lastChecked = $this->config->getUserValue($this->uid, 'user_ldap',
|
||||
self::USER_PREFKEY_LASTREFRESH, 0);
|
||||
|
||||
if((time() - intval($lastChecked)) < intval($this->config->getAppValue('user_ldap', 'updateAttributesInterval', 86400)) ) {
|
||||
if((time() - (int)$lastChecked) < (int)$this->config->getAppValue('user_ldap', 'updateAttributesInterval', 86400)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -412,7 +412,7 @@ class User {
|
|||
* @returns string the effective display name
|
||||
*/
|
||||
public function composeAndStoreDisplayName($displayName, $displayName2 = '') {
|
||||
$displayName2 = strval($displayName2);
|
||||
$displayName2 = (string)$displayName2;
|
||||
if($displayName2 !== '') {
|
||||
$displayName .= ' (' . $displayName2 . ')';
|
||||
}
|
||||
|
@ -452,20 +452,20 @@ class User {
|
|||
if($this->wasRefreshed('email')) {
|
||||
return;
|
||||
}
|
||||
$email = strval($valueFromLDAP);
|
||||
$email = (string)$valueFromLDAP;
|
||||
if(is_null($valueFromLDAP)) {
|
||||
$emailAttribute = $this->connection->ldapEmailAttribute;
|
||||
if ($emailAttribute !== '') {
|
||||
$aEmail = $this->access->readAttribute($this->dn, $emailAttribute);
|
||||
if(is_array($aEmail) && (count($aEmail) > 0)) {
|
||||
$email = strval($aEmail[0]);
|
||||
$email = (string)$aEmail[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($email !== '') {
|
||||
$user = $this->userManager->get($this->uid);
|
||||
if (!is_null($user)) {
|
||||
$currentEmail = strval($user->getEMailAddress());
|
||||
$currentEmail = (string)$user->getEMailAddress();
|
||||
if ($currentEmail !== $email) {
|
||||
$user->setEMailAddress($email);
|
||||
}
|
||||
|
@ -610,7 +610,7 @@ class User {
|
|||
*/
|
||||
public function handlePasswordExpiry($params) {
|
||||
$ppolicyDN = $this->connection->ldapDefaultPPolicyDN;
|
||||
if (empty($ppolicyDN) || (intval($this->connection->turnOnPasswordChange) !== 1)) {
|
||||
if (empty($ppolicyDN) || ((int)$this->connection->turnOnPasswordChange !== 1)) {
|
||||
return;//password expiry handling disabled
|
||||
}
|
||||
$uid = $params['uid'];
|
||||
|
@ -646,7 +646,7 @@ class User {
|
|||
if($pwdGraceUseTime && $pwdGraceUseTimeCount > 0) { //was this a grace login?
|
||||
if($pwdGraceAuthNLimit
|
||||
&& (count($pwdGraceAuthNLimit) > 0)
|
||||
&&($pwdGraceUseTimeCount < intval($pwdGraceAuthNLimit[0]))) { //at least one more grace login available?
|
||||
&&($pwdGraceUseTimeCount < (int)$pwdGraceAuthNLimit[0])) { //at least one more grace login available?
|
||||
$this->config->setUserValue($uid, 'user_ldap', 'needsPasswordReset', 'true');
|
||||
header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute(
|
||||
'user_ldap.renewPassword.showRenewPasswordForm', array('user' => $uid)));
|
||||
|
@ -667,8 +667,8 @@ class User {
|
|||
if($pwdChangedTime && (count($pwdChangedTime) > 0)) {
|
||||
if($pwdMaxAge && (count($pwdMaxAge) > 0)
|
||||
&& $pwdExpireWarning && (count($pwdExpireWarning) > 0)) {
|
||||
$pwdMaxAgeInt = intval($pwdMaxAge[0]);
|
||||
$pwdExpireWarningInt = intval($pwdExpireWarning[0]);
|
||||
$pwdMaxAgeInt = (int)$pwdMaxAge[0];
|
||||
$pwdExpireWarningInt = (int)$pwdExpireWarning[0];
|
||||
if($pwdMaxAgeInt > 0 && $pwdExpireWarningInt > 0){
|
||||
$pwdChangedTimeDt = \DateTime::createFromFormat('YmdHisZ', $pwdChangedTime[0]);
|
||||
$pwdChangedTimeDt->add(new \DateInterval('PT'.$pwdMaxAgeInt.'S'));
|
||||
|
|
|
@ -232,7 +232,7 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
|
|||
if($user->getUsername() !== false && $this->access->setPassword($user->getDN(), $password)) {
|
||||
$ldapDefaultPPolicyDN = $this->access->connection->ldapDefaultPPolicyDN;
|
||||
$turnOnPasswordChange = $this->access->connection->turnOnPasswordChange;
|
||||
if (!empty($ldapDefaultPPolicyDN) && (intval($turnOnPasswordChange) === 1)) {
|
||||
if (!empty($ldapDefaultPPolicyDN) && ((int)$turnOnPasswordChange === 1)) {
|
||||
//remove last password expiry warning if any
|
||||
$notification = $this->notificationManager->createNotification();
|
||||
$notification->setApp('user_ldap')
|
||||
|
@ -387,7 +387,7 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
|
|||
}
|
||||
|
||||
$marked = $this->ocConfig->getUserValue($uid, 'user_ldap', 'isDeleted', 0);
|
||||
if(intval($marked) === 0) {
|
||||
if((int)$marked === 0) {
|
||||
\OC::$server->getLogger()->notice(
|
||||
'User '.$uid . ' is not marked as deleted, not cleaning up.',
|
||||
array('app' => 'user_ldap'));
|
||||
|
@ -549,7 +549,7 @@ class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserIn
|
|||
| Backend::GET_DISPLAYNAME
|
||||
| Backend::PROVIDE_AVATAR
|
||||
| Backend::COUNT_USERS
|
||||
| ((intval($this->access->connection->turnOnPasswordChange) === 1)?(Backend::SET_PASSWORD):0)
|
||||
| (((int)$this->access->connection->turnOnPasswordChange === 1)?(Backend::SET_PASSWORD):0)
|
||||
| $this->userPluginManager->getImplementedActions())
|
||||
& $actions);
|
||||
}
|
||||
|
|
|
@ -690,7 +690,7 @@ class Wizard extends LDAPUtility {
|
|||
if ($settingsFound === true) {
|
||||
$config = array(
|
||||
'ldapPort' => $p,
|
||||
'ldapTLS' => intval($t)
|
||||
'ldapTLS' => (int)$t
|
||||
);
|
||||
$this->configuration->setConfiguration($config);
|
||||
\OCP\Util::writeLog('user_ldap', 'Wiz: detected Port ' . $p, \OCP\Util::DEBUG);
|
||||
|
@ -1069,7 +1069,7 @@ class Wizard extends LDAPUtility {
|
|||
|
||||
if($login === true) {
|
||||
$this->ldap->unbind($cr);
|
||||
\OCP\Util::writeLog('user_ldap', 'Wiz: Bind successful to Port '. $port . ' TLS ' . intval($tls), \OCP\Util::DEBUG);
|
||||
\OCP\Util::writeLog('user_ldap', 'Wiz: Bind successful to Port '. $port . ' TLS ' . (int)$tls, \OCP\Util::DEBUG);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1326,7 +1326,7 @@ class Wizard extends LDAPUtility {
|
|||
//636 ← LDAPS / SSL
|
||||
//7xxx ← UCS. need to be checked first, because both ports may be open
|
||||
$host = $this->configuration->ldapHost;
|
||||
$port = intval($this->configuration->ldapPort);
|
||||
$port = (int)$this->configuration->ldapPort;
|
||||
$portSettings = array();
|
||||
|
||||
//In case the port is already provided, we will check this first
|
||||
|
|
|
@ -327,7 +327,7 @@ class Database extends \OC\Group\Backend {
|
|||
$result = $stmt->execute($parameters);
|
||||
$count = $result->fetchOne();
|
||||
if($count !== false) {
|
||||
$count = intval($count);
|
||||
$count = (int)$count;
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue