diff --git a/3rdparty b/3rdparty index a70e51b4cc..179b231245 160000 --- a/3rdparty +++ b/3rdparty @@ -1 +1 @@ -Subproject commit a70e51b4cce278e006090d91cf26d616cb73e911 +Subproject commit 179b231245bbae294d021b7158f99c3ffe7e2cb6 diff --git a/apps/dav/lib/CalDAV/BirthdayService.php b/apps/dav/lib/CalDAV/BirthdayService.php index 31ea38fc7b..208b923f53 100644 --- a/apps/dav/lib/CalDAV/BirthdayService.php +++ b/apps/dav/lib/CalDAV/BirthdayService.php @@ -256,6 +256,7 @@ class BirthdayService { $vCal = new VCalendar(); $vCal->VERSION = '2.0'; + $vCal->PRODID = '-//IDN nextcloud.com//Birthday calendar//EN'; $vEvent = $vCal->createComponent('VEVENT'); $vEvent->add('DTSTART'); $vEvent->DTSTART->setDateTime( diff --git a/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php b/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php index 0702d8fc9a..e285bbc378 100644 --- a/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php +++ b/apps/dav/lib/CalDAV/InvitationResponse/InvitationResponseServer.php @@ -94,7 +94,7 @@ class InvitationResponseServer { )); // wait with registering these until auth is handled and the filesystem is setup - $this->server->on('beforeMethod', function () use ($root) { + $this->server->on('beforeMethod:*', function () use ($root) { // register plugins from apps $pluginManager = new PluginManager( \OC::$server, diff --git a/apps/dav/lib/CalDAV/WebcalCaching/Plugin.php b/apps/dav/lib/CalDAV/WebcalCaching/Plugin.php index cea11de395..783c73968b 100644 --- a/apps/dav/lib/CalDAV/WebcalCaching/Plugin.php +++ b/apps/dav/lib/CalDAV/WebcalCaching/Plugin.php @@ -83,7 +83,7 @@ class Plugin extends ServerPlugin { */ public function initialize(Server $server) { $this->server = $server; - $server->on('beforeMethod', [$this, 'beforeMethod']); + $server->on('beforeMethod:*', [$this, 'beforeMethod']); } /** diff --git a/apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php b/apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php index de414e3aa2..79999f968a 100644 --- a/apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php +++ b/apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php @@ -46,7 +46,7 @@ class AnonymousOptionsPlugin extends ServerPlugin { public function initialize(\Sabre\DAV\Server $server) { $this->server = $server; // before auth - $this->server->on('beforeMethod', [$this, 'handleAnonymousOptions'], 9); + $this->server->on('beforeMethod:*', [$this, 'handleAnonymousOptions'], 9); } /** diff --git a/apps/dav/lib/Connector/Sabre/AppEnabledPlugin.php b/apps/dav/lib/Connector/Sabre/AppEnabledPlugin.php index 947b2960ea..896a6a5518 100644 --- a/apps/dav/lib/Connector/Sabre/AppEnabledPlugin.php +++ b/apps/dav/lib/Connector/Sabre/AppEnabledPlugin.php @@ -74,7 +74,7 @@ class AppEnabledPlugin extends ServerPlugin { public function initialize(\Sabre\DAV\Server $server) { $this->server = $server; - $this->server->on('beforeMethod', [$this, 'checkAppEnabled'], 30); + $this->server->on('beforeMethod:*', [$this, 'checkAppEnabled'], 30); } /** diff --git a/apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php b/apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php index 6d7a635f1d..07c7aad0d1 100644 --- a/apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php +++ b/apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php @@ -53,7 +53,7 @@ class BlockLegacyClientPlugin extends ServerPlugin { */ public function initialize(\Sabre\DAV\Server $server) { $this->server = $server; - $this->server->on('beforeMethod', [$this, 'beforeHandler'], 200); + $this->server->on('beforeMethod:*', [$this, 'beforeHandler'], 200); } /** diff --git a/apps/dav/lib/Connector/Sabre/LockPlugin.php b/apps/dav/lib/Connector/Sabre/LockPlugin.php index 0d5cad6d9a..077086c40d 100644 --- a/apps/dav/lib/Connector/Sabre/LockPlugin.php +++ b/apps/dav/lib/Connector/Sabre/LockPlugin.php @@ -45,7 +45,7 @@ class LockPlugin extends ServerPlugin { */ public function initialize(\Sabre\DAV\Server $server) { $this->server = $server; - $this->server->on('beforeMethod', [$this, 'getLock'], 50); + $this->server->on('beforeMethod:*', [$this, 'getLock'], 50); $this->server->on('afterMethod', [$this, 'releaseLock'], 50); } diff --git a/apps/dav/lib/Connector/Sabre/MaintenancePlugin.php b/apps/dav/lib/Connector/Sabre/MaintenancePlugin.php index 4076abe59f..67e57e788b 100644 --- a/apps/dav/lib/Connector/Sabre/MaintenancePlugin.php +++ b/apps/dav/lib/Connector/Sabre/MaintenancePlugin.php @@ -67,7 +67,7 @@ class MaintenancePlugin extends ServerPlugin { */ public function initialize(\Sabre\DAV\Server $server) { $this->server = $server; - $this->server->on('beforeMethod', [$this, 'checkMaintenanceMode'], 1); + $this->server->on('beforeMethod:*', [$this, 'checkMaintenanceMode'], 1); } /** diff --git a/apps/dav/lib/Connector/Sabre/ServerFactory.php b/apps/dav/lib/Connector/Sabre/ServerFactory.php index 9efd9ba7b5..d26e19c67c 100644 --- a/apps/dav/lib/Connector/Sabre/ServerFactory.php +++ b/apps/dav/lib/Connector/Sabre/ServerFactory.php @@ -140,7 +140,7 @@ class ServerFactory { } // wait with registering these until auth is handled and the filesystem is setup - $server->on('beforeMethod', function () use ($server, $objectTree, $viewCallBack) { + $server->on('beforeMethod:*', function () use ($server, $objectTree, $viewCallBack) { // ensure the skeleton is copied $userFolder = \OC::$server->getUserFolder(); diff --git a/apps/dav/lib/Files/Sharing/FilesDropPlugin.php b/apps/dav/lib/Files/Sharing/FilesDropPlugin.php index 7a34ef9507..4542d0b52d 100644 --- a/apps/dav/lib/Files/Sharing/FilesDropPlugin.php +++ b/apps/dav/lib/Files/Sharing/FilesDropPlugin.php @@ -61,7 +61,7 @@ class FilesDropPlugin extends ServerPlugin { * @throws MethodNotAllowed */ public function initialize(\Sabre\DAV\Server $server) { - $server->on('beforeMethod', [$this, 'beforeMethod'], 999); + $server->on('beforeMethod:*', [$this, 'beforeMethod'], 999); $this->enabled = false; } diff --git a/apps/dav/lib/Files/Sharing/PublicLinkCheckPlugin.php b/apps/dav/lib/Files/Sharing/PublicLinkCheckPlugin.php index 84401196b1..4c45a29902 100644 --- a/apps/dav/lib/Files/Sharing/PublicLinkCheckPlugin.php +++ b/apps/dav/lib/Files/Sharing/PublicLinkCheckPlugin.php @@ -52,7 +52,7 @@ class PublicLinkCheckPlugin extends ServerPlugin { * @return void */ public function initialize(\Sabre\DAV\Server $server) { - $server->on('beforeMethod', [$this, 'beforeMethod']); + $server->on('beforeMethod:*', [$this, 'beforeMethod']); } public function beforeMethod(RequestInterface $request, ResponseInterface $response){ diff --git a/apps/dav/lib/Server.php b/apps/dav/lib/Server.php index 2502d53997..230e72fd27 100644 --- a/apps/dav/lib/Server.php +++ b/apps/dav/lib/Server.php @@ -217,7 +217,7 @@ class Server { $this->server->addPlugin(new SearchPlugin($lazySearchBackend)); // wait with registering these until auth is handled and the filesystem is setup - $this->server->on('beforeMethod', function () use ($root, $lazySearchBackend) { + $this->server->on('beforeMethod:*', function () use ($root, $lazySearchBackend) { // custom properties plugin must be the last one $userSession = \OC::$server->getUserSession(); $user = $userSession->getUser(); diff --git a/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php b/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php index cf62b6eb05..f7972d37d4 100644 --- a/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php +++ b/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php @@ -82,9 +82,8 @@ class PluginTest extends TestCase { $this->book->expects($this->once())->method('setPublishStatus')->with(true); // setup request - $request = new Request(); + $request = new Request('POST', 'cal1'); $request->addHeader('Content-Type', 'application/xml'); - $request->setUrl('cal1'); $request->setBody(''); $response = new Response(); $this->plugin->httpPost($request, $response); @@ -95,9 +94,8 @@ class PluginTest extends TestCase { $this->book->expects($this->once())->method('setPublishStatus')->with(false); // setup request - $request = new Request(); + $request = new Request('POST', 'cal1'); $request->addHeader('Content-Type', 'application/xml'); - $request->setUrl('cal1'); $request->setBody(''); $response = new Response(); $this->plugin->httpPost($request, $response); diff --git a/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php b/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php index e38bd1810a..0bb4a8c4a3 100644 --- a/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php +++ b/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php @@ -91,6 +91,7 @@ class BirthdayServiceTest extends TestCase { $this->assertNull($cal); } else { $this->assertInstanceOf('Sabre\VObject\Component\VCalendar', $cal); + $this->assertEquals('-//IDN nextcloud.com//Birthday calendar//EN', $cal->PRODID->getValue()); $this->assertTrue(isset($cal->VEVENT)); $this->assertEquals('FREQ=YEARLY', $cal->VEVENT->RRULE->getValue()); $this->assertEquals($expectedSummary, $cal->VEVENT->SUMMARY->getValue()); @@ -259,21 +260,27 @@ class BirthdayServiceTest extends TestCase { ); } if ($expectedOp === 'create') { - $service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn(new VCalendar()); + $vCal = new VCalendar(); + $vCal->PRODID = '-//Nextcloud testing//mocked object//'; + + $service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn($vCal); $this->calDav->expects($this->exactly(3))->method('createCalendarObject')->withConsecutive( - [1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"], - [1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"], - [1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"] + [1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"], + [1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"], + [1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"] ); } if ($expectedOp === 'update') { - $service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn(new VCalendar()); + $vCal = new VCalendar(); + $vCal->PRODID = '-//Nextcloud testing//mocked object//'; + + $service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn($vCal); $service->expects($this->exactly(3))->method('birthdayEvenChanged')->willReturn(true); $this->calDav->expects($this->exactly(3))->method('getCalendarObject')->willReturn(['calendardata' => '']); $this->calDav->expects($this->exactly(3))->method('updateCalendarObject')->withConsecutive( - [1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"], - [1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"], - [1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"] + [1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"], + [1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"], + [1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"] ); } diff --git a/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php b/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php index 742f231287..b8cdb70b7f 100644 --- a/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php +++ b/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php @@ -47,7 +47,7 @@ class PluginTest extends TestCase { protected function setUp(): void { parent::setUp(); - + /** @var Auth | \PHPUnit_Framework_MockObject_MockObject $authBackend */ $authBackend = $this->getMockBuilder(Auth::class)->disableOriginalConstructor()->getMock(); $authBackend->method('isDavAuthenticated')->willReturn(true); @@ -75,9 +75,8 @@ class PluginTest extends TestCase { ]], ['mailto:wilfredo@example.com']); // setup request - $request = new Request(); + $request = new Request('POST', 'addressbook1.vcf'); $request->addHeader('Content-Type', 'application/xml'); - $request->setUrl('addressbook1.vcf'); $request->setBody('principal:principals/admin mailto:wilfredo@example.com'); $response = new Response(); $this->plugin->httpPost($request, $response); diff --git a/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php index f2012a87a3..29b549f3b4 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php @@ -54,7 +54,7 @@ class CopyEtagHeaderPluginTest extends TestCase { } public function testCopyEtag() { - $request = new \Sabre\Http\Request(); + $request = new \Sabre\Http\Request('GET', 'dummy.file'); $response = new \Sabre\Http\Response(); $response->setHeader('Etag', 'abcd'); @@ -64,7 +64,7 @@ class CopyEtagHeaderPluginTest extends TestCase { } public function testNoopWhenEmpty() { - $request = new \Sabre\Http\Request(); + $request = new \Sabre\Http\Request('GET', 'dummy.file'); $response = new \Sabre\Http\Response(); $this->plugin->afterMethod($request, $response); diff --git a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php index 473c0164d0..d24b4dfe96 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php @@ -172,7 +172,7 @@ class FakeLockerPluginTest extends TestCase { $this->assertSame(false, $this->fakeLockerPlugin->fakeLockProvider($request, $response)); - $expectedXml = 'MyPathinfinitySecond-1800opaquelocktoken:fe4f7f2437b151fbcb4e9f5c8118c6b1'; + $expectedXml = 'MyPathinfinitySecond-1800opaquelocktoken:fe4f7f2437b151fbcb4e9f5c8118c6b1'; $this->assertXmlStringEqualsXmlString($expectedXml, $response->getBody()); } diff --git a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php index 3af82f31f5..5ff1316752 100644 --- a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php @@ -62,7 +62,7 @@ class QuotaPluginTest extends TestCase { $this->init(0); $this->plugin->expects($this->never()) ->method('getFileChunking'); - $this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers); + $this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers); $length = $this->plugin->getLength(); $this->assertEquals($expected, $length); } @@ -75,7 +75,7 @@ class QuotaPluginTest extends TestCase { $this->plugin->expects($this->never()) ->method('getFileChunking'); - $this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers); + $this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers); $result = $this->plugin->checkQuota(''); $this->assertTrue($result); } @@ -90,7 +90,7 @@ class QuotaPluginTest extends TestCase { $this->plugin->expects($this->never()) ->method('getFileChunking'); - $this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers); + $this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers); $this->plugin->checkQuota(''); } @@ -102,7 +102,7 @@ class QuotaPluginTest extends TestCase { $this->plugin->expects($this->never()) ->method('getFileChunking'); - $this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers); + $this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers); $result = $this->plugin->checkQuota('/sub/test.txt'); $this->assertTrue($result); } @@ -187,7 +187,7 @@ class QuotaPluginTest extends TestCase { ->willReturn($mockChunking); $headers['OC-CHUNKED'] = 1; - $this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers); + $this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers); $result = $this->plugin->checkQuota('/sub/test.txt-chunking-12345-3-1'); $this->assertTrue($result); } @@ -224,7 +224,7 @@ class QuotaPluginTest extends TestCase { ->willReturn($mockChunking); $headers['OC-CHUNKED'] = 1; - $this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers); + $this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers); $this->plugin->checkQuota('/sub/test.txt-chunking-12345-3-1'); } diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php index 771d73dec5..3624a9cc30 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php @@ -92,7 +92,7 @@ abstract class RequestTestCase extends TestCase { * @return \Sabre\HTTP\Response * @throws \Exception */ - protected function request($view, $user, $password, $method, $url, $body = null, $headers = null) { + protected function request($view, $user, $password, $method, $url, $body = null, $headers = []) { if (is_string($body)) { $body = $this->getStream($body); } diff --git a/apps/dav/tests/unit/DAV/Sharing/PluginTest.php b/apps/dav/tests/unit/DAV/Sharing/PluginTest.php index 9eeaccc29d..9776d17642 100644 --- a/apps/dav/tests/unit/DAV/Sharing/PluginTest.php +++ b/apps/dav/tests/unit/DAV/Sharing/PluginTest.php @@ -47,7 +47,7 @@ class PluginTest extends TestCase { protected function setUp(): void { parent::setUp(); - + /** @var Auth | \PHPUnit_Framework_MockObject_MockObject $authBackend */ $authBackend = $this->getMockBuilder(Auth::class)->disableOriginalConstructor()->getMock(); $authBackend->method('isDavAuthenticated')->willReturn(true); @@ -77,9 +77,8 @@ class PluginTest extends TestCase { ]], ['mailto:wilfredo@example.com']); // setup request - $request = new Request(); + $request = new Request('POST', 'addressbook1.vcf'); $request->addHeader('Content-Type', 'application/xml'); - $request->setUrl('addressbook1.vcf'); $request->setBody('principal:principals/admin mailto:wilfredo@example.com'); $response = new Response(); $this->plugin->httpPost($request, $response); diff --git a/apps/dav/tests/unit/Files/Sharing/FilesDropPluginTest.php b/apps/dav/tests/unit/Files/Sharing/FilesDropPluginTest.php index 77646b2c9d..82a4515c7e 100644 --- a/apps/dav/tests/unit/Files/Sharing/FilesDropPluginTest.php +++ b/apps/dav/tests/unit/Files/Sharing/FilesDropPluginTest.php @@ -66,7 +66,7 @@ class FilesDropPluginTest extends TestCase { $this->server->expects($this->once()) ->method('on') ->with( - $this->equalTo('beforeMethod'), + $this->equalTo('beforeMethod:*'), $this->equalTo([$this->plugin, 'beforeMethod']), $this->equalTo(999) ); diff --git a/remote.php b/remote.php index 7d20b4fbdf..b1777e92f7 100644 --- a/remote.php +++ b/remote.php @@ -58,7 +58,7 @@ function handleException($e) { // we shall not log on RemoteException $server->addPlugin(new ExceptionLoggerPlugin('webdav', \OC::$server->getLogger())); } - $server->on('beforeMethod', function () use ($e) { + $server->on('beforeMethod:*', function () use ($e) { if ($e instanceof RemoteException) { switch ($e->getCode()) { case 503: