stable

Clone or download

Read-only

HTTP requests can be processed through a PSR-15 [0] middleware pipeline

This contribution introduce a way to process a PSR-7 [1] server request using only PSR-15 middlewares. This approach helps the developer to separate the different layers of the request processing and as a consequence it makes the request processing easier to test. This approach is also the one taken in the modern PHP ecosystem so it should not surprise new developers deep diving into the codebase. For now, this contribution makes the usage of a PSR-15 middleware pipeline opt-in. The routes available to upload files in the FRS and document manager has been converted to it as an example and because they were already using PSR-7 and PSR-15 interfaces. No functionnal change is expected. Part of request #13133: A REST API user can not download a document manager file [0] https://www.php-fig.org/psr/psr-15/ [1] https://www.php-fig.org/psr/psr-7/ Change-Id: I28e173b3ca99331d674d1ae8972e616d9cc029aa

Modified Files

Name
M plugins/docman/include/Download/DocmanFileDownloadController.php +7 −2 Go to diff View file
M plugins/docman/include/Upload/Document/DocumentBeingUploadedInformationProvider.php +7 −4 Go to diff View file
M plugins/docman/include/Upload/Version/VersionBeingUploadedInformationProvider.php +6 −5 Go to diff View file
M plugins/docman/include/docmanPlugin.class.php +6 −6 Go to diff View file
M plugins/docman/phpunit/Download/DocmanFileDownloadControllerTest.php +8 −10 Go to diff View file
M plugins/docman/phpunit/Upload/Document/DocumentBeingUploadedInformationProviderTest.php +24 −15 Go to diff View file
M plugins/docman/phpunit/Upload/Version/VersionBeingUploadedInformationProviderTest.php +13 −10 Go to diff View file
M plugins/document/include/Tree/DocumentTreeController.php +4 −7 Go to diff View file
M plugins/document/include/Tree/DocumentTreeProjectExtractor.php +3 −5 Go to diff View file
M plugins/document/include/Tree/DocumentTreeUnderConstructionController.php +4 −5 Go to diff View file
M plugins/frs/include/FRS/Upload/Tus/FileBeingUploadedInformationProvider.php +7 −4 Go to diff View file
M plugins/frs/include/frsPlugin.class.php +1 −1 Go to diff View file
M plugins/frs/phpunit/FRS/Upload/Tus/FileBeingUploadedInformationProviderTest.php +13 −9 Go to diff View file
M plugins/git/include/Git/GitRepositoryBrowserController.php +2 −3 Go to diff View file
M plugins/git/include/Git/HTTP/HTTPController.php +1 −3 Go to diff View file
M plugins/git/include/Git/RepositoryList/GitRepositoryListController.php +1 −4 Go to diff View file
A src/common/Http/Server/EmptyMiddlewareStackException.php +33 −0 Go to diff View file
A src/common/Http/Server/MiddlewareDispatcher.php +54 −0 Go to diff View file
A src/common/Http/Server/MissingMiddlewareResponseException.php +34 −0 Go to diff View file
A src/common/Http/Server/RequestHandlerAsMiddleware.php +46 −0 Go to diff View file
A src/common/Http/Server/SessionWriteCloseMiddleware.php +39 −0 Go to diff View file
M src/common/Project/Admin/Categories/IndexController.php +2 −2 Go to diff View file
M src/common/Project/Admin/Categories/UpdateController.php +2 −2 Go to diff View file
A src/common/REST/RESTCurrentUserMiddleware.php +61 −0 Go to diff View file
A src/common/Request/DispatchablePSR15Compatible.php +67 −0 Go to diff View file
M src/common/Request/DispatchableWithProject.php +3 −4 Go to diff View file
M src/common/Request/FrontRouter.php +2 −5 Go to diff View file
A src/common/Request/PSR15PipelineResponseEmissionException.php +33 −0 Go to diff View file
M src/common/Upload/FileUploadController.php +27 −58 Go to diff View file
M src/composer.json +2 −1 Go to diff View file
M src/composer.lock +56 −1 Go to diff View file
M src/www/api/index.php +9 −15 Go to diff View file
A tests/phpunit/common/Http/Server/MiddlewareDispatcherTest.php +83 −0 Go to diff View file
A tests/phpunit/common/Http/Server/RequestHandlerAsMiddlewareTest.php +51 −0 Go to diff View file
A tests/phpunit/common/REST/RESTCurrentUserMiddlewareTest.php +83 −0 Go to diff View file
A tests/phpunit/common/Request/DispatchablePSR15CompatibleTest.php +96 −0 Go to diff View file
M tests/phpunit/common/Request/FrontRouterTest.php +1 −36 Go to diff View file