19
19
use Psr \Log \LoggerInterface ;
20
20
use Psr \SimpleCache \CacheException as PsrCacheException ;
21
21
use Throwable ;
22
- use function array_merge ;
22
+ use function array_replace ;
23
23
use function extension_loaded ;
24
24
use function file_exists ;
25
25
use function filter_var_array ;
@@ -80,7 +80,7 @@ public static function createFromCacheDir(LoggerInterface $logger, string $cache
80
80
81
81
public function refresh (array $ context = []): int
82
82
{
83
- $ context = filter_var_array (array_merge (self ::DEFAULT_CONTEXT , $ context ), [
83
+ $ context = filter_var_array (array_replace (self ::DEFAULT_CONTEXT , $ context ), [
84
84
self ::REFRESH_PSL_KEY => FILTER_VALIDATE_BOOLEAN ,
85
85
self ::REFRESH_PSL_URL_KEY => ['filter ' => FILTER_SANITIZE_STRING , 'flags ' => FILTER_FLAG_STRIP_LOW , 'default ' => Manager::PSL_URL ],
86
86
self ::REFRESH_RZD_KEY => FILTER_VALIDATE_BOOLEAN ,
@@ -96,16 +96,10 @@ public function refresh(array $context = []): int
96
96
try {
97
97
$ retVal = $ this ->execute ($ context );
98
98
} catch (PsrCacheException $ exception ) {
99
- $ this ->logger ->error ('😓 😓 😓 Your local cache could not be updated. 😓 😓 😓 ' );
100
- $ this ->logger ->error ('An error occurred during cache regeneration. ' );
101
- $ this ->logger ->error ('----- Error Message ---- ' );
102
- $ this ->logger ->error ($ exception ->getMessage ());
99
+ $ this ->logger ->error ('Local cache update failed with {exception} ' , ['exception ' => $ exception ->getMessage ()]);
103
100
$ retVal = 1 ;
104
101
} catch (Throwable $ exception ) {
105
- $ this ->logger ->error ('😓 😓 😓 Your local cache could not be updated. 😓 😓 😓 ' );
106
- $ this ->logger ->error ('An error occurred during the update. ' );
107
- $ this ->logger ->error ('----- Error Message ---- ' );
108
- $ this ->logger ->error ($ exception ->getMessage ());
102
+ $ this ->logger ->error ('Local cache update failed with {exception} ' , ['exception ' => $ exception ->getMessage ()]);
109
103
$ retVal = 1 ;
110
104
}
111
105
@@ -121,18 +115,20 @@ public function refresh(array $context = []): int
121
115
*/
122
116
private function execute (array $ arguments = []): int
123
117
{
124
- $ this ->logger ->info ('Updating your Pdp local cache. ' );
125
-
126
118
if ($ arguments [self ::REFRESH_PSL_KEY ]) {
127
- $ this ->logger ->info ('Updating your Public Suffix List copy. ' );
128
119
if (!$ this ->manager ->refreshRules ($ arguments [self ::REFRESH_PSL_URL_KEY ], $ arguments [self ::TTL_KEY ])) {
129
- $ this ->logger ->error ('😓 😓 😓 Your Public Suffix List copy could not be updated. 😓 😓 😓 ' );
130
- $ this ->logger ->error ('Please review your settings. ' );
120
+ $ this ->logger ->error ('Unable to update the Public Suffix List Cache using {psl_url} with a TTL of {ttl} ' , [
121
+ 'psl_url ' => $ arguments [self ::REFRESH_PSL_URL_KEY ],
122
+ 'ttl ' => $ arguments [self ::TTL_KEY ],
123
+ ]);
131
124
132
125
return 1 ;
133
126
}
134
127
135
- $ this ->logger ->info ('💪 💪 💪 Your Public Suffix List copy is updated. 💪 💪 💪 ' );
128
+ $ this ->logger ->info ('Public Suffix List Cache updated for {ttl} using {psl_url} ' , [
129
+ 'psl_url ' => $ arguments [self ::REFRESH_PSL_URL_KEY ],
130
+ 'ttl ' => $ arguments [self ::TTL_KEY ],
131
+ ]);
136
132
}
137
133
138
134
if (!$ arguments [self ::REFRESH_RZD_KEY ]) {
@@ -141,13 +137,18 @@ private function execute(array $arguments = []): int
141
137
142
138
$ this ->logger ->info ('Updating your IANA Root Zone Database copy. ' );
143
139
if ($ this ->manager ->refreshTLDs ($ arguments [self ::REFRESH_RZD_URL_KEY ], $ arguments [self ::TTL_KEY ])) {
144
- $ this ->logger ->info ('💪 💪 💪 Your IANA Root Zone Database copy is updated. 💪 💪 💪 ' );
140
+ $ this ->logger ->info ('IANA Root Zone Database Cache updated for {ttl} using {rzd_url} ' , [
141
+ 'rzd_url ' => $ arguments [self ::REFRESH_RZD_URL_KEY ],
142
+ 'ttl ' => $ arguments [self ::TTL_KEY ],
143
+ ]);
145
144
146
145
return 0 ;
147
146
}
148
147
149
- $ this ->logger ->error ('😓 😓 😓 Your IANA Root Zone Database copy could not be updated. 😓 😓 😓 ' );
150
- $ this ->logger ->error ('Please review your settings. ' );
148
+ $ this ->logger ->error ('Unable to update the IANA Root Zone Database Cache using {rzd_url} with a TTL of {ttl} ' , [
149
+ 'rzd_url ' => $ arguments [self ::REFRESH_RZD_URL_KEY ],
150
+ 'ttl ' => $ arguments [self ::TTL_KEY ],
151
+ ]);
151
152
152
153
return 1 ;
153
154
}
@@ -187,9 +188,15 @@ public static function updateLocalCache(Event $event = null)
187
188
$ arguments = array_replace ($ arguments , $ event ->getArguments ());
188
189
}
189
190
190
- $ installer = self ::createFromCacheDir (new Logger (), $ arguments [Installer::CACHE_DIR_KEY ]);
191
+ $ logger = new Logger ();
192
+ $ installer = self ::createFromCacheDir ($ logger , $ arguments [Installer::CACHE_DIR_KEY ]);
193
+ $ logger ->info ('Updating your Pdp local cache. ' );
191
194
$ retVal = $ installer ->refresh ($ arguments );
192
-
195
+ if (0 === $ retVal ) {
196
+ $ logger ->info ('Pdp local cache successfully updated. ' );
197
+ } else {
198
+ $ logger ->error ("The command failed to update Pdp local cache successfully. " );
199
+ }
193
200
die ($ retVal );
194
201
}
195
202
0 commit comments