File tree Expand file tree Collapse file tree 2 files changed +43
-4
lines changed
app/code/Magento/PageCache/Model/App/Request/Http
lib/internal/Magento/Framework/App/PageCache Expand file tree Collapse file tree 2 files changed +43
-4
lines changed Original file line number Diff line number Diff line change 8
8
namespace Magento \PageCache \Model \App \Request \Http ;
9
9
10
10
use Magento \Framework \App \Http \Context ;
11
+ use Magento \Framework \App \PageCache \IdentifierInterface ;
11
12
use Magento \Framework \App \Request \Http ;
12
13
use Magento \Framework \Serialize \Serializer \Json ;
13
- use Magento \Framework \App \PageCache \IdentifierInterface ;
14
14
15
15
/**
16
16
* Page unique identifier
@@ -36,12 +36,32 @@ public function __construct(
36
36
*/
37
37
public function getValue ()
38
38
{
39
+ $ url = $ this ->request ->getUriString ();
40
+ list ($ baseUrl , $ query ) = $ this ->reconstructUrl ($ url );
39
41
$ data = [
40
42
$ this ->request ->isSecure (),
41
- $ this ->request ->getUriString (),
43
+ $ baseUrl ,
44
+ $ query ,
42
45
$ this ->context ->getVaryString ()
43
46
];
44
47
45
48
return sha1 ($ this ->serializer ->serialize ($ data ));
46
49
}
50
+
51
+ /**
52
+ * Reconstruct url and sort query
53
+ *
54
+ * @param string $url
55
+ * @return array
56
+ */
57
+ private function reconstructUrl ($ url )
58
+ {
59
+ $ baseUrl = strtok ($ url , '? ' );
60
+ $ query = $ this ->request ->getQuery ()->toArray ();
61
+ if (!empty ($ query )) {
62
+ ksort ($ query );
63
+ $ query = http_build_query ($ query );
64
+ }
65
+ return [$ baseUrl , $ query ];
66
+ }
47
67
}
Original file line number Diff line number Diff line change @@ -50,13 +50,32 @@ public function __construct(
50
50
*/
51
51
public function getValue ()
52
52
{
53
+ $ url = $ this ->request ->getUriString ();
54
+ list ($ baseUrl , $ query ) = $ this ->reconstructUrl ($ url );
53
55
$ data = [
54
56
$ this ->request ->isSecure (),
55
- $ this ->request ->getUriString (),
57
+ $ baseUrl ,
58
+ $ query ,
56
59
$ this ->request ->get (\Magento \Framework \App \Response \Http::COOKIE_VARY_STRING )
57
60
?: $ this ->context ->getVaryString ()
58
61
];
59
-
60
62
return sha1 ($ this ->serializer ->serialize ($ data ));
61
63
}
64
+
65
+ /**
66
+ * Reconstruct url and sort query
67
+ *
68
+ * @param string $url
69
+ * @return array
70
+ */
71
+ private function reconstructUrl ($ url )
72
+ {
73
+ $ baseUrl = strtok ($ url , '? ' );
74
+ $ query = $ this ->request ->getQuery ()->toArray ();
75
+ if (!empty ($ query )) {
76
+ ksort ($ query );
77
+ $ query = http_build_query ($ query );
78
+ }
79
+ return [$ baseUrl , $ query ];
80
+ }
62
81
}
You can’t perform that action at this time.
0 commit comments