@@ -277,7 +277,7 @@ protected function formatShare(IShare $share, ?Node $recipientNode = null): arra
277277 /** @var array{share_with_displayname: string, share_with_link: string, share_with?: string, token?: string} $roomShare */
278278 $ roomShare = $ this ->getRoomShareHelper ()->formatShare ($ share );
279279 $ result = array_merge ($ result , $ roomShare );
280- } catch (QueryException $ e ) {
280+ } catch (ContainerExceptionInterface $ e ) {
281281 }
282282 } elseif ($ share ->getShareType () === IShare::TYPE_DECK ) {
283283 $ result ['share_with ' ] = $ share ->getSharedWith ();
@@ -287,7 +287,7 @@ protected function formatShare(IShare $share, ?Node $recipientNode = null): arra
287287 /** @var array{share_with: string, share_with_displayname: string, share_with_link: string} $deckShare */
288288 $ deckShare = $ this ->getDeckShareHelper ()->formatShare ($ share );
289289 $ result = array_merge ($ result , $ deckShare );
290- } catch (QueryException $ e ) {
290+ } catch (ContainerExceptionInterface $ e ) {
291291 }
292292 } elseif ($ share ->getShareType () === IShare::TYPE_SCIENCEMESH ) {
293293 $ result ['share_with ' ] = $ share ->getSharedWith ();
@@ -297,7 +297,7 @@ protected function formatShare(IShare $share, ?Node $recipientNode = null): arra
297297 /** @var array{share_with: string, share_with_displayname: string, token: string} $scienceMeshShare */
298298 $ scienceMeshShare = $ this ->getSciencemeshShareHelper ()->formatShare ($ share );
299299 $ result = array_merge ($ result , $ scienceMeshShare );
300- } catch (QueryException $ e ) {
300+ } catch (ContainerExceptionInterface $ e ) {
301301 }
302302 }
303303
@@ -632,7 +632,9 @@ public function createShare(
632632 $ share = $ this ->setShareAttributes ($ share , $ attributes );
633633 }
634634
635- // Expire date
635+ // Expire date checks
636+ // Normally, null means no expiration date but we still set the default for backwards compatibility
637+ // If the client sends an empty string, we set noExpirationDate to true
636638 if ($ expireDate !== null ) {
637639 if ($ expireDate !== '' ) {
638640 try {
@@ -746,7 +748,7 @@ public function createShare(
746748 $ share ->setSharedWith ($ shareWith );
747749 $ share ->setPermissions ($ permissions );
748750 } elseif ($ shareType === IShare::TYPE_CIRCLE ) {
749- if (!\OC :: $ server -> getAppManager ( )->isEnabledForUser ('circles ' ) || !class_exists ('\OCA\Circles\ShareByCircleProvider ' )) {
751+ if (!\OCP \Server:: get (IAppManager::class )->isEnabledForUser ('circles ' ) || !class_exists ('\OCA\Circles\ShareByCircleProvider ' )) {
750752 throw new OCSNotFoundException ($ this ->l ->t ('You cannot share to a Team if the app is not enabled ' ));
751753 }
752754
@@ -761,19 +763,19 @@ public function createShare(
761763 } elseif ($ shareType === IShare::TYPE_ROOM ) {
762764 try {
763765 $ this ->getRoomShareHelper ()->createShare ($ share , $ shareWith , $ permissions , $ expireDate ?? '' );
764- } catch (QueryException $ e ) {
766+ } catch (ContainerExceptionInterface $ e ) {
765767 throw new OCSForbiddenException ($ this ->l ->t ('Sharing %s failed because the back end does not support room shares ' , [$ node ->getPath ()]));
766768 }
767769 } elseif ($ shareType === IShare::TYPE_DECK ) {
768770 try {
769771 $ this ->getDeckShareHelper ()->createShare ($ share , $ shareWith , $ permissions , $ expireDate ?? '' );
770- } catch (QueryException $ e ) {
772+ } catch (ContainerExceptionInterface $ e ) {
771773 throw new OCSForbiddenException ($ this ->l ->t ('Sharing %s failed because the back end does not support room shares ' , [$ node ->getPath ()]));
772774 }
773775 } elseif ($ shareType === IShare::TYPE_SCIENCEMESH ) {
774776 try {
775777 $ this ->getSciencemeshShareHelper ()->createShare ($ share , $ shareWith , $ permissions , $ expireDate ?? '' );
776- } catch (QueryException $ e ) {
778+ } catch (ContainerExceptionInterface $ e ) {
777779 throw new OCSForbiddenException ($ this ->l ->t ('Sharing %s failed because the back end does not support ScienceMesh shares ' , [$ node ->getPath ()]));
778780 }
779781 } else {
@@ -1765,10 +1767,10 @@ public function cleanup() {
17651767 * Returns the helper of ShareAPIController for room shares.
17661768 *
17671769 * If the Talk application is not enabled or the helper is not available
1768- * a QueryException is thrown instead.
1770+ * a ContainerExceptionInterface is thrown instead.
17691771 *
17701772 * @return \OCA\Talk\Share\Helper\ShareAPIController
1771- * @throws QueryException
1773+ * @throws ContainerExceptionInterface
17721774 */
17731775 private function getRoomShareHelper () {
17741776 if (!$ this ->appManager ->isEnabledForUser ('spreed ' )) {
@@ -1782,10 +1784,10 @@ private function getRoomShareHelper() {
17821784 * Returns the helper of ShareAPIHelper for deck shares.
17831785 *
17841786 * If the Deck application is not enabled or the helper is not available
1785- * a QueryException is thrown instead.
1787+ * a ContainerExceptionInterface is thrown instead.
17861788 *
17871789 * @return \OCA\Deck\Sharing\ShareAPIHelper
1788- * @throws QueryException
1790+ * @throws ContainerExceptionInterface
17891791 */
17901792 private function getDeckShareHelper () {
17911793 if (!$ this ->appManager ->isEnabledForUser ('deck ' )) {
@@ -1799,10 +1801,10 @@ private function getDeckShareHelper() {
17991801 * Returns the helper of ShareAPIHelper for sciencemesh shares.
18001802 *
18011803 * If the sciencemesh application is not enabled or the helper is not available
1802- * a QueryException is thrown instead.
1804+ * a ContainerExceptionInterface is thrown instead.
18031805 *
18041806 * @return \OCA\Deck\Sharing\ShareAPIHelper
1805- * @throws QueryException
1807+ * @throws ContainerExceptionInterface
18061808 */
18071809 private function getSciencemeshShareHelper () {
18081810 if (!$ this ->appManager ->isEnabledForUser ('sciencemesh ' )) {
@@ -1935,7 +1937,7 @@ private function shareProviderResharingRights(string $userId, IShare $share, $no
19351937 return true ;
19361938 }
19371939
1938- if ($ share ->getShareType () === IShare::TYPE_CIRCLE && \OC :: $ server -> getAppManager ( )->isEnabledForUser ('circles ' )
1940+ if ($ share ->getShareType () === IShare::TYPE_CIRCLE && \OCP \Server:: get (IAppManager::class )->isEnabledForUser ('circles ' )
19391941 && class_exists ('\OCA\Circles\Api\v1\Circles ' )) {
19401942 $ hasCircleId = (str_ends_with ($ share ->getSharedWith (), '] ' ));
19411943 $ shareWithStart = ($ hasCircleId ? strrpos ($ share ->getSharedWith (), '[ ' ) + 1 : 0 );
@@ -1951,7 +1953,7 @@ private function shareProviderResharingRights(string $userId, IShare $share, $no
19511953 return true ;
19521954 }
19531955 return false ;
1954- } catch (QueryException $ e ) {
1956+ } catch (ContainerExceptionInterface $ e ) {
19551957 return false ;
19561958 }
19571959 }
0 commit comments