@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | return new WebarchiveDTO( |
46 | 46 | self::ARCHIVER_NAME, |
47 | 47 | $url, |
48 | - (string)$archiveData['url'], |
|
48 | + (string) $archiveData['url'], |
|
49 | 49 | $iaDateOrNull |
50 | 50 | ); |
51 | 51 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | protected function requestInternetArchiveApi(string $url, ?DateTimeInterface $date = null): array |
54 | 54 | { |
55 | 55 | $response = $this->client->get( |
56 | - 'https://archive.org/wayback/available?timestamp=' . self::SEARCH_CLOSEST_TIMESTAMP . '&url=' . urlencode($url), |
|
56 | + 'https://archive.org/wayback/available?timestamp='.self::SEARCH_CLOSEST_TIMESTAMP.'&url='.urlencode($url), |
|
57 | 57 | [ |
58 | 58 | 'timeout' => 20, |
59 | 59 | 'allow_redirects' => true, |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | } |
104 | 104 | $iaDateTime = new DateTime(); |
105 | 105 | $iaDateTime->setDate( |
106 | - (int)substr($iaTimestamp, 0, 4), |
|
107 | - (int)substr($iaTimestamp, 4, 2), |
|
108 | - (int)substr($iaTimestamp, 6, 2) |
|
106 | + (int) substr($iaTimestamp, 0, 4), |
|
107 | + (int) substr($iaTimestamp, 4, 2), |
|
108 | + (int) substr($iaTimestamp, 6, 2) |
|
109 | 109 | ); |
110 | 110 | $iaDateTime->setTime( |
111 | - (int)substr($iaTimestamp, 8, 2), |
|
112 | - (int)substr($iaTimestamp, 10, 2), |
|
113 | - (int)substr($iaTimestamp, 12, 2) |
|
111 | + (int) substr($iaTimestamp, 8, 2), |
|
112 | + (int) substr($iaTimestamp, 10, 2), |
|
113 | + (int) substr($iaTimestamp, 12, 2) |
|
114 | 114 | ); |
115 | 115 | |
116 | 116 | return $iaDateTime; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | public function hasWarning(): bool |
26 | 26 | { |
27 | - return (bool)$this->warning; |
|
27 | + return (bool) $this->warning; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $refs = array_slice($refs, 0, self::MAX_REFS_PROCESSED_IN_ARTICLE, true); |
56 | 56 | |
57 | 57 | foreach ($refs as $ref) { |
58 | - $refContent = WikiTextUtil::stripFinalPoint(trim((string)$ref[1])); |
|
58 | + $refContent = WikiTextUtil::stripFinalPoint(trim((string) $ref[1])); |
|
59 | 59 | |
60 | 60 | $newRefContent = $this->processRefContent($refContent); |
61 | 61 | |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | protected function replaceRefInText(array $ref, string $replace, string $text) |
71 | 71 | { |
72 | 72 | // Pas de changement |
73 | - if (WikiTextUtil::stripFinalPoint(trim($replace)) === WikiTextUtil::stripFinalPoint(trim((string)$ref[1]))) { |
|
73 | + if (WikiTextUtil::stripFinalPoint(trim($replace)) === WikiTextUtil::stripFinalPoint(trim((string) $ref[1]))) { |
|
74 | 74 | return $text; |
75 | 75 | } |
76 | 76 | $replace = $this->addFinalPeriod($ref[0], $replace); |
77 | - $result = str_replace($ref[1], $replace, (string)$ref[0]); |
|
77 | + $result = str_replace($ref[1], $replace, (string) $ref[0]); |
|
78 | 78 | $this->printDiff($ref[0], $result); |
79 | 79 | |
80 | 80 | return str_replace($ref[0], $result, $text); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | protected function addFinalPeriod($ref, string $replace): string |
87 | 87 | { |
88 | - if (preg_match('#</ref>#', (string)$ref)) { |
|
88 | + if (preg_match('#</ref>#', (string) $ref)) { |
|
89 | 89 | $replace .= '.'; |
90 | 90 | } |
91 | 91 | return $replace; |
@@ -56,10 +56,10 @@ |
||
56 | 56 | $titles = $list->getPageTitles(); |
57 | 57 | unset($list); |
58 | 58 | //echo count($titles)." titles\n"; |
59 | -$edited = file(__DIR__ . '/../resources/article_externRef_edited.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
59 | +$edited = file(__DIR__.'/../resources/article_externRef_edited.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
60 | 60 | $filtered = array_diff($titles, $edited); |
61 | 61 | $list = new PageList($filtered); |
62 | -echo ">" . $list->count() . " dans liste\n"; |
|
62 | +echo ">".$list->count()." dans liste\n"; |
|
63 | 63 | |
64 | 64 | |
65 | 65 | $httpClient = ServiceFactory::getHttpClient(); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | // todo command --tor --wikiwix --internetarchive |
39 | 39 | $torEnabled = false; |
40 | -echo "TOR enabled : ".($torEnabled ? "oui" : "non"). "\n"; |
|
40 | +echo "TOR enabled : ".($torEnabled ? "oui" : "non")."\n"; |
|
41 | 41 | |
42 | 42 | $client = ServiceFactory::getHttpClient(); |
43 | 43 | $wikiwix = new WikiwixAdapter($client, $logger); |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | // Attention : pas de post-processing (sanitize title, etc.) |
57 | 57 | $result = $trans->process($url, $summary); |
58 | 58 | } catch (Exception $e) { |
59 | - $result = "EXCEPTION ". $e->getMessage().$e->getFile().$e->getLine(); |
|
59 | + $result = "EXCEPTION ".$e->getMessage().$e->getFile().$e->getLine(); |
|
60 | 60 | } |
61 | 61 | |
62 | -echo '>>> '. $result."\n"; |
|
62 | +echo '>>> '.$result."\n"; |
|
63 | 63 | |
64 | 64 | |
65 | 65 |
@@ -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 : not a valid URL : ' . $this->url, |
|
84 | + $this->log->warning('Skip : not a valid URL : '.$this->url, |
|
85 | 85 | ['stats' => 'externref.skip.URLAuthorized.exception2'] |
86 | 86 | ); |
87 | 87 | return null; |
@@ -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->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; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | protected function isSiteBlackListed(): bool |
158 | 158 | { |
159 | 159 | if ($this->skipSiteBlacklisted && in_array($this->registrableDomain, $this->skip_domain)) { |
160 | - $this->log->notice("Skip web site " . $this->registrableDomain); |
|
160 | + $this->log->notice("Skip web site ".$this->registrableDomain); |
|
161 | 161 | return true; |
162 | 162 | } |
163 | 163 | return false; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $this->config[$domain] = is_array($this->config[$domain]) ? $this->config[$domain] : []; |
176 | 176 | |
177 | 177 | if ($this->config[$domain] === 'deactivated' || isset($this->config[$domain]['deactivated'])) { |
178 | - $this->log->info("Domain " . $domain . " disabled\n"); |
|
178 | + $this->log->info("Domain ".$domain." disabled\n"); |
|
179 | 179 | |
180 | 180 | return false; |
181 | 181 | } |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | protected function logDebugConfigWebDomain(string $domain): void |
187 | 187 | { |
188 | 188 | if (!isset($this->config[$domain])) { |
189 | - $this->log->debug("Domain " . $domain . " non configuré"); |
|
189 | + $this->log->debug("Domain ".$domain." non configuré"); |
|
190 | 190 | } else { |
191 | - $this->log->debug("Domain " . $domain . " configuré"); |
|
191 | + $this->log->debug("Domain ".$domain." configuré"); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | if ($pageData === [] |
215 | 215 | || (empty($pageData['JSON-LD']) && empty($pageData['meta'])) |
216 | 216 | ) { |
217 | - $this->log->notice('No metadata : ' . $url); |
|
217 | + $this->log->notice('No metadata : '.$url); |
|
218 | 218 | |
219 | 219 | return true; |
220 | 220 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | protected function emptyMapData(array $mapData, string $url): bool |
230 | 230 | { |
231 | 231 | if ($mapData === [] || empty($mapData['url']) || empty($mapData['titre'])) { |
232 | - $this->log->info('Mapping incomplet : ' . $url); |
|
232 | + $this->log->info('Mapping incomplet : '.$url); |
|
233 | 233 | |
234 | 234 | return true; |
235 | 235 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | |
283 | 283 | $template = WikiTemplateFactory::create($templateName); |
284 | 284 | $template->userSeparator = " |"; |
285 | - $this->summary->memo['count ' . $templateName] = 1 + ($this->summary->memo['count ' . $templateName] ?? 0); |
|
285 | + $this->summary->memo['count '.$templateName] = 1 + ($this->summary->memo['count '.$templateName] ?? 0); |
|
286 | 286 | |
287 | 287 | return $template; |
288 | 288 | } |
@@ -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 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class ExternHttpErrorLogic |
20 | 20 | { |
21 | - final public const LOG_REQUEST_ERROR = __DIR__ . '/../../Application/resources/external_request_error.log'; |
|
21 | + final public const LOG_REQUEST_ERROR = __DIR__.'/../../Application/resources/external_request_error.log'; |
|
22 | 22 | protected const LOOSE = true; |
23 | 23 | |
24 | 24 | public function __construct( |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | return $url; |
41 | 41 | } |
42 | 42 | if (preg_match('#400 Bad Request#i', $errorMessage)) { |
43 | - $this->log->warning('400 Bad Request : ' . $url, ['stats' => 'externHttpErrorLogic.400']); |
|
43 | + $this->log->warning('400 Bad Request : '.$url, ['stats' => 'externHttpErrorLogic.400']); |
|
44 | 44 | |
45 | 45 | return $url; |
46 | 46 | } |
47 | 47 | if (preg_match('#(403 Forbidden|403 Access Forbidden)#i', $errorMessage)) { |
48 | - $this->log->warning('403 Forbidden : ' . $url, ['stats' => 'externHttpErrorLogic.403']); |
|
48 | + $this->log->warning('403 Forbidden : '.$url, ['stats' => 'externHttpErrorLogic.403']); |
|
49 | 49 | // TODO return blankLienWeb without consulté le=... |
50 | 50 | |
51 | 51 | return $url; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | return $url; |
60 | 60 | } |
61 | 61 | if (preg_match('#401 (Unauthorized|Authorization Required)#i', $errorMessage)) { |
62 | - $this->log->notice('401 Unauthorized : skip ' . $url, ['stats' => 'externHttpErrorLogic.401']); |
|
62 | + $this->log->notice('401 Unauthorized : skip '.$url, ['stats' => 'externHttpErrorLogic.401']); |
|
63 | 63 | |
64 | 64 | return $url; |
65 | 65 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | // "cURL error 28: Connection timed out after 20005 milliseconds (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) |
113 | 113 | //"cURL error 28: Connection timed out after 20005 milliseconds (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) |
114 | 114 | $this->log->notice( |
115 | - 'erreur non gérée sur extractWebData: "' . $errorMessage . "\" URL: " . $url, |
|
115 | + 'erreur non gérée sur extractWebData: "'.$errorMessage."\" URL: ".$url, |
|
116 | 116 | ['stats' => 'externHttpErrorLogic.defaultSkip'] |
117 | 117 | ); |
118 | 118 | //file_put_contents(self::LOG_REQUEST_ERROR, $this->domain."\n", FILE_APPEND); |
@@ -56,7 +56,7 @@ |
||
56 | 56 | if ($webarchiveDTO->getArchiver() === '[[Internet Archive]]') { |
57 | 57 | $this->log->notice(' |
@@ -32,7 +32,7 @@ |
||
32 | 32 | $this->summary->memo['sites'][] = $this->externalPage->getPrettyDomainName(); // ??? |
33 | 33 | } |
34 | 34 | if (isset($mapData['accès url'])) { |
35 | - $this->log->debug('accès |