@@ -135,25 +135,6 @@ class CodeIgniter
135
135
*/
136
136
protected static $ cacheTTL = 0 ;
137
137
138
- /**
139
- * Request path to use.
140
- *
141
- * @var string
142
- *
143
- * @deprecated No longer used.
144
- */
145
- protected $ path ;
146
-
147
- /**
148
- * Should the Response instance "pretend"
149
- * to keep from setting headers/cookies/etc
150
- *
151
- * @var bool
152
- *
153
- * @deprecated No longer used.
154
- */
155
- protected $ useSafeOutput = false ;
156
-
157
138
/**
158
139
* Context
159
140
* web: Invoked by HTTP request
@@ -171,7 +152,7 @@ class CodeIgniter
171
152
/**
172
153
* Whether to return Response object or send response.
173
154
*
174
- * @deprecated No longer used.
155
+ * @deprecated 4.4.0 No longer used.
175
156
*/
176
157
protected bool $ returnResponse = false ;
177
158
@@ -336,6 +317,8 @@ private function configureKint(): void
336
317
* tries to route the response, loads the controller and generally
337
318
* makes all the pieces work together.
338
319
*
320
+ * @param bool $returnResponse Used for testing purposes only.
321
+ *
339
322
* @return ResponseInterface|void
340
323
*/
341
324
public function run (?RouteCollectionInterface $ routes = null , bool $ returnResponse = false )
@@ -355,9 +338,9 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon
355
338
$ this ->getRequestObject ();
356
339
$ this ->getResponseObject ();
357
340
358
- $ this ->spoofRequestMethod ();
359
-
360
341
try {
342
+ $ this ->forceSecureAccess ();
343
+
361
344
$ this ->response = $ this ->handleRequest ($ routes , config (Cache::class), $ returnResponse );
362
345
} catch (ResponsableInterface |DeprecatedRedirectException $ e ) {
363
346
$ this ->outputBufferingEnd ();
@@ -381,22 +364,6 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon
381
364
$ this ->sendResponse ();
382
365
}
383
366
384
- /**
385
- * Set our Response instance to "pretend" mode so that things like
386
- * cookies and headers are not actually sent, allowing PHP 7.2+ to
387
- * not complain when ini_set() function is used.
388
- *
389
- * @return $this
390
- *
391
- * @deprecated No longer used.
392
- */
393
- public function useSafeOutput (bool $ safe = true )
394
- {
395
- $ this ->useSafeOutput = $ safe ;
396
-
397
- return $ this ;
398
- }
399
-
400
367
/**
401
368
* Invoked via php-cli command?
402
369
*/
@@ -433,8 +400,6 @@ public function disableFilters(): void
433
400
*/
434
401
protected function handleRequest (?RouteCollectionInterface $ routes , Cache $ cacheConfig , bool $ returnResponse = false )
435
402
{
436
- $ this ->forceSecureAccess ();
437
-
438
403
if ($ this ->request instanceof IncomingRequest && strtolower ($ this ->request ->getMethod ()) === 'cli ' ) {
439
404
return $ this ->response ->setStatusCode (405 )->setBody ('Method Not Allowed ' );
440
405
}
@@ -449,7 +414,7 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache
449
414
450
415
$ routeFilters = $ this ->tryToRouteIt ($ routes );
451
416
452
- $ uri = $ this ->determinePath ();
417
+ $ uri = $ this ->request -> getPath ();
453
418
454
419
if ($ this ->enableFilters ) {
455
420
// Start up the filters
@@ -621,6 +586,9 @@ protected function startBenchmark()
621
586
* @param CLIRequest|IncomingRequest $request
622
587
*
623
588
* @return $this
589
+ *
590
+ * @internal Used for testing purposes only.
591
+ * @testTag
624
592
*/
625
593
public function setRequest ($ request )
626
594
{
@@ -637,6 +605,8 @@ public function setRequest($request)
637
605
protected function getRequestObject ()
638
606
{
639
607
if ($ this ->request instanceof Request) {
608
+ $ this ->spoofRequestMethod ();
609
+
640
610
return ;
641
611
}
642
612
@@ -647,6 +617,8 @@ protected function getRequestObject()
647
617
}
648
618
649
619
$ this ->request = Services::request ();
620
+
621
+ $ this ->spoofRequestMethod ();
650
622
}
651
623
652
624
/**
@@ -808,14 +780,14 @@ protected function tryToRouteIt(?RouteCollectionInterface $routes = null)
808
780
// $routes is defined in Config/Routes.php
809
781
$ this ->router = Services::router ($ routes , $ this ->request );
810
782
811
- $ path = $ this ->determinePath ();
783
+ $ uri = $ this ->request -> getPath ();
812
784
813
785
$ this ->benchmark ->stop ('bootstrap ' );
814
786
$ this ->benchmark ->start ('routing ' );
815
787
816
788
$ this ->outputBufferingStart ();
817
789
818
- $ this ->controller = $ this ->router ->handle ($ path );
790
+ $ this ->controller = $ this ->router ->handle ($ uri );
819
791
$ this ->method = $ this ->router ->methodName ();
820
792
821
793
// If a {locale} segment was matched in the final route,
@@ -834,31 +806,12 @@ protected function tryToRouteIt(?RouteCollectionInterface $routes = null)
834
806
* on the CLI/IncomingRequest path.
835
807
*
836
808
* @return string
837
- */
838
- protected function determinePath ()
839
- {
840
- if (! empty ($ this ->path )) {
841
- return $ this ->path ;
842
- }
843
-
844
- return method_exists ($ this ->request , 'getPath ' ) ? $ this ->request ->getPath () : $ this ->request ->getUri ()->getPath ();
845
- }
846
-
847
- /**
848
- * Allows the request path to be set from outside the class,
849
- * instead of relying on CLIRequest or IncomingRequest for the path.
850
- *
851
- * This is not used now.
852
809
*
853
- * @return $this
854
- *
855
- * @deprecated No longer used.
810
+ * @deprecated 4.5.0 No longer used.
856
811
*/
857
- public function setPath ( string $ path )
812
+ protected function determinePath ( )
858
813
{
859
- $ this ->path = $ path ;
860
-
861
- return $ this ;
814
+ return $ this ->request ->getPath ();
862
815
}
863
816
864
817
/**
0 commit comments