Date: Sunday, January 16, 2022 @ 16:58:14 Author: dvzrv Revision: 1106376
upgpkg: nextcloud 23.0.0-2: Rebuild to make compatible with php 8.1. Add upstream series of patches for php 8.1 support: https://github.com/nextcloud/server/pull/29862 Raise php compatibility to < 8.2.0. Ignore .orig patch files when installing. Simplify installation of systemd service and timer and quote pkgdir. Added: nextcloud/trunk/nextcloud-23.0.0-php8.1.patch Modified: nextcloud/trunk/PKGBUILD -------------------------------+ PKGBUILD | 27 - nextcloud-23.0.0-php8.1.patch | 983 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 998 insertions(+), 12 deletions(-) Modified: PKGBUILD =================================================================== --- PKGBUILD 2022-01-16 16:55:13 UTC (rev 1106375) +++ PKGBUILD 2022-01-16 16:58:14 UTC (rev 1106376) @@ -4,12 +4,12 @@ pkgname=nextcloud # NOTE: do not package x.0.0 versions as they are considered beta pkgver=23.0.0 -pkgrel=1 +pkgrel=2 pkgdesc="A cloud server to store your files centrally on a hardware controlled by you" -arch=('any') +arch=(any) url="https://nextcloud.com" -license=('AGPL3') -depends=('php>=8.0.0' 'php<8.1.0' 'php-gd') +license=(AGPL3) +depends=('php>=8.0.0' 'php<8.2.0' php-gd) optdepends=( 'curl: for webcron jobs from within uwsgi' 'ffmpeg: for preview generation' @@ -52,6 +52,7 @@ "${pkgname}.uwsgi" "${pkgname}-cron.service" "${pkgname}-cron.timer" + "${pkgname}-23.0.0-php8.1.patch" ) sha512sums=('fba9f03c37a4d3f5e44472218fc50a49157872ae7c1aaaa3bc0c1c0301a97394690f75cf03cd11b3f9b0f282fef29eea189fa52ee5019f40a0d6f671ddda6706' 'SKIP' @@ -63,7 +64,8 @@ '919008a2bf6cf2492cb1e9c8e28c1e082d74e45da5a96e6669f8971d6cf721e36d23625c89918fe10d8bc1b202c0340aa897849d9ec501a26f3f4572ccb57a98' '8bc7e76ba986cadf8d3bf35d6fbd8e7e236a61d1372e023c07e60427bacce925737c996d9fbaaeb51ed1066c1d0c8d83a86d7d640ed991b531744ed06629a670' 'c585af280c2503a5a969fffd53d192a045a1dedd6d3a32901dfa0e226f9ddb4b5d1b1760553e962b061172c0077fcc57b095d8b7c70cafaa8ca84dbfce2eaa24' - 'eb69785a5b0df0e2a11f53f9c2e2dbf75681d7c698e88cbcc5ceed713a558d528511cc576813cc083cbaa28a2c83d543a39436ad4805670348ef22634305b1c8') + 'eb69785a5b0df0e2a11f53f9c2e2dbf75681d7c698e88cbcc5ceed713a558d528511cc576813cc083cbaa28a2c83d543a39436ad4805670348ef22634305b1c8' + '00ce00f0bd5e424ee8bbaef72e7bf0a15f4987c059385abb3788d7605e2e9802176c5083a00b7e211be44c74eb83fe9b9bc1069256e0328f883a4abc01705a08') b2sums=('2dc00a1b522b51baa368a19628e354a674af1428e062595ccf75cb8541f497c1b2f8ed4f301cc0b5136382526e0e0c6ea1405f2d08a748b8fa2caf95d70c3d89' 'SKIP' '7d40d120c28291f1a7537f3e1b5049fa83c9c0af949371345ea9ccdf3de4a0f3a3a06edbc52d9254dba483e4d11acf562cf679b9e379c5dfc2f61dfbfc2e4cef' @@ -74,15 +76,18 @@ 'd132044cb7f1d61a1ce87800d2e1142e3ac385acdec25e2f5ad685603a0ffa88e105f4c35688584d65d287adbb40b8d9a02d6a80d7a0b58bb8801a6769405218' '937ae5b89d968d784c7b68e1ca81e7aec11e295b95244fc4bcfec55b3d5f37ef70d5f593086eeb14101c8940a241565730cb6edcdf88165094c4ad27a89bd980' '9857f3dd219b624869255e0d6c262b60de813b87ac4fd3fccad0a330392f55709e8c2d4b9dfb5ad19df7cc0fc13cc83cead06c9a1d893ee4e4972c4937df0c2b' - 'e6214351ca16bfe97683e838e727d6b5eaa62194878272204034c62aac4a632c9b33cd31aa0570c2eb936d7e9e7ff60190ac05a3a8cc2e27eda423a7d89b6d39') + 'e6214351ca16bfe97683e838e727d6b5eaa62194878272204034c62aac4a632c9b33cd31aa0570c2eb936d7e9e7ff60190ac05a3a8cc2e27eda423a7d89b6d39' + '509be5240a86010f1143c285f0c4796d6fdc3be0239b0345aeac7f295cb723e095b91a24302558b611d0d7146654e652d3caf1e479260941a7cc84bfc4207de3') validpgpkeys=('28806A878AE423A28372792ED75899B9A724937A') # Nextcloud Security <[email protected]> prepare() { - mv -v "${pkgname}" "${pkgname}-${pkgver}" + cd "${pkgname}" + # add backported patch for php 8.1 support: https://github.com/nextcloud/server/pull/29862 + patch -Np1 -i ../"${pkgname}-23.0.0-php8.1.patch" } package() { - cd "${pkgname}-${pkgver}" + cd "${pkgname}" # sysusers.d integration install -vDm 644 ../${pkgname}.sysusers \ "${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf" @@ -105,7 +110,7 @@ rm -rf config .htaccess # webapp - find . -type f -exec install -vDm 644 {} "${pkgdir}/usr/share/webapps/${pkgname}/"{} \; + find . -type f -not -iname "*.orig" -exec install -vDm 644 {} "${pkgdir}/usr/share/webapps/${pkgname}/"{} \; # symlink config directory into place ln -sv "/etc/webapps/${pkgname}/config" "${pkgdir}/usr/share/webapps/${pkgname}/" @@ -122,7 +127,5 @@ # apache example conf install -vDm 644 ../apache.example.conf -t "${pkgdir}/usr/share/doc/${pkgname}/" # systemd timer - install -D -t $pkgdir/usr/lib/systemd/system -m 644 \ - "${srcdir}"/${pkgname}-cron.service \ - "${srcdir}"/${pkgname}-cron.timer + install -vDm 644 ../${pkgname}-cron.{service,timer} -t "$pkgdir/usr/lib/systemd/system" } Added: nextcloud-23.0.0-php8.1.patch =================================================================== --- nextcloud-23.0.0-php8.1.patch (rev 0) +++ nextcloud-23.0.0-php8.1.patch 2022-01-16 16:58:14 UTC (rev 1106376) @@ -0,0 +1,983 @@ +From 260be93a14af6eccb6240dfb3692073775da259e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <[email protected]> +Date: Tue, 19 Oct 2021 17:08:57 +0200 +Subject: [PATCH 01/12] Allow running Nextcloud with PHP 8.1 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Côme Chilliet <[email protected]> +--- + lib/versioncheck.php | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/lib/versioncheck.php b/lib/versioncheck.php +index 4b1d9dec4d72..8aa68dd35fdd 100644 +--- a/lib/versioncheck.php ++++ b/lib/versioncheck.php +@@ -33,10 +33,10 @@ + exit(1); + } + +-// Show warning if > PHP 8.0 is used as Nextcloud is not compatible with > PHP 8.0 for now +-if (PHP_VERSION_ID >= 80100) { ++// Show warning if > PHP 8.1 is used as Nextcloud is not compatible with > PHP 8.1 for now ++if (PHP_VERSION_ID > 80100) { + http_response_code(500); +- echo 'This version of Nextcloud is not compatible with > PHP 8.0.<br/>'; ++ echo 'This version of Nextcloud is not compatible with > PHP 8.1.<br/>'; + echo 'You are currently running ' . PHP_VERSION . '.'; + exit(1); + } + +From 37f8f7a5a18e57507330036b747d4b12e58efae4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <[email protected]> +Date: Tue, 26 Oct 2021 16:42:19 +0200 +Subject: [PATCH 03/12] Fix tests on PHP 8.1 for encryption, files_sharing, + files_version, +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + + files_trashbin and theming apps + +Signed-off-by: Côme Chilliet <[email protected]> +--- + apps/encryption/lib/Command/FixEncryptedVersion.php | 5 +---- + apps/encryption/tests/Crypto/EncryptAllTest.php | 5 ++++- + .../tests/Controller/PublicPreviewControllerTest.php | 4 ++++ + .../tests/Controller/PreviewControllerTest.php | 2 ++ + .../tests/Controller/PreviewControllerTest.php | 2 ++ + apps/theming/tests/Controller/IconControllerTest.php | 2 ++ + apps/theming/tests/Controller/ThemingControllerTest.php | 3 +++ + 7 files changed, 18 insertions(+), 5 deletions(-) + +diff --git a/apps/encryption/lib/Command/FixEncryptedVersion.php b/apps/encryption/lib/Command/FixEncryptedVersion.php +index d51f64c8ef91..073c1f1438a8 100644 +--- a/apps/encryption/lib/Command/FixEncryptedVersion.php ++++ b/apps/encryption/lib/Command/FixEncryptedVersion.php +@@ -116,10 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int + $user = (string)$input->getArgument('user'); + $pathToWalk = "/$user/files"; + +- /** +- * trim() returns an empty string when the argument is an unset/null +- */ +- $pathOption = \trim($input->getOption('path'), '/'); ++ $pathOption = \trim(($input->getOption('path') ?? ''), '/'); + if ($pathOption !== "") { + $pathToWalk = "$pathToWalk/$pathOption"; + } + +From f3dcbfe146782d2c7dec8760651e79605ddc96e7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <[email protected]> +Date: Tue, 26 Oct 2021 16:43:39 +0200 +Subject: [PATCH 04/12] Fix PHP 8.1 support for user_ldap application +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Côme Chilliet <[email protected]> +--- + apps/user_ldap/lib/Access.php | 8 +- + apps/user_ldap/lib/Connection.php | 9 +- + apps/user_ldap/lib/Group_LDAP.php | 6 +- + apps/user_ldap/lib/Group_Proxy.php | 2 +- + apps/user_ldap/lib/IGroupLDAP.php | 2 +- + apps/user_ldap/lib/ILDAPWrapper.php | 60 ++++++------ + apps/user_ldap/lib/IUserLDAP.php | 2 +- + apps/user_ldap/lib/LDAP.php | 92 +++++-------------- + apps/user_ldap/lib/LDAPProvider.php | 4 +- + apps/user_ldap/lib/PagedResults/IAdapter.php | 4 +- + apps/user_ldap/lib/PagedResults/TLinkId.php | 12 ++- + apps/user_ldap/lib/User/Manager.php | 2 +- + apps/user_ldap/lib/User/User.php | 8 +- + apps/user_ldap/lib/User_LDAP.php | 2 +- + apps/user_ldap/lib/User_Proxy.php | 2 +- + apps/user_ldap/lib/Wizard.php | 6 +- + apps/user_ldap/tests/AccessTest.php | 2 +- + .../Integration/ExceptionOnLostConnection.php | 4 +- + 18 files changed, 96 insertions(+), 131 deletions(-) + +diff --git a/apps/user_ldap/lib/Access.php b/apps/user_ldap/lib/Access.php +index 0af04747ded2..f79efe909968 100644 +--- a/apps/user_ldap/lib/Access.php ++++ b/apps/user_ldap/lib/Access.php +@@ -260,7 +260,7 @@ public function readAttribute($dn, $attr, $filter = 'objectClass=*') { + /** + * Runs an read operation against LDAP + * +- * @param resource $cr the LDAP connection ++ * @param resource|\LDAP\Connection $cr the LDAP connection + * @param string $dn + * @param string $attribute + * @param string $filter +@@ -926,7 +926,7 @@ public function fetchListOfUsers(string $filter, array $attr, int $limit = null, + * @throws \Exception + */ + public function batchApplyUserAttributes(array $ldapRecords) { +- $displayNameAttribute = strtolower($this->connection->ldapUserDisplayName); ++ $displayNameAttribute = strtolower((string)$this->connection->ldapUserDisplayName); + foreach ($ldapRecords as $userRecord) { + if (!isset($userRecord[$displayNameAttribute])) { + // displayName is obligatory +@@ -1186,7 +1186,7 @@ private function executeSearch( + /** + * processes an LDAP paged search operation + * +- * @param resource $sr the array containing the LDAP search resources ++ * @param resource|\LDAP\Result|resource[]|\LDAP\Result[] $sr the array containing the LDAP search resources + * @param int $foundItems number of results in the single search operation + * @param int $limit maximum results to be counted + * @param bool $pagedSearchOK whether a paged search has been executed +@@ -1303,7 +1303,7 @@ private function count( + } + + /** +- * @param resource $sr ++ * @param resource|\LDAP\Result|resource[]|\LDAP\Result[] $sr + * @return int + * @throws ServerNotAvailableException + */ +diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php +index 77ae34f9f6c4..6666da1e933c 100644 +--- a/apps/user_ldap/lib/Connection.php ++++ b/apps/user_ldap/lib/Connection.php +@@ -74,6 +74,9 @@ + * @property string ldapMatchingRuleInChainState + */ + class Connection extends LDAPUtility { ++ /** ++ * @var resource|\LDAP\Connection|null ++ */ + private $ldapConnectionRes = null; + private $configPrefix; + private $configID; +@@ -202,7 +205,7 @@ public function init($force = false) { + } + + /** +- * Returns the LDAP handler ++ * @return resource|\LDAP\Connection The LDAP resource + */ + public function getConnectionResource() { + if (!$this->ldapConnectionRes) { +@@ -408,7 +411,7 @@ private function doSoftValidation() { + } + } + +- if ((stripos($this->configuration->ldapHost, 'ldaps://') === 0) ++ if ((stripos((string)$this->configuration->ldapHost, 'ldaps://') === 0) + && $this->configuration->ldapTLS) { + $this->configuration->ldapTLS = false; + $this->logger->info( +@@ -487,7 +490,7 @@ private function doCriticalValidation() { + $configurationOK = false; + } + +- if (mb_strpos($this->configuration->ldapLoginFilter, '%uid', 0, 'UTF-8') ++ if (mb_strpos((string)$this->configuration->ldapLoginFilter, '%uid', 0, 'UTF-8') + === false) { + $this->logger->warning( + $errorStr.'login filter does not contain %uid place holder.', +diff --git a/apps/user_ldap/lib/Group_LDAP.php b/apps/user_ldap/lib/Group_LDAP.php +index 744f921c6dd3..9172b5fa25fc 100644 +--- a/apps/user_ldap/lib/Group_LDAP.php ++++ b/apps/user_ldap/lib/Group_LDAP.php +@@ -83,7 +83,7 @@ public function __construct(Access $access, GroupPluginManager $groupPluginManag + $this->cachedNestedGroups = new CappedMemoryCache(); + $this->groupPluginManager = $groupPluginManager; + $this->logger = OC::$server->get(LoggerInterface::class); +- $this->ldapGroupMemberAssocAttr = strtolower($gAssoc); ++ $this->ldapGroupMemberAssocAttr = strtolower((string)$gAssoc); + } + + /** +@@ -202,7 +202,7 @@ public function inGroup($uid, $gid) { + * @throws ServerNotAvailableException + */ + public function getDynamicGroupMembers(string $dnGroup): array { +- $dynamicGroupMemberURL = strtolower($this->access->connection->ldapDynamicGroupMemberURL); ++ $dynamicGroupMemberURL = strtolower((string)$this->access->connection->ldapDynamicGroupMemberURL); + + if (empty($dynamicGroupMemberURL)) { + return []; +@@ -1312,7 +1312,7 @@ public function getGroupDetails($gid) { + * of the current access. + * + * @param string $gid +- * @return resource of the LDAP connection ++ * @return resource|\LDAP\Connection The LDAP connection + * @throws ServerNotAvailableException + */ + public function getNewLDAPConnection($gid) { +diff --git a/apps/user_ldap/lib/Group_Proxy.php b/apps/user_ldap/lib/Group_Proxy.php +index 3f9bb9013eb4..92a9041949e2 100644 +--- a/apps/user_ldap/lib/Group_Proxy.php ++++ b/apps/user_ldap/lib/Group_Proxy.php +@@ -290,7 +290,7 @@ public function getLDAPAccess($gid) { + * The connection needs to be closed manually. + * + * @param string $gid +- * @return resource of the LDAP connection ++ * @return resource|\LDAP\Connection The LDAP connection + */ + public function getNewLDAPConnection($gid) { + return $this->handleRequest($gid, 'getNewLDAPConnection', [$gid]); +diff --git a/apps/user_ldap/lib/IGroupLDAP.php b/apps/user_ldap/lib/IGroupLDAP.php +index 33636dd8f552..2face1aa9074 100644 +--- a/apps/user_ldap/lib/IGroupLDAP.php ++++ b/apps/user_ldap/lib/IGroupLDAP.php +@@ -36,7 +36,7 @@ public function getLDAPAccess($gid); + /** + * Return a new LDAP connection for the specified group. + * @param string $gid +- * @return resource of the LDAP connection ++ * @return resource|\LDAP\Connection The LDAP connection + */ + public function getNewLDAPConnection($gid); + } +diff --git a/apps/user_ldap/lib/ILDAPWrapper.php b/apps/user_ldap/lib/ILDAPWrapper.php +index c82df09d2345..9917898a001b 100644 +--- a/apps/user_ldap/lib/ILDAPWrapper.php ++++ b/apps/user_ldap/lib/ILDAPWrapper.php +@@ -35,7 +35,7 @@ interface ILDAPWrapper { + + /** + * Bind to LDAP directory +- * @param resource $link LDAP link resource ++ * @param resource|\LDAP\Connection $link LDAP link resource + * @param string $dn an RDN to log in with + * @param string $password the password + * @return bool true on success, false otherwise +@@ -54,7 +54,7 @@ public function connect($host, $port); + + /** + * Send LDAP pagination control +- * @param resource $link LDAP link resource ++ * @param resource|\LDAP\Connection $link LDAP link resource + * @param int $pageSize number of results per page + * @param bool $isCritical Indicates whether the pagination is critical of not. + * @param string $cookie structure sent by LDAP server +@@ -64,8 +64,8 @@ public function controlPagedResult($link, $pageSize, $isCritical); + + /** + * Retrieve the LDAP pagination cookie +- * @param resource $link LDAP link resource +- * @param resource $result LDAP result resource ++ * @param resource|\LDAP\Connection $link LDAP link resource ++ * @param resource|\LDAP\Result $result LDAP result resource + * @param string $cookie structure sent by LDAP server + * @return bool true on success, false otherwise + * +@@ -75,22 +75,22 @@ public function controlPagedResultResponse($link, $result, &$cookie); + + /** + * Count the number of entries in a search +- * @param resource $link LDAP link resource +- * @param resource $result LDAP result resource ++ * @param resource|\LDAP\Connection $link LDAP link resource ++ * @param resource|\LDAP\Result $result LDAP result resource + * @return int|false number of results on success, false otherwise + */ + public function countEntries($link, $result); + + /** + * Return the LDAP error number of the last LDAP command +- * @param resource $link LDAP link resource ++ * @param resource|\LDAP\Connection $link LDAP link resource + * @return int error code + */ + public function errno($link); + + /** + * Return the LDAP error message of the last LDAP command +- * @param resource $link LDAP link resource ++ * @param resource|\LDAP\Connection $link LDAP link resource + * @return string error message + */ + public function error($link); +@@ -106,69 +106,69 @@ public function explodeDN($dn, $withAttrib); + + /** + * Return first result id +- * @param resource $link LDAP link resource +- * @param resource $result LDAP result resource +- * @return Resource an LDAP search result resource ++ * @param resource|\LDAP\Connection $link LDAP link resource ++ * @param resource|\LDAP\Result $result LDAP result resource ++ * @return resource|\LDAP\ResultEntry an LDAP entry resource + * */ + public function firstEntry($link, $result); + + /** + * Get attributes from a search result entry +- * @param resource $link LDAP link resource +- * @param resource $result LDAP result resource ++ * @param resource|\LDAP\Connection $link LDAP link resource ++ * @param resource|\LDAP\ResultEntry $result LDAP result resource + * @return array containing the results, false on error + * */ + public function getAttributes($link, $result); + + /** + * Get the DN of a result entry +- * @param resource $link LDAP link resource +- * @param resource $result LDAP result resource ++ * @param resource|\LDAP\Connection $link LDAP link resource ++ * @param resource|\LDAP\ResultEntry $result LDAP result resource + * @return string containing the DN, false on error + */ + public function getDN($link, $result); + + /** + * Get all result entries +- * @param resource $link LDAP link resource +- * @param resource $result LDAP result resource ++ * @param resource|\LDAP\Connection $link LDAP link resource ++ * @param resource|\LDAP\Result $result LDAP result resource + * @return array containing the results, false on error + */ + public function getEntries($link, $result); + + /** + * Return next result id +- * @param resource $link LDAP link resource +- * @param resource $result LDAP entry result resource +- * @return resource an LDAP search result resource ++ * @param resource|\LDAP\Connection $link LDAP link resource ++ * @param resource|\LDAP\ResultEntry $result LDAP result resource ++ * @return resource|\LDAP\ResultEntry an LDAP entry resource + * */ + public function nextEntry($link, $result); + + /** + * Read an entry +- * @param resource $link LDAP link resource ++ * @param resource|\LDAP\Connection $link LDAP link resource + * @param array $baseDN The DN of the entry to read from + * @param string $filter An LDAP filter + * @param array $attr array of the attributes to read +- * @return resource an LDAP search result resource ++ * @return resource|\LDAP\Result an LDAP search result resource + */ + public function read($link, $baseDN, $filter, $attr); + + /** + * Search LDAP tree +- * @param resource $link LDAP link resource ++ * @param resource|\LDAP\Connection $link LDAP link resource + * @param string $baseDN The DN of the entry to read from + * @param string $filter An LDAP filter + * @param array $attr array of the attributes to read + * @param int $attrsOnly optional, 1 if only attribute types shall be returned + * @param int $limit optional, limits the result entries +- * @return resource|false an LDAP search result resource, false on error ++ * @return resource|\LDAP\Result|false an LDAP search result resource, false on error + */ + public function search($link, $baseDN, $filter, $attr, $attrsOnly = 0, $limit = 0); + + /** + * Replace the value of a userPassword by $password +- * @param resource $link LDAP link resource ++ * @param resource|\LDAP\Connection $link LDAP link resource + * @param string $userDN the DN of the user whose password is to be replaced + * @param string $password the new value for the userPassword + * @return bool true on success, false otherwise +@@ -177,7 +177,7 @@ public function modReplace($link, $userDN, $password); + + /** + * Sets the value of the specified option to be $value +- * @param resource $link LDAP link resource ++ * @param resource|\LDAP\Connection $link LDAP link resource + * @param string $option a defined LDAP Server option + * @param int $value the new value for the option + * @return bool true on success, false otherwise +@@ -186,14 +186,14 @@ public function setOption($link, $option, $value); + + /** + * establish Start TLS +- * @param resource $link LDAP link resource ++ * @param resource|\LDAP\Connection $link LDAP link resource + * @return bool true on success, false otherwise + */ + public function startTls($link); + + /** + * Unbind from LDAP directory +- * @param resource $link LDAP link resource ++ * @param resource|\LDAP\Connection $link LDAP link resource + * @return bool true on success, false otherwise + */ + public function unbind($link); +@@ -208,8 +208,8 @@ public function areLDAPFunctionsAvailable(); + + /** + * Checks whether the submitted parameter is a resource +- * @param resource $resource the resource variable to check +- * @return bool true if it is a resource, false otherwise ++ * @param mixed $resource the resource variable to check ++ * @return bool true if it is a resource or LDAP object, false otherwise + */ + public function isResource($resource); + } +diff --git a/apps/user_ldap/lib/IUserLDAP.php b/apps/user_ldap/lib/IUserLDAP.php +index 201bbfd75a22..dfba11c5d343 100644 +--- a/apps/user_ldap/lib/IUserLDAP.php ++++ b/apps/user_ldap/lib/IUserLDAP.php +@@ -37,7 +37,7 @@ public function getLDAPAccess($uid); + /** + * Return a new LDAP connection for the specified user. + * @param string $uid +- * @return resource of the LDAP connection ++ * @return resource|\LDAP\Connection of the LDAP connection + */ + public function getNewLDAPConnection($uid); + +diff --git a/apps/user_ldap/lib/LDAP.php b/apps/user_ldap/lib/LDAP.php +index 900f5a7030f7..e33facd0889e 100644 +--- a/apps/user_ldap/lib/LDAP.php ++++ b/apps/user_ldap/lib/LDAP.php +@@ -51,19 +51,14 @@ public function __construct(string $logFile = '') { + } + + /** +- * @param resource $link +- * @param string $dn +- * @param string $password +- * @return bool|mixed ++ * {@inheritDoc} + */ + public function bind($link, $dn, $password) { + return $this->invokeLDAPMethod('bind', $link, $dn, $password); + } + + /** +- * @param string $host +- * @param string $port +- * @return mixed ++ * {@inheritDoc} + */ + public function connect($host, $port) { + if (strpos($host, '://') === false) { +@@ -76,6 +71,9 @@ public function connect($host, $port) { + return $this->invokeLDAPMethod('connect', $host); + } + ++ /** ++ * {@inheritDoc} ++ */ + public function controlPagedResultResponse($link, $result, &$cookie): bool { + $this->preFunctionCall( + $this->pagedResultsAdapter->getResponseCallFunc(), +@@ -93,10 +91,7 @@ public function controlPagedResultResponse($link, $result, &$cookie): bool { + } + + /** +- * @param LDAP $link +- * @param int $pageSize +- * @param bool $isCritical +- * @return mixed|true ++ * {@inheritDoc} + */ + public function controlPagedResult($link, $pageSize, $isCritical) { + $fn = $this->pagedResultsAdapter->getRequestCallFunc(); +@@ -116,25 +111,21 @@ public function controlPagedResult($link, $pageSize, $isCritical) { + } + + /** +- * @param LDAP $link +- * @param LDAP $result +- * @return mixed ++ * {@inheritDoc} + */ + public function countEntries($link, $result) { + return $this->invokeLDAPMethod('count_entries', $link, $result); + } + + /** +- * @param LDAP $link +- * @return integer ++ * {@inheritDoc} + */ + public function errno($link) { + return $this->invokeLDAPMethod('errno', $link); + } + + /** +- * @param LDAP $link +- * @return string ++ * {@inheritDoc} + */ + public function error($link) { + return $this->invokeLDAPMethod('error', $link); +@@ -152,56 +143,42 @@ public function explodeDN($dn, $withAttrib) { + } + + /** +- * @param LDAP $link +- * @param LDAP $result +- * @return mixed ++ * {@inheritDoc} + */ + public function firstEntry($link, $result) { + return $this->invokeLDAPMethod('first_entry', $link, $result); + } + + /** +- * @param LDAP $link +- * @param LDAP $result +- * @return array|mixed ++ * {@inheritDoc} + */ + public function getAttributes($link, $result) { + return $this->invokeLDAPMethod('get_attributes', $link, $result); + } + + /** +- * @param LDAP $link +- * @param LDAP $result +- * @return mixed|string ++ * {@inheritDoc} + */ + public function getDN($link, $result) { + return $this->invokeLDAPMethod('get_dn', $link, $result); + } + + /** +- * @param LDAP $link +- * @param LDAP $result +- * @return array|mixed ++ * {@inheritDoc} + */ + public function getEntries($link, $result) { + return $this->invokeLDAPMethod('get_entries', $link, $result); + } + + /** +- * @param LDAP $link +- * @param resource $result +- * @return mixed ++ * {@inheritDoc} + */ + public function nextEntry($link, $result) { + return $this->invokeLDAPMethod('next_entry', $link, $result); + } + + /** +- * @param LDAP $link +- * @param string $baseDN +- * @param string $filter +- * @param array $attr +- * @return mixed ++ * {@inheritDoc} + */ + public function read($link, $baseDN, $filter, $attr) { + $this->pagedResultsAdapter->setReadArgs($link, $baseDN, $filter, $attr); +@@ -209,14 +186,7 @@ public function read($link, $baseDN, $filter, $attr) { + } + + /** +- * @param LDAP $link +- * @param string[] $baseDN +- * @param string $filter +- * @param array $attr +- * @param int $attrsOnly +- * @param int $limit +- * @return mixed +- * @throws \Exception ++ * {@inheritDoc} + */ + public function search($link, $baseDN, $filter, $attr, $attrsOnly = 0, $limit = 0) { + $oldHandler = set_error_handler(function ($no, $message, $file, $line) use (&$oldHandler) { +@@ -239,47 +209,35 @@ public function search($link, $baseDN, $filter, $attr, $attrsOnly = 0, $limit = + } + + /** +- * @param LDAP $link +- * @param string $userDN +- * @param string $password +- * @return bool ++ * {@inheritDoc} + */ + public function modReplace($link, $userDN, $password) { + return $this->invokeLDAPMethod('mod_replace', $link, $userDN, ['userPassword' => $password]); + } + + /** +- * @param LDAP $link +- * @param string $userDN +- * @param string $oldPassword +- * @param string $password +- * @return bool ++ * {@inheritDoc} + */ + public function exopPasswd($link, $userDN, $oldPassword, $password) { + return $this->invokeLDAPMethod('exop_passwd', $link, $userDN, $oldPassword, $password); + } + + /** +- * @param LDAP $link +- * @param string $option +- * @param int $value +- * @return bool|mixed ++ * {@inheritDoc} + */ + public function setOption($link, $option, $value) { + return $this->invokeLDAPMethod('set_option', $link, $option, $value); + } + + /** +- * @param LDAP $link +- * @return mixed|true ++ * {@inheritDoc} + */ + public function startTls($link) { + return $this->invokeLDAPMethod('start_tls', $link); + } + + /** +- * @param resource $link +- * @return bool|mixed ++ * {@inheritDoc} + */ + public function unbind($link) { + return $this->invokeLDAPMethod('unbind', $link); +@@ -294,12 +252,10 @@ public function areLDAPFunctionsAvailable() { + } + + /** +- * Checks whether the submitted parameter is a resource +- * @param Resource $resource the resource variable to check +- * @return bool true if it is a resource, false otherwise ++ * {@inheritDoc} + */ + public function isResource($resource) { +- return is_resource($resource); ++ return is_resource($resource) || is_object($resource); + } + + /** +@@ -368,7 +324,7 @@ private function preFunctionCall($functionName, $args) { + /** + * Analyzes the returned LDAP error and acts accordingly if not 0 + * +- * @param resource $resource the LDAP Connection resource ++ * @param resource|\LDAP\Connection $resource the LDAP Connection resource + * @throws ConstraintViolationException + * @throws ServerNotAvailableException + * @throws \Exception +diff --git a/apps/user_ldap/lib/LDAPProvider.php b/apps/user_ldap/lib/LDAPProvider.php +index dd86ce486ac9..751ebf687684 100644 +--- a/apps/user_ldap/lib/LDAPProvider.php ++++ b/apps/user_ldap/lib/LDAPProvider.php +@@ -149,7 +149,7 @@ public function sanitizeDN($dn) { + * Return a new LDAP connection resource for the specified user. + * The connection must be closed manually. + * @param string $uid user id +- * @return resource of the LDAP connection ++ * @return resource|\LDAP\Connection The LDAP connection + * @throws \Exception if user id was not found in LDAP + */ + public function getLDAPConnection($uid) { +@@ -163,7 +163,7 @@ public function getLDAPConnection($uid) { + * Return a new LDAP connection resource for the specified user. + * The connection must be closed manually. + * @param string $gid group id +- * @return resource of the LDAP connection ++ * @return resource|\LDAP\Connection The LDAP connection + * @throws \Exception if group id was not found in LDAP + */ + public function getGroupLDAPConnection($gid) { +diff --git a/apps/user_ldap/lib/PagedResults/IAdapter.php b/apps/user_ldap/lib/PagedResults/IAdapter.php +index 2dd9ffe80a16..31338126e405 100644 +--- a/apps/user_ldap/lib/PagedResults/IAdapter.php ++++ b/apps/user_ldap/lib/PagedResults/IAdapter.php +@@ -82,7 +82,7 @@ public function getResponseCallArgs(array $originalArgs): array; + /** + * the adapter should do it's LDAP function call and return success state + * +- * @param resource $link LDAP resource ++ * @param resource|\LDAP\Connection $link LDAP resource + * @return bool + */ + public function responseCall($link): bool; +@@ -123,7 +123,7 @@ public function getReadArgs($link): array; + /** + * Returns the current paged results cookie + * +- * @param resource $link LDAP resource ++ * @param resource|\LDAP\Connection $link LDAP resource + * @return string + */ + public function getCookie($link): string; +diff --git a/apps/user_ldap/lib/PagedResults/TLinkId.php b/apps/user_ldap/lib/PagedResults/TLinkId.php +index 6f320705e67e..02c36da97f92 100644 +--- a/apps/user_ldap/lib/PagedResults/TLinkId.php ++++ b/apps/user_ldap/lib/PagedResults/TLinkId.php +@@ -28,10 +28,16 @@ + + trait TLinkId { + public function getLinkId($link) { +- if (is_resource($link)) { ++ if (is_object($link)) { ++ return spl_object_id($link); ++ } elseif (is_resource($link)) { + return (int)$link; +- } elseif (is_array($link) && isset($link[0]) && is_resource($link[0])) { +- return (int)$link[0]; ++ } elseif (is_array($link) && isset($link[0])) { ++ if (is_object($link[0])) { ++ return spl_object_id($link[0]); ++ } elseif (is_resource($link[0])) { ++ return (int)$link[0]; ++ } + } + throw new \RuntimeException('No resource provided'); + } +diff --git a/apps/user_ldap/lib/User/Manager.php b/apps/user_ldap/lib/User/Manager.php +index 63af3cf17709..e752b113e3f1 100644 +--- a/apps/user_ldap/lib/User/Manager.php ++++ b/apps/user_ldap/lib/User/Manager.php +@@ -177,7 +177,7 @@ public function getAttributes($minimal = false) { + $this->access->getConnection()->ldapExtStorageHomeAttribute, + ]; + +- $homeRule = $this->access->getConnection()->homeFolderNamingRule; ++ $homeRule = (string)$this->access->getConnection()->homeFolderNamingRule; + if (strpos($homeRule, 'attr:') === 0) { + $attributes[] = substr($homeRule, strlen('attr:')); + } +diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php +index a0955f94bb4f..ab1500ff3689 100644 +--- a/apps/user_ldap/lib/User/User.php ++++ b/apps/user_ldap/lib/User/User.php +@@ -464,9 +464,9 @@ public function updateEmail($valueFromLDAP = null) { + * bytes), '1234 MB' (quota in MB - check the \OC_Helper::computerFileSize method for more info) + * + * fetches the quota from LDAP and stores it as Nextcloud user value +- * @param string $valueFromLDAP the quota attribute's value can be passed, ++ * @param ?string $valueFromLDAP the quota attribute's value can be passed, + * to save the readAttribute request +- * @return null ++ * @return void + */ + public function updateQuota($valueFromLDAP = null) { + if ($this->wasRefreshed('quota')) { +@@ -487,7 +487,7 @@ public function updateQuota($valueFromLDAP = null) { + } elseif (is_array($aQuota) && isset($aQuota[0])) { + $this->logger->debug('no suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', ['app' => 'user_ldap']); + } +- } elseif ($this->verifyQuotaValue($valueFromLDAP)) { ++ } elseif (!is_null($valueFromLDAP) && $this->verifyQuotaValue($valueFromLDAP)) { + $quota = $valueFromLDAP; + } else { + $this->logger->debug('no suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', ['app' => 'user_ldap']); +@@ -509,7 +509,7 @@ public function updateQuota($valueFromLDAP = null) { + } + } + +- private function verifyQuotaValue($quotaValue) { ++ private function verifyQuotaValue(string $quotaValue) { + return $quotaValue === 'none' || $quotaValue === 'default' || \OC_Helper::computerFileSize($quotaValue) !== false; + } + +diff --git a/apps/user_ldap/lib/User_LDAP.php b/apps/user_ldap/lib/User_LDAP.php +index b1d4da9514d6..9cd90451ea37 100644 +--- a/apps/user_ldap/lib/User_LDAP.php ++++ b/apps/user_ldap/lib/User_LDAP.php +@@ -617,7 +617,7 @@ public function getLDAPAccess($uid) { + * The cloned connection needs to be closed manually. + * of the current access. + * @param string $uid +- * @return resource of the LDAP connection ++ * @return resource|\LDAP\Connection The LDAP connection + */ + public function getNewLDAPConnection($uid) { + $connection = clone $this->access->getConnection(); +diff --git a/apps/user_ldap/lib/User_Proxy.php b/apps/user_ldap/lib/User_Proxy.php +index 5731f314aede..183c90493cfa 100644 +--- a/apps/user_ldap/lib/User_Proxy.php ++++ b/apps/user_ldap/lib/User_Proxy.php +@@ -368,7 +368,7 @@ public function getLDAPAccess($uid) { + * The connection needs to be closed manually. + * + * @param string $uid +- * @return resource of the LDAP connection ++ * @return resource|\LDAP\Connection The LDAP connection + */ + public function getNewLDAPConnection($uid) { + return $this->handleRequest($uid, 'getNewLDAPConnection', [$uid]); +diff --git a/apps/user_ldap/lib/Wizard.php b/apps/user_ldap/lib/Wizard.php +index 9b037b471347..98d399b77b94 100644 +--- a/apps/user_ldap/lib/Wizard.php ++++ b/apps/user_ldap/lib/Wizard.php +@@ -820,7 +820,7 @@ private function detectGroupMemberAssoc() { + return false; + } + $er = $this->ldap->firstEntry($cr, $rr); +- while (is_resource($er)) { ++ while ($this->ldap->isResource($er)) { + $this->ldap->getDN($cr, $er); + $attrs = $this->ldap->getAttributes($cr, $er); + $result = []; +@@ -1066,7 +1066,7 @@ private function connectAndBind($port, $tls) { + ['app' => 'user_ldap'] + ); + $cr = $this->ldap->connect($host, $port); +- if (!is_resource($cr)) { ++ if (!$this->ldap->isResource($cr)) { + throw new \Exception(self::$l->t('Invalid Host')); + } + +@@ -1276,7 +1276,7 @@ private function determineFeature($objectclasses, $attr, $dbkey, $confkey, $po = + + /** + * appends a list of values fr +- * @param resource $result the return value from ldap_get_attributes ++ * @param array $result the return value from ldap_get_attributes + * @param string $attribute the attribute values to look for + * @param array &$known new values will be appended here + * @return int, state on of the class constants LRESULT_PROCESSED_OK, + +From 743267eba4bf0558337dcb47f0f8c382f2b25b69 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <[email protected]> +Date: Mon, 29 Nov 2021 11:42:27 +0100 +Subject: [PATCH 07/12] Fix LDAP related docblocks types +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Côme Chilliet <[email protected]> +--- + apps/user_ldap/lib/ILDAPWrapper.php | 2 +- + lib/public/LDAP/ILDAPProvider.php | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/apps/user_ldap/lib/ILDAPWrapper.php b/apps/user_ldap/lib/ILDAPWrapper.php +index 9917898a001b..3f600a40cc0e 100644 +--- a/apps/user_ldap/lib/ILDAPWrapper.php ++++ b/apps/user_ldap/lib/ILDAPWrapper.php +@@ -147,7 +147,7 @@ public function nextEntry($link, $result); + /** + * Read an entry + * @param resource|\LDAP\Connection $link LDAP link resource +- * @param array $baseDN The DN of the entry to read from ++ * @param string $baseDN The DN of the entry to read from + * @param string $filter An LDAP filter + * @param array $attr array of the attributes to read + * @return resource|\LDAP\Result an LDAP search result resource +diff --git a/lib/public/LDAP/ILDAPProvider.php b/lib/public/LDAP/ILDAPProvider.php +index 0355a0052c41..8fad3bd2266e 100644 +--- a/lib/public/LDAP/ILDAPProvider.php ++++ b/lib/public/LDAP/ILDAPProvider.php +@@ -79,7 +79,7 @@ public function sanitizeDN($dn); + /** + * Return a new LDAP connection resource for the specified user. + * @param string $uid user id +- * @return resource of the LDAP connection ++ * @return \LDAP\Connection|resource + * @since 11.0.0 + */ + public function getLDAPConnection($uid); +@@ -87,7 +87,7 @@ public function getLDAPConnection($uid); + /** + * Return a new LDAP connection resource for the specified group. + * @param string $gid group id +- * @return resource of the LDAP connection ++ * @return \LDAP\Connection|resource + * @since 13.0.0 + */ + public function getGroupLDAPConnection($gid); + +From 72baee96988bbd9d3f7d68a90bf716008946000f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <[email protected]> +Date: Thu, 2 Dec 2021 16:31:19 +0100 +Subject: [PATCH 09/12] Allow minor release of PHP 8.1 to be used as well +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +No reason to allow 8.1.0 and not 8.1.1. + +Signed-off-by: Côme Chilliet <[email protected]> +--- + lib/versioncheck.php | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/lib/versioncheck.php b/lib/versioncheck.php +index 8aa68dd35fdd..3e840ff5b461 100644 +--- a/lib/versioncheck.php ++++ b/lib/versioncheck.php +@@ -33,10 +33,10 @@ + exit(1); + } + +-// Show warning if > PHP 8.1 is used as Nextcloud is not compatible with > PHP 8.1 for now +-if (PHP_VERSION_ID > 80100) { ++// Show warning if >= PHP 8.2 is used as Nextcloud is not compatible with >= PHP 8.2 for now ++if (PHP_VERSION_ID >= 80200) { + http_response_code(500); +- echo 'This version of Nextcloud is not compatible with > PHP 8.1.<br/>'; ++ echo 'This version of Nextcloud is not compatible with PHP>=8.2.<br/>'; + echo 'You are currently running ' . PHP_VERSION . '.'; + exit(1); + } + +From c3a1a66eaefac9e06385d125dd4edae3117cc9eb Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <[email protected]> +Date: Thu, 16 Dec 2021 10:35:03 +0100 +Subject: [PATCH 12/12] Avoid deprecation warnings about + libxml_disable_entity_loader in PHP 8.1 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Côme Chilliet <[email protected]> +--- + lib/private/Updater/ChangesCheck.php | 10 +++++++--- + lib/private/Updater/VersionCheck.php | 10 +++++++--- + 2 files changed, 14 insertions(+), 6 deletions(-) + +diff --git a/lib/private/Updater/ChangesCheck.php b/lib/private/Updater/ChangesCheck.php +index 600c8db9a3c2..e3ced6e5b123 100644 +--- a/lib/private/Updater/ChangesCheck.php ++++ b/lib/private/Updater/ChangesCheck.php +@@ -138,9 +138,13 @@ protected function queryChangesServer(string $uri, ChangesResult $entry): IRespo + protected function extractData($body):array { + $data = []; + if ($body) { +- $loadEntities = libxml_disable_entity_loader(true); +- $xml = @simplexml_load_string($body); +- libxml_disable_entity_loader($loadEntities); ++ if (\LIBXML_VERSION < 20900) { ++ $loadEntities = libxml_disable_entity_loader(true); ++ $xml = @simplexml_load_string($body); ++ libxml_disable_entity_loader($loadEntities); ++ } else { ++ $xml = @simplexml_load_string($body); ++ } + if ($xml !== false) { + $data['changelogURL'] = (string)$xml->changelog['href']; + $data['whatsNew'] = []; +diff --git a/lib/private/Updater/VersionCheck.php b/lib/private/Updater/VersionCheck.php +index ffa707d89909..d9f795796b8c 100644 +--- a/lib/private/Updater/VersionCheck.php ++++ b/lib/private/Updater/VersionCheck.php +@@ -95,9 +95,13 @@ public function check() { + } + + if ($xml) { +- $loadEntities = libxml_disable_entity_loader(true); +- $data = @simplexml_load_string($xml); +- libxml_disable_entity_loader($loadEntities); ++ if (\LIBXML_VERSION < 20900) { ++ $loadEntities = libxml_disable_entity_loader(true); ++ $data = @simplexml_load_string($xml); ++ libxml_disable_entity_loader($loadEntities); ++ } else { ++ $data = @simplexml_load_string($xml); ++ } + if ($data !== false) { + $tmp['version'] = (string)$data->version; + $tmp['versionstring'] = (string)$data->versionstring;
