diff options
author | Maxence Lange <maxence@nextcloud.com> | 2017-05-22 14:21:09 +0300 |
---|---|---|
committer | Maxence Lange <maxence@nextcloud.com> | 2017-05-22 14:21:09 +0300 |
commit | a689488c47519886bb6f45403049abda496b614e (patch) | |
tree | c95d940c510d716ca5a08a9b373c8298654550e5 /lib | |
parent | 33013bf89e7bea1e1c46a0f39f5f1a62321a4119 (diff) |
compat php5.6
Signed-off-by: Maxence Lange <maxence@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Api/Circles.php | 8 | ||||
-rw-r--r-- | lib/Controller/FederatedController.php | 22 | ||||
-rw-r--r-- | lib/Db/CirclesMapper.php | 24 | ||||
-rw-r--r-- | lib/Db/CirclesRequest.php | 16 | ||||
-rw-r--r-- | lib/Db/CirclesRequestBuilder.php | 4 | ||||
-rw-r--r-- | lib/Db/FederatedLinksRequest.php | 10 | ||||
-rw-r--r-- | lib/IBroadcaster.php | 2 | ||||
-rw-r--r-- | lib/Model/BaseCircle.php | 4 | ||||
-rw-r--r-- | lib/Model/FederatedLink.php | 36 | ||||
-rw-r--r-- | lib/Model/SharingFrame.php | 29 | ||||
-rw-r--r-- | lib/Service/BroadcastService.php | 8 | ||||
-rw-r--r-- | lib/Service/FederatedService.php | 15 | ||||
-rw-r--r-- | lib/Service/SharesService.php | 12 |
13 files changed, 86 insertions, 104 deletions
diff --git a/lib/Api/Circles.php b/lib/Api/Circles.php index dfc1ecfc..b662f0e7 100644 --- a/lib/Api/Circles.php +++ b/lib/Api/Circles.php @@ -72,16 +72,16 @@ class Circles { public static function shareToCircle( - int $circleId, string $source, string $type, array $payload, string $broadcaster + $circleId, $source, $type, array $payload, $broadcaster ) { $c = self::getContainer(); - $frame = new SharingFrame($source, $type); - $frame->setCircleId($circleId); + $frame = new SharingFrame((string)$source, (string)$type); + $frame->setCircleId((int)$circleId); $frame->setPayload($payload); return $c->query('SharesService') - ->createFrame($frame, $broadcaster); + ->createFrame($frame, (string)$broadcaster); } diff --git a/lib/Controller/FederatedController.php b/lib/Controller/FederatedController.php index 172d6074..e7fc5e52 100644 --- a/lib/Controller/FederatedController.php +++ b/lib/Controller/FederatedController.php @@ -190,26 +190,10 @@ class FederatedController extends BaseController { return $this->federatedFail('shares_is_already_known'); } + $this->asyncAndLeaveClientOutOfThis('done'); - // $this->sharesService->proceedFrame($token, $uniqueId$frame); - //$frame->setCircleId(); - // TODO: SAVE THE FRAME, BROADCAST, DELIVER -// $this->miscService->log( -// "receiveFederatedDelivery start " . $token . ' ' . var_export($item, true) . ' ' -// . $uniqueId -// ); - // $this->miscService->log( - // ' ' . $item . ' ' - // . $frame->getHeader('address') - // ); - - // We don't want to keep the connection with the client up and running - // as he might have others things to do - // $this->asyncAndLeaveClientOutOfThis('done'); - - // sleep(15); - // $this->miscService->log("receiveFederatedDelivery end"); - // exit(); + $this->federatedService->sendRemoteShare($frame); + exit(); } /** diff --git a/lib/Db/CirclesMapper.php b/lib/Db/CirclesMapper.php index 3f2c4f0e..ae976e0b 100644 --- a/lib/Db/CirclesMapper.php +++ b/lib/Db/CirclesMapper.php @@ -195,11 +195,11 @@ class CirclesMapper extends Mapper { * @param string $field * @param int $circleId */ - private function buildWithCircleId(IQueryBuilder & $qb, string $field, int $circleId) { + private function buildWithCircleId(IQueryBuilder & $qb, $field, $circleId) { if ($circleId > 0) { $qb->andWhere( $qb->expr() - ->eq($field, $qb->createNamedParameter($circleId)) + ->eq((string)$field, $qb->createNamedParameter((int)$circleId)) ); } } @@ -210,11 +210,11 @@ class CirclesMapper extends Mapper { * @param string $field * @param int $level */ - private function buildWithMemberLevel(IQueryBuilder & $qb, string $field, int $level) { + private function buildWithMemberLevel(IQueryBuilder & $qb, $field, $level) { if ($level > 0) { $qb->andWhere( $qb->expr() - ->gte($field, $qb->createNamedParameter($level)) + ->gte((string)$field, $qb->createNamedParameter((int)$level)) ); } } @@ -227,7 +227,7 @@ class CirclesMapper extends Mapper { * * @return \OCP\DB\QueryBuilder\ICompositeExpression */ - private function generateTypeEntryForCirclePersonal(IQueryBuilder $qb, int $type, string $userId + private function generateTypeEntryForCirclePersonal(IQueryBuilder $qb, $type, $userId ) { if (Circle::CIRCLES_PERSONAL & (int)$type) { $expr = $qb->expr(); @@ -236,7 +236,7 @@ class CirclesMapper extends Mapper { return $qb->expr() ->andX( $expr->eq('c.type', $qb->createNamedParameter(Circle::CIRCLES_PERSONAL)), - $expr->eq('o.user_id', $qb->createNamedParameter($userId)) + $expr->eq('o.user_id', $qb->createNamedParameter((string)$userId)) ); } @@ -252,9 +252,7 @@ class CirclesMapper extends Mapper { * * @return string */ - private function generateTypeEntryForCircleHidden( - IQueryBuilder $qb, int $type, int $circleId, string $name - ) { + private function generateTypeEntryForCircleHidden(IQueryBuilder $qb, $type, $circleId, $name) { if (!(Circle::CIRCLES_HIDDEN & (int)$type)) { return null; } @@ -267,8 +265,8 @@ class CirclesMapper extends Mapper { $expr->gte( 'u.level', $qb->createNamedParameter(Member::LEVEL_MEMBER) ), - $expr->eq('c.id', $qb->createNamedParameter($circleId)), - $expr->eq('c.name', $qb->createNamedParameter($name)) + $expr->eq('c.id', $qb->createNamedParameter((string)$circleId)), + $expr->eq('c.name', $qb->createNamedParameter((string)$name)) ) ); @@ -282,7 +280,7 @@ class CirclesMapper extends Mapper { * * @return string */ - private function generateTypeEntryForCirclePrivate(IQueryBuilder $qb, int $type) { + private function generateTypeEntryForCirclePrivate(IQueryBuilder $qb, $type) { if (Circle::CIRCLES_PRIVATE & (int)$type) { return $qb->expr() ->eq( @@ -301,7 +299,7 @@ class CirclesMapper extends Mapper { * * @return string */ - private function generateTypeEntryForCirclePublic(IQueryBuilder $qb, int $type) { + private function generateTypeEntryForCirclePublic(IQueryBuilder $qb, $type) { if (Circle::CIRCLES_PUBLIC & (int)$type) { return $qb->expr() ->eq( diff --git a/lib/Db/CirclesRequest.php b/lib/Db/CirclesRequest.php index 3949b59c..c8058444 100644 --- a/lib/Db/CirclesRequest.php +++ b/lib/Db/CirclesRequest.php @@ -125,9 +125,9 @@ class CirclesRequest extends CirclesRequestBuilder { * * @return Circle */ - public function getCircle(string $uniqueId) { + public function getCircle($uniqueId) { $qb = $this->getCirclesSelectSql(); - $this->limitToUniqueId($qb, $uniqueId); + $this->limitToUniqueId($qb, (string) $uniqueId); $cursor = $qb->execute(); $data = $cursor->fetch(); @@ -143,10 +143,10 @@ class CirclesRequest extends CirclesRequestBuilder { * * @return SharingFrame */ - public function getFrame(int $circleId, string $uniqueId) { + public function getFrame($circleId, $uniqueId) { $qb = $this->getSharesSelectSql(); - $this->limitToUniqueId($qb, $uniqueId); - $this->limitToCircleId($qb, $circleId); + $this->limitToUniqueId($qb, (string) $uniqueId); + $this->limitToCircleId($qb, (int) $circleId); $cursor = $qb->execute(); $data = $cursor->fetch(); @@ -163,10 +163,10 @@ class CirclesRequest extends CirclesRequestBuilder { * * @return FederatedLink */ - public function getLinkFromToken(string $token, string $uniqueId) { + public function getLinkFromToken($token, $uniqueId) { $qb = $this->getLinksSelectSql(); - $this->limitToUniqueId($qb, $uniqueId); - $this->limitToToken($qb, $token); + $this->limitToUniqueId($qb, (string) $uniqueId); + $this->limitToToken($qb, (string) $token); $cursor = $qb->execute(); $data = $cursor->fetch(); diff --git a/lib/Db/CirclesRequestBuilder.php b/lib/Db/CirclesRequestBuilder.php index 3fa5040e..b47cc51b 100644 --- a/lib/Db/CirclesRequestBuilder.php +++ b/lib/Db/CirclesRequestBuilder.php @@ -242,12 +242,12 @@ class CirclesRequestBuilder { * * @return IQueryBuilder */ - protected function getSharesUpdateSql(string $uniqueId) { + protected function getSharesUpdateSql($uniqueId) { $qb = $this->dbConnection->getQueryBuilder(); $qb->update('circles_shares') ->where( $qb->expr() - ->eq('unique_id', $qb->createNamedParameter($uniqueId)) + ->eq('unique_id', $qb->createNamedParameter((string) $uniqueId)) ); return $qb; diff --git a/lib/Db/FederatedLinksRequest.php b/lib/Db/FederatedLinksRequest.php index 932495c1..1173f669 100644 --- a/lib/Db/FederatedLinksRequest.php +++ b/lib/Db/FederatedLinksRequest.php @@ -76,13 +76,13 @@ class FederatedLinksRequest extends FederatedLinksRequestBuilder { * * @return FederatedLink[] */ - public function getLinked(int $circleId) { + public function getLinked($circleId) { $qb = $this->getLinksSelectSql(); $expr = $qb->expr(); $qb->where( $expr->andX( - $expr->eq('f.circle_id', $qb->createNamedParameter($circleId)), + $expr->eq('f.circle_id', $qb->createNamedParameter((int) $circleId)), $expr->eq('f.status', $qb->createNamedParameter(9)) ) ); @@ -105,14 +105,14 @@ class FederatedLinksRequest extends FederatedLinksRequestBuilder { * * @return FederatedLink */ - public function getFromUniqueId(int $circleId, string $uniqueId) { + public function getFromUniqueId($circleId, $uniqueId) { $qb = $this->getLinksSelectSql(); $expr = $qb->expr(); $qb->where( $expr->andX( - $expr->eq('f.circle_id', $qb->createNamedParameter($circleId)), - $expr->eq('f.unique_id', $qb->createNamedParameter($uniqueId)) + $expr->eq('f.circle_id', $qb->createNamedParameter((int) $circleId)), + $expr->eq('f.unique_id', $qb->createNamedParameter((string) $uniqueId)) ) ); diff --git a/lib/IBroadcaster.php b/lib/IBroadcaster.php index fa200d8f..b022a546 100644 --- a/lib/IBroadcaster.php +++ b/lib/IBroadcaster.php @@ -21,6 +21,6 @@ interface IBroadcaster { * * @return */ - public function broadcast(string $userId, SharingFrame $frame); + public function broadcast($userId, SharingFrame $frame); }
\ No newline at end of file diff --git a/lib/Model/BaseCircle.php b/lib/Model/BaseCircle.php index 3f387bd2..a12243d1 100644 --- a/lib/Model/BaseCircle.php +++ b/lib/Model/BaseCircle.php @@ -92,8 +92,8 @@ class BaseCircle { * * @return $this */ - public function setUniqueId(string $uniqueId) { - $this->uniqueId = $uniqueId; + public function setUniqueId($uniqueId) { + $this->uniqueId = (string) $uniqueId; return $this; } diff --git a/lib/Model/FederatedLink.php b/lib/Model/FederatedLink.php index 34600c60..84df59d8 100644 --- a/lib/Model/FederatedLink.php +++ b/lib/Model/FederatedLink.php @@ -76,8 +76,8 @@ class FederatedLink implements \JsonSerializable { * * @return FederatedLink */ - public function setId(int $id) { - $this->id = $id; + public function setId($id) { + $this->id = (int) $id; return $this; } @@ -95,8 +95,8 @@ class FederatedLink implements \JsonSerializable { * * @return $this */ - public function setToken(string $token) { - $this->token = $token; + public function setToken($token) { + $this->token = (string) $token; return $this; } @@ -124,8 +124,8 @@ class FederatedLink implements \JsonSerializable { * * @return FederatedLink */ - public function setAddress(string $address) { - $this->address = $address; + public function setAddress($address) { + $this->address = (string) $address; return $this; } @@ -143,8 +143,8 @@ class FederatedLink implements \JsonSerializable { * * @return FederatedLink */ - public function setLocalAddress(string $address) { - $this->localAddress = $address; + public function setLocalAddress($address) { + $this->localAddress = (string) $address; return $this; } @@ -162,8 +162,8 @@ class FederatedLink implements \JsonSerializable { * * @return FederatedLink */ - public function setCircleId(int $circleId) { - $this->circleId = $circleId; + public function setCircleId($circleId) { + $this->circleId = (int)$circleId; return $this; } @@ -181,8 +181,8 @@ class FederatedLink implements \JsonSerializable { * * @return FederatedLink */ - public function setUniqueId(string $uniqueId) { - $this->uniqueId = $uniqueId; + public function setUniqueId($uniqueId) { + $this->uniqueId = (string) $uniqueId; return $this; } @@ -200,8 +200,8 @@ class FederatedLink implements \JsonSerializable { * * @return FederatedLink */ - public function setRemoteCircleName(string $circleName) { - $this->remoteCircleName = $circleName; + public function setRemoteCircleName($circleName) { + $this->remoteCircleName = (string) $circleName; return $this; } @@ -219,8 +219,8 @@ class FederatedLink implements \JsonSerializable { * * @return FederatedLink */ - public function setCircleName(string $circleName) { - $this->localCircleName = $circleName; + public function setCircleName($circleName) { + $this->localCircleName = (string) $circleName; return $this; } @@ -238,8 +238,8 @@ class FederatedLink implements \JsonSerializable { * * @return FederatedLink */ - public function setStatus(int $status) { - $this->status = $status; + public function setStatus($status) { + $this->status = (int) $status; return $this; } diff --git a/lib/Model/SharingFrame.php b/lib/Model/SharingFrame.php index c57c4ba9..047b154d 100644 --- a/lib/Model/SharingFrame.php +++ b/lib/Model/SharingFrame.php @@ -58,9 +58,9 @@ class SharingFrame implements \JsonSerializable { /** @var string */ private $uniqueId; - public function __construct(string $source, string $type) { - $this->source = $source; - $this->type = $type; + public function __construct($source, $type) { + $this->source = (string)$source; + $this->type = (string)$type; } @@ -81,8 +81,8 @@ class SharingFrame implements \JsonSerializable { /** * @param int $circleId */ - public function setCircleId(int $circleId) { - $this->circleId = $circleId; + public function setCircleId($circleId) { + $this->circleId = (int)$circleId; } /** @@ -111,8 +111,8 @@ class SharingFrame implements \JsonSerializable { /** * @param string $author */ - public function setAuthor(string $author) { - $this->author = $author; + public function setAuthor($author) { + $this->author = (string)$author; } /** @@ -143,8 +143,8 @@ class SharingFrame implements \JsonSerializable { * * @return SharingFrame */ - public function setUniqueId(string $uniqueId) { - $this->uniqueId = $uniqueId; + public function setUniqueId($uniqueId) { + $this->uniqueId = (string)$uniqueId; return $this; } @@ -178,7 +178,7 @@ class SharingFrame implements \JsonSerializable { * * @return array|string */ - public function getPayload(bool $asJson = false) { + public function getPayload($asJson = false) { if ($asJson) { return json_encode($this->payload); } @@ -199,7 +199,7 @@ class SharingFrame implements \JsonSerializable { * * @return array|string */ - public function getHeaders(bool $asJson = false) { + public function getHeaders($asJson = false) { if ($asJson) { return json_encode($this->headers); } @@ -213,11 +213,12 @@ class SharingFrame implements \JsonSerializable { * * @return string */ - public function getHeader(string $k) { + public function getHeader($k) { if ($this->headers === null) { return null; } + $k = (string)$k; if (!key_exists($k, $this->headers)) { return null; } @@ -229,8 +230,8 @@ class SharingFrame implements \JsonSerializable { * @param string $k * @param string $v */ - public function setHeader(string $k, $v) { - $this->headers[$k] = $v; + public function setHeader($k, $v) { + $this->headers[(string)$k] = $v; } diff --git a/lib/Service/BroadcastService.php b/lib/Service/BroadcastService.php index baf97a0d..f5f81a8f 100644 --- a/lib/Service/BroadcastService.php +++ b/lib/Service/BroadcastService.php @@ -58,12 +58,12 @@ class BroadcastService { * @param MiscService $miscService */ public function __construct( - string $userId, + $userId, ConfigService $configService, CirclesRequest $circlesRequest, MiscService $miscService ) { - $this->userId = $userId; + $this->userId = (string) $userId; $this->configService = $configService; $this->circlesRequest = $circlesRequest; $this->miscService = $miscService; @@ -80,13 +80,13 @@ class BroadcastService { * * @throws BroadcasterIsNotCompatible */ - public function broadcastFrame(string $broadcast, SharingFrame $frame) { + public function broadcastFrame($broadcast, SharingFrame $frame) { if ($broadcast === null) { return; } - $broadcaster = \OC::$server->query($broadcast); + $broadcaster = \OC::$server->query((string) $broadcast); if (!($broadcaster instanceof IBroadcaster)) { throw new BroadcasterIsNotCompatible(); } diff --git a/lib/Service/FederatedService.php b/lib/Service/FederatedService.php index a003873e..24eb6f1f 100644 --- a/lib/Service/FederatedService.php +++ b/lib/Service/FederatedService.php @@ -100,7 +100,7 @@ class FederatedService { CirclesService $circlesService, BroadcastService $broadcastService, FederatedLinksRequest $federatedLinksRequest, - string $serverHost, + $serverHost, ClientService $clientService, MiscService $miscService ) { @@ -111,7 +111,7 @@ class FederatedService { $this->circlesService = $circlesService; $this->broadcastService = $broadcastService; $this->federatedLinksRequest = $federatedLinksRequest; - $this->serverHost = $serverHost; + $this->serverHost = (string)$serverHost; $this->clientService = $clientService; $this->miscService = $miscService; } @@ -338,9 +338,9 @@ class FederatedService { * @return bool * @throws Exception */ - public function receiveFrame(string $token, string $uniqueId, SharingFrame &$frame) { + public function receiveFrame($token, $uniqueId, SharingFrame &$frame) { - $link = $this->circlesRequest->getLinkFromToken($token, $uniqueId); + $link = $this->circlesRequest->getLinkFromToken((string)$token, (string)$uniqueId); if ($link === null) { return false; // TODO: throw Exception @@ -363,7 +363,6 @@ class FederatedService { $this->circlesRequest->saveFrame($frame); $this->broadcastService->broadcastFrame($frame->getHeader('broadcast'), $frame); - $this->sendRemoteShare($frame); return true; } @@ -396,10 +395,10 @@ class FederatedService { * @return bool * @throws Exception */ - public function initiateRemoteShare(int $circleId, string $uniqueId) { + public function initiateRemoteShare($circleId, $uniqueId) { $args = [ - 'circleId' => $circleId, - 'uniqueId' => $uniqueId + 'circleId' => (int)$circleId, + 'uniqueId' => (string)$uniqueId ]; $client = $this->clientService->newClient(); diff --git a/lib/Service/SharesService.php b/lib/Service/SharesService.php index 57d64999..b5208504 100644 --- a/lib/Service/SharesService.php +++ b/lib/Service/SharesService.php @@ -67,14 +67,14 @@ class SharesService { * @param MiscService $miscService */ public function __construct( - string $userId, + $userId, ConfigService $configService, CirclesRequest $circlesRequest, BroadcastService $broadcastService, FederatedService $federatedService, MiscService $miscService ) { - $this->userId = $userId; + $this->userId = (string) $userId; $this->configService = $configService; $this->circlesRequest = $circlesRequest; $this->broadcastService = $broadcastService; @@ -95,7 +95,7 @@ class SharesService { * * @throws MemberDoesNotExistException */ - public function createFrame(SharingFrame $frame, string $broadcast = null) { + public function createFrame(SharingFrame $frame, $broadcast = null) { $circle = $this->circlesRequest->getDetails($frame->getCircleId(), $this->userId); if ($circle->getUser() @@ -107,7 +107,7 @@ class SharesService { $frame->setAuthor($this->userId); $frame->setHeader('author', $this->userId); $frame->setHeader('circleName', $circle->getName()); - $frame->setHeader('broadcast', $broadcast); + $frame->setHeader('broadcast', (string) $broadcast); $frame->generateUniqueId(); $frame->setCircleName($circle->getName()); @@ -127,12 +127,12 @@ class SharesService { * * @return null|SharingFrame */ - public function getFrameFromUniqueId(int $circleId, $uniqueId) { + public function getFrameFromUniqueId($circleId, $uniqueId) { if ($uniqueId === null || $uniqueId === '') { return null; } - return $this->circlesRequest->getFrame($circleId, $uniqueId); + return $this->circlesRequest->getFrame((int) $circleId, (string) $uniqueId); } |