@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | { |
21 | 21 | // use LoggerTrait; |
22 | 22 | |
23 | - protected const CRITICAL_LOG_PATH = __DIR__ . '/../../../log/critical.log'; |
|
23 | + protected const CRITICAL_LOG_PATH = __DIR__.'/../../../log/critical.log'; |
|
24 | 24 | public bool $verbose = false; |
25 | 25 | public bool $debug = false; |
26 | 26 | public bool $colorMode = false; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | public function __call(string $method, array $args): void |
38 | 38 | { |
39 | - $this->notice('Call to undefined method ConsoleLogger:' . $method . '()'); |
|
39 | + $this->notice('Call to undefined method ConsoleLogger:'.$method.'()'); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | case 'emergency': |
63 | 63 | case 'alert': |
64 | 64 | case 'critical': |
65 | - $this->echoColor("[$level] " . $date . ' : ' . $message . "\n", Color::BG_RED . Color::WHITE); |
|
65 | + $this->echoColor("[$level] ".$date.' : '.$message."\n", Color::BG_RED.Color::WHITE); |
|
66 | 66 | if ($context !== []) { |
67 | 67 | dump($context); |
68 | 68 | } |
@@ -70,20 +70,20 @@ discard block |
||
70 | 70 | break; |
71 | 71 | case 'error': |
72 | 72 | case 'warning': |
73 | - $this->echoColor("[$level] " . $date . ' : ' . $message . "\n", Color::BG_YELLOW . Color::BLACK); |
|
73 | + $this->echoColor("[$level] ".$date.' : '.$message."\n", Color::BG_YELLOW.Color::BLACK); |
|
74 | 74 | if ($context !== []) { |
75 | 75 | dump($context); |
76 | 76 | } |
77 | 77 | break; |
78 | 78 | case 'notice': |
79 | - $this->echoColor("[$level] " . $message . "\n"); |
|
79 | + $this->echoColor("[$level] ".$message."\n"); |
|
80 | 80 | if ($context !== []) { |
81 | 81 | dump($context); |
82 | 82 | } |
83 | 83 | break; |
84 | 84 | case 'info': |
85 | 85 | if ($this->verbose || $this->debug) { |
86 | - $this->echoColor("[$level] " . $message . "\n", Color::GRAY); |
|
86 | + $this->echoColor("[$level] ".$message."\n", Color::GRAY); |
|
87 | 87 | if ($context !== []) { |
88 | 88 | dump($context); |
89 | 89 | } |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | break; |
92 | 92 | case 'debug': |
93 | 93 | if ($this->debug) { |
94 | - $this->echoColor("[$level] " . $message . "\n", Color::GRAY); |
|
94 | + $this->echoColor("[$level] ".$message."\n", Color::GRAY); |
|
95 | 95 | if ($context !== []) { |
96 | 96 | dump($context); |
97 | 97 | } |
98 | 98 | } |
99 | 99 | break; |
100 | 100 | case 'echo': |
101 | - $this->echoColor($message . "\n"); |
|
101 | + $this->echoColor($message."\n"); |
|
102 | 102 | break; |
103 | 103 | } |
104 | 104 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | private function echoColor(string $text, ?string $color = null): void |
122 | 122 | { |
123 | 123 | if ($this->colorMode && !empty($color)) { |
124 | - echo $color . $text . Color::NORMAL; |
|
124 | + echo $color.$text.Color::NORMAL; |
|
125 | 125 | |
126 | 126 | return; |
127 | 127 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | { |
133 | 133 | file_put_contents( |
134 | 134 | self::CRITICAL_LOG_PATH, |
135 | - date('d-m-Y H:i:s') . " : $level : " . $message . PHP_EOL, |
|
135 | + date('d-m-Y H:i:s')." : $level : ".$message.PHP_EOL, |
|
136 | 136 | FILE_APPEND |
137 | 137 | ); |
138 | 138 | } |
@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | public const SLEEP_AFTER_EDITION = 60; |
33 | 33 | public const MINUTES_DELAY_AFTER_LAST_HUMAN_EDIT = 15; |
34 | 34 | public const CHECK_EDIT_CONFLICT = true; |
35 | - public const ARTICLE_ANALYZED_FILENAME = __DIR__ . '/resources/article_edited.txt'; |
|
35 | + public const ARTICLE_ANALYZED_FILENAME = __DIR__.'/resources/article_edited.txt'; |
|
36 | 36 | public const SKIP_LASTEDIT_BY_BOT = true; |
37 | 37 | public const SKIP_NOT_IN_MAIN_WIKISPACE = true; |
38 | 38 | public const SKIP_ADQ = true; |
39 | 39 | public const THROTTLE_DELAY_AFTER_EACH_TITLE = 1; //secs |
40 | - protected const GIT_COMMIT_HASH_PATH = __DIR__ . '/resources/commithash.txt'; |
|
40 | + protected const GIT_COMMIT_HASH_PATH = __DIR__.'/resources/commithash.txt'; |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @var PageListInterface |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $this->initializePastAnalyzedTitles(); |
94 | 94 | |
95 | 95 | // @throw exception on "Invalid CSRF token" |
96 | - $this->run();//todo delete that and use (Worker)->run($duration) or process management |
|
96 | + $this->run(); //todo delete that and use (Worker)->run($duration) or process management |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | */ |
104 | 104 | final public function run(): void |
105 | 105 | { |
106 | - $this->log->notice('*** New BotTaskWorker: ' . $this->defaultTaskname, ['stats' => 'bottaskworker.instance']); |
|
106 | + $this->log->notice('*** New BotTaskWorker: '.$this->defaultTaskname, ['stats' => 'bottaskworker.instance']); |
|
107 | 107 | $this->log->notice(sprintf( |
108 | 108 | '*** Bot: %s - commit: %s', |
109 | 109 | $this->bot::getBotName(), |
110 | 110 | $this->bot->getCurrentGitCommitHash() ?? '??' |
111 | 111 | )); |
112 | - $this->log->notice('*** Stats: ' . $this->log->stats::class); |
|
112 | + $this->log->notice('*** Stats: '.$this->log->stats::class); |
|
113 | 113 | |
114 | 114 | foreach ($this->getTitles() as $title) { |
115 | 115 | try { |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | } |
219 | 219 | |
220 | 220 | $this->log->notice($result ? '>> OK' : '>> NOCHANGE'); |
221 | - $this->log->debug("Sleep " . static::SLEEP_AFTER_EDITION); |
|
221 | + $this->log->debug("Sleep ".static::SLEEP_AFTER_EDITION); |
|
222 | 222 | sleep(static::SLEEP_AFTER_EDITION); |
223 | 223 | } |
224 | 224 |
@@ -59,13 +59,13 @@ |
||
59 | 59 | $list = new PageList([trim($options['page'])]); |
60 | 60 | |
61 | 61 | // delete Title from edited.txt |
62 | - $file = __DIR__ . '/../resources/article_externRef_edited.txt'; |
|
62 | + $file = __DIR__.'/../resources/article_externRef_edited.txt'; |
|
63 | 63 | $text = file_get_contents($file); |
64 | - $newText = str_replace(trim($argv[1]) . "\n", '', $text); |
|
64 | + $newText = str_replace(trim($argv[1])."\n", '', $text); |
|
65 | 65 | if (!empty($text) && $text !== $newText) { |
66 | 66 | @file_put_contents($file, $newText); |
67 | 67 | } |
68 | - $botConfig->setTaskName(' |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | $this->url = $url; |
50 | 50 | $this->registrableDomain = null; |
51 | 51 | if (!HttpUtil::isHttpURL($url)) { |
52 | - $this->log->debug('Skip : not Http URL : ' . $url, ['stats' => 'externref.skip.notRawURL']); |
|
52 | + $this->log->debug('Skip : not Http URL : '.$url, ['stats' => 'externref.skip.notRawURL']); |
|
53 | 53 | return false; |
54 | 54 | } |
55 | 55 | |
56 | 56 | if ($this->hasForbiddenFilenameExtension()) { |
57 | - $this->log->debug('Skip : ForbiddenFilenameExtension : ' . $url, ['stats' => 'externref.skip.forbiddenFilenameExtension']); |
|
57 | + $this->log->debug('Skip : ForbiddenFilenameExtension : '.$url, ['stats' => 'externref.skip.forbiddenFilenameExtension']); |
|
58 | 58 | return false; |
59 | 59 | } |
60 | 60 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | protected function hasForbiddenFilenameExtension(): bool |
72 | 72 | { |
73 | - return (bool)preg_match( |
|
73 | + return (bool) preg_match( |
|
74 | 74 | '#\.(pdf|jpg|jpeg|gif|png|webp|xls|xlsx|xlr|xml|xlt|txt|csv|js|docx|exe|gz|zip|ini|movie|mp3|mp4|ogg|raw|rss|tar|tgz|wma)$#i', |
75 | 75 | $this->url |
76 | 76 | ); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | try { |
82 | 82 | $this->registrableDomain = $this->internetDomainParser->getRegistrableDomainFromURL($this->url); |
83 | 83 | } catch (Exception) { |
84 | - $this->log->warning('Skip : registrableDomain not a valid URL : ' . $this->url, |
|
84 | + $this->log->warning('Skip : registrableDomain not a valid URL : '.$this->url, |
|
85 | 85 | ['stats' => 'externref.skip.URLAuthorized.exception2'] |
86 | 86 | ); |
87 | 87 | return null; |
@@ -63,7 +63,7 @@ |
||
63 | 63 | if ($webarchiveDTO->getArchiver() === '[[Internet Archive]]') { |
64 | 64 | $this->log->notice(' |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | use SummaryExternTrait, PublisherLogicTrait; |
36 | 36 | |
37 | 37 | final public const HTTP_REQUEST_LOOP_DELAY = 10; |
38 | - final public const SKIP_DOMAIN_FILENAME = __DIR__ . '/../resources/config_skip_domain.txt'; |
|
38 | + final public const SKIP_DOMAIN_FILENAME = __DIR__.'/../resources/config_skip_domain.txt'; |
|
39 | 39 | final public const REPLACE_404 = true; |
40 | 40 | final public const REPLACE_410 = true; |
41 | - final public const CONFIG_PRESSE = __DIR__ . '/../resources/config_presse.yaml'; |
|
42 | - final public const CONFIG_NEWSPAPER_JSON = __DIR__ . '/../resources/data_newspapers.json'; |
|
43 | - final public const CONFIG_SCIENTIFIC_JSON = __DIR__ . '/../resources/data_scientific_domain.json'; |
|
44 | - final public const CONFIG_SCIENTIFIC_WIKI_JSON = __DIR__ . '/../resources/data_scientific_wiki.json'; |
|
41 | + final public const CONFIG_PRESSE = __DIR__.'/../resources/config_presse.yaml'; |
|
42 | + final public const CONFIG_NEWSPAPER_JSON = __DIR__.'/../resources/data_newspapers.json'; |
|
43 | + final public const CONFIG_SCIENTIFIC_JSON = __DIR__.'/../resources/data_scientific_domain.json'; |
|
44 | + final public const CONFIG_SCIENTIFIC_WIKI_JSON = __DIR__.'/../resources/data_scientific_wiki.json'; |
|
45 | 45 | |
46 | 46 | public bool $skipSiteBlacklisted = true; |
47 | 47 | public bool $skipRobotNoIndex = true; |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | } |
97 | 97 | $this->registrableDomain = $this->urlChecker->getRegistrableDomain($url); // hack |
98 | 98 | if ($this->isSiteBlackListed()) { |
99 | - $this->log->debug('Site blacklisted : ' . $this->registrableDomain, ['stats' => 'externref.skip.blacklisted']); |
|
99 | + $this->log->debug('Site blacklisted : '.$this->registrableDomain, ['stats' => 'externref.skip.blacklisted']); |
|
100 | 100 | return $url; |
101 | 101 | } |
102 | 102 | |
103 | 103 | if ($this->registrableDomain && !$this->validateConfigWebDomain($this->registrableDomain)) { |
104 | 104 | $this->log->debug( |
105 | - 'Domain blocked by config : ' . $this->registrableDomain, |
|
105 | + 'Domain blocked by config : '.$this->registrableDomain, |
|
106 | 106 | ['stats' => 'externref.skip.domainDisabledByConfig'] |
107 | 107 | ); |
108 | 108 | return $url; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | protected function isSiteBlackListed(): bool |
160 | 160 | { |
161 | 161 | if ($this->registrableDomain && $this->skipSiteBlacklisted && in_array($this->registrableDomain, $this->skip_domain)) { |
162 | - $this->log->notice("Skip web site " . $this->registrableDomain); |
|
162 | + $this->log->notice("Skip web site ".$this->registrableDomain); |
|
163 | 163 | return true; |
164 | 164 | } |
165 | 165 | return false; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $this->config[$domain] = is_array($this->config[$domain]) ? $this->config[$domain] : []; |
178 | 178 | |
179 | 179 | if ($this->config[$domain] === 'deactivated' || isset($this->config[$domain]['deactivated'])) { |
180 | - $this->log->info("Domain " . $domain . " disabled\n"); |
|
180 | + $this->log->info("Domain ".$domain." disabled\n"); |
|
181 | 181 | |
182 | 182 | return false; |
183 | 183 | } |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | protected function logDebugConfigWebDomain(string $domain): void |
189 | 189 | { |
190 | 190 | if (!isset($this->config[$domain])) { |
191 | - $this->log->debug("Domain " . $domain . " non configuré"); |
|
191 | + $this->log->debug("Domain ".$domain." non configuré"); |
|
192 | 192 | } else { |
193 | - $this->log->debug("Domain " . $domain . " configuré"); |
|
193 | + $this->log->debug("Domain ".$domain." configuré"); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | if ($pageData === [] |
217 | 217 | || (empty($pageData['JSON-LD']) && empty($pageData['meta'])) |
218 | 218 | ) { |
219 | - $this->log->notice('No metadata : ' . $url); |
|
219 | + $this->log->notice('No metadata : '.$url); |
|
220 | 220 | |
221 | 221 | return true; |
222 | 222 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | protected function emptyMapData(array $mapData, string $url): bool |
232 | 232 | { |
233 | 233 | if ($mapData === [] || empty($mapData['url']) || empty($mapData['titre'])) { |
234 | - $this->log->info('Mapping incomplet : ' . $url); |
|
234 | + $this->log->info('Mapping incomplet : '.$url); |
|
235 | 235 | |
236 | 236 | return true; |
237 | 237 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | protected function correctSiteViaWebarchiver(array $mapData): array |
323 | 323 | { |
324 | 324 | if (!empty($this->options['originalRegistrableDomain']) && $mapData['site']) { |
325 | - $mapData['site'] = $this->options['originalRegistrableDomain'] . ' via ' . $mapData['site']; |
|
325 | + $mapData['site'] = $this->options['originalRegistrableDomain'].' via '.$mapData['site']; |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | return $mapData; |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | $templateOptimized = $optimizer->getOptiTemplate(); |
347 | 347 | |
348 | 348 | $serialized = $templateOptimized->serialize(true); |
349 | - $this->log->info('Serialized 444: ' . $serialized . "\n"); |
|
349 | + $this->log->info('Serialized 444: '.$serialized."\n"); |
|
350 | 350 | return $serialized; |
351 | 351 | } |
352 | 352 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | { |
355 | 355 | $template = WikiTemplateFactory::create($templateName); |
356 | 356 | $template->userSeparator = " |"; |
357 | - $this->summary->memo['count ' . $templateName] = 1 + ($this->summary->memo['count ' . $templateName] ?? 0); |
|
357 | + $this->summary->memo['count '.$templateName] = 1 + ($this->summary->memo['count '.$templateName] ?? 0); |
|
358 | 358 | |
359 | 359 | return $template; |
360 | 360 | } |