@@ -616,23 +616,21 @@ public static function url($url = null, $full = false)
616
616
'action ' => 'index ' ,
617
617
'_ext ' => null ,
618
618
];
619
- $ here = $ base = $ output = $ frag = null ;
619
+ $ here = $ output = $ frag = null ;
620
620
621
+ $ context = static ::$ _requestContext ;
621
622
// In 4.x this should be replaced with state injected via setRequestContext
622
623
$ request = static ::getRequest (true );
623
624
if ($ request ) {
624
625
$ params = $ request ->getAttribute ('params ' );
625
626
$ here = $ request ->getRequestTarget ();
626
- $ base = $ request ->getAttribute ('base ' );
627
- } else {
628
- $ base = Configure::read ('App.base ' );
629
- if (isset (static ::$ _requestContext ['_base ' ])) {
630
- $ base = static ::$ _requestContext ['_base ' ];
631
- }
627
+ $ context ['_base ' ] = $ request ->getAttribute ('base ' );
628
+ } elseif (!isset ($ context ['_base ' ])) {
629
+ $ context ['_base ' ] = Configure::read ('App.base ' );
632
630
}
633
631
634
632
if (empty ($ url )) {
635
- $ output = $ base . (isset ($ here ) ? $ here : '/ ' );
633
+ $ output = $ context [ ' _base ' ] . (isset ($ here ) ? $ here : '/ ' );
636
634
if ($ full ) {
637
635
$ output = static ::fullBaseUrl () . $ output ;
638
636
}
@@ -680,8 +678,9 @@ public static function url($url = null, $full = false)
680
678
if ($ full && isset ($ url ['_scheme ' ]) && !isset ($ url ['_host ' ])) {
681
679
$ url ['_host ' ] = parse_url (static ::fullBaseUrl (), PHP_URL_HOST );
682
680
}
681
+ $ context ['params ' ] = $ params ;
683
682
684
- $ output = static ::$ _collection ->match ($ url , static :: $ _requestContext + [ ' params ' => $ params ] );
683
+ $ output = static ::$ _collection ->match ($ url , $ context );
685
684
} else {
686
685
$ plainString = (
687
686
strpos ($ url , 'javascript: ' ) === 0 ||
@@ -697,7 +696,7 @@ public static function url($url = null, $full = false)
697
696
if ($ plainString ) {
698
697
return $ url ;
699
698
}
700
- $ output = $ base . $ url ;
699
+ $ output = $ context [ ' _base ' ] . $ url ;
701
700
}
702
701
$ protocol = preg_match ('#^[a-z][a-z0-9+\-.]*\://#i ' , $ output );
703
702
if ($ protocol === 0 ) {
0 commit comments