Skip to content

Commit ecc64a7

Browse files
author
Hai Zheng
committed
v7.9-a23: Allowed multi GM crawler variant.
1 parent 11bf662 commit ecc64a7

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

src/crawler.cls.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1311,9 +1311,16 @@ public function list_crawlers() {
13111311

13121312
$this_cookie_key = 'cookie:' . $v['name'];
13131313

1314-
$crawler_factors[ $this_cookie_key ] = [];
1314+
// Preserves Guest Mode preset when same-name cookie row arrives.
1315+
if ( ! isset( $crawler_factors[ $this_cookie_key ] ) ) {
1316+
$crawler_factors[ $this_cookie_key ] = [];
1317+
}
13151318

13161319
foreach ( $v['vals'] as $v2 ) {
1320+
// Preserve existing labels (e.g. Guest Mode 👒 marker on `_null`) — skip if value already mapped.
1321+
if ( isset( $crawler_factors[ $this_cookie_key ][ $v2 ] ) ) {
1322+
continue;
1323+
}
13171324
$crawler_factors[ $this_cookie_key ][ $v2 ] =
13181325
( '_null' === $v2 ? '' : '<font data-balloon-pos="up" aria-label="Cookie">🍪</font>' . esc_html( $v['name'] ) . '=' . esc_html( $v2 ) );
13191326
}

thirdparty/wcml.cls.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,23 @@ public static function inject_vary_row( $cookies ) {
135135

136136
$vary_name = \LiteSpeed\Vary::cls()->get_vary_name();
137137

138-
// Strip only when injecting — preserves manually configured rows on unpicked sites.
139-
$cookies = array_values(array_filter(
140-
$cookies,
141-
function ( $c ) use ( $vary_name ) {
142-
return is_array($c) && isset($c['name']) && $vary_name !== $c['name'];
138+
// Merge with admin's same-name rows
139+
$existing_vals = [];
140+
$other_rows = [];
141+
foreach ($cookies as $c) {
142+
if (is_array($c) && isset($c['name']) && $vary_name === $c['name']) {
143+
if (!empty($c['vals']) && is_array($c['vals'])) {
144+
$existing_vals = array_merge($existing_vals, $c['vals']);
145+
}
146+
} else {
147+
$other_rows[] = $c;
143148
}
144-
));
145-
$cookies[] = [ 'name' => $vary_name, 'vals' => $vals ];
146-
return $cookies;
149+
}
150+
$other_rows[] = [
151+
'name' => $vary_name,
152+
'vals' => array_values(array_unique(array_merge($existing_vals, $vals))),
153+
];
154+
return $other_rows;
147155
}
148156

149157
/**

0 commit comments

Comments
 (0)