Skip to content

Commit

Permalink
Try drop Sf 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDev committed Oct 16, 2022
1 parent 3447642 commit 9b5ac09
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 81 deletions.
46 changes: 23 additions & 23 deletions composer.json
Expand Up @@ -34,34 +34,34 @@
"phpstan/phpstan-strict-rules": "^1.0",
"piedweb/linksimprover": "^0.0.8",
"piedweb/render-html-attributes": "^2.0.1",
"piedweb/url-harvester": "^0.0.31",
"piedweb/curl": "^0.1",
"piedweb/extractor": "^0.1.10",
"sensio/framework-extra-bundle": "^6.1",
"sonata-project/admin-bundle": "^4.0",
"sonata-project/doctrine-orm-admin-bundle": "^4.0",
"spatie/image-optimizer": "^1.3",
"spatie/yaml-front-matter": "^2.0",
"symfony/asset": "^5.4 || ^6.0",
"symfony/cache": "^5.4 || ^6.0",
"symfony/console": "^5.4 || ^6.0",
"symfony/expression-language": "^5.4 || ^6.0",
"symfony/finder": "^5.4 || ^6.0",
"symfony/form": "^5.4 || ^6.0",
"symfony/framework-bundle": "^5.4 || ^6.0",
"symfony/lock": "^5.4 || ^6.0",
"symfony/mailer": "^5.4 || ^6.0",
"symfony/asset": "6.0.*",
"symfony/cache": "6.0.*",
"symfony/console": "6.0.*",
"symfony/expression-language": "6.0.*",
"symfony/finder": "6.0.*",
"symfony/form": "6.0.*",
"symfony/framework-bundle": "6.0.*",
"symfony/lock": "6.0.*",
"symfony/mailer": "6.0.*",
"symfony/monolog-bundle": "^3.7",
"symfony/process": "^5.4 || ^6.0",
"symfony/security-bundle": "^5.4 || ^6.0",
"symfony/security-csrf": "^5.4 || ^6.0",
"symfony/security-guard": "^5.4 || ^6.0",
"symfony/serializer": "^5.4 || ^6.0",
"symfony/translation": "^5.4 || ^6.0",
"symfony/twig-bundle": "^5.4 || ^6.0",
"symfony/validator": "^5.4 || ^6.0",
"symfony/web-link": "^5.4 || ^6.0",
"symfony/process": "6.0.*",
"symfony/security-bundle": "6.0.*",
"symfony/security-csrf": "6.0.*",
"symfony/security-guard": "*",
"symfony/serializer": "6.0.*",
"symfony/translation": "6.0.*",
"symfony/twig-bundle": "6.0.*",
"symfony/validator": "6.0.*",
"symfony/web-link": "6.0.*",
"symfony/webpack-encore-bundle": "^1.8",
"symfony/http-client": "^5.4 || 6.1.6",
"symfony/yaml": "^5.4 || ^6.0",
"symfony/yaml": "6.0.*",
"thecodingmachine/safe": "^2.2",
"twig/intl-extra": "^3.2",
"vich/uploader-bundle": "^1.16",
Expand All @@ -71,15 +71,15 @@
"require-dev": {
"composer/composer": "^2.0",
"friendsofphp/php-cs-fixer": "^3.2",
"friendsoftwig/twigcs": "^6.0",
"friendsoftwig/twigcs": "6.0.*",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-doctrine": "^1.0",
"phpstan/phpstan-symfony": "^1.0",
"phpunit/phpunit": "^9.5",
"psalm/plugin-symfony": "^3.1",
"rector/rector": "^0.14",
"squizlabs/php_codesniffer": "^3.5",
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/dotenv": "6.0.*",
"symfony/maker-bundle": "^1.35",
"symfony/panther": "^1 || ^2.0",
"symfony/phpunit-bridge": "^6.1",
Expand Down
1 change: 0 additions & 1 deletion packages/admin/src/PageCRUDController.php
Expand Up @@ -62,7 +62,6 @@ public function listAction(Request $request): Response
public function treeAction(): Response
{
$pages = Repository::getPageRepository($this->entityManager, $this->params->get('pw.entity_page')) // @phpstan-ignore-line
// $pages = $this->getDoctrine()->getRepository(PageInterface::class)
->getPagesWithoutParent();

return $this->renderWithExtraParams('@pwAdmin/page/page_treeView.html.twig', [
Expand Down
47 changes: 24 additions & 23 deletions packages/core/composer.json
Expand Up @@ -19,44 +19,45 @@
"michelf/php-markdown": "^2",
"pagerfanta/twig": "^3.0",
"piedweb/render-html-attributes": "^2.0.1",
"piedweb/url-harvester": "^0.0.31",
"piedweb/curl": "^0.1",
"piedweb/extractor": "^0.1.10",
"pushword/skeleton": "*",
"thecodingmachine/safe": "^2.1",
"sensio/framework-extra-bundle": "^5.6",
"spatie/image-optimizer": "^1.3",
"symfony/asset": "^5.3 || ^6.0",
"symfony/cache": "^5.3 || ^6.0",
"symfony/console": "^5.3 || ^6.0",
"symfony/expression-language": "^5.3 || ^6.0",
"symfony/finder": "^5.3 || ^6.0",
"symfony/form": "^5.3 || ^6.0",
"symfony/framework-bundle": "^5.3 || ^6.0",
"symfony/lock": "^5.3 || ^6.0",
"symfony/mailer": "^5.3 || ^6.0",
"symfony/process": "^5.3 || ^6.0",
"symfony/security-bundle": "^5.3 || ^6.0",
"symfony/security-csrf": "^5.3 || ^6.0",
"symfony/security-guard": "^5.3 || ^6.0",
"symfony/translation": "^5.3 || ^6.0",
"symfony/twig-bundle": "^5.3 || ^6.0",
"symfony/validator": "^5.3 || ^6.0",
"symfony/web-link": "^5.3 || ^6.0",
"symfony/asset": "6.0.*",
"symfony/cache": "6.0.*",
"symfony/console": "6.0.*",
"symfony/expression-language": "6.0.*",
"symfony/finder": "6.0.*",
"symfony/form": "6.0.*",
"symfony/framework-bundle": "6.0.*",
"symfony/lock": "6.0.*",
"symfony/mailer": "6.0.*",
"symfony/process": "6.0.*",
"symfony/security-bundle": "6.0.*",
"symfony/security-csrf": "6.0.*",
"symfony/security-guard": "6.0.*",
"symfony/translation": "6.0.*",
"symfony/twig-bundle": "6.0.*",
"symfony/validator": "6.0.*",
"symfony/web-link": "6.0.*",
"symfony/webpack-encore-bundle": "^1.8",
"symfony/yaml": "^5.3 || ^6.0",
"symfony/dotenv": "^5.3 || ^6.0",
"symfony/runtime": "^5.3 || ^6.0",
"symfony/yaml": "6.0.*",
"symfony/dotenv": "6.0.*",
"symfony/runtime": "6.0.*",
"twig/intl-extra": "^3.2",
"vich/uploader-bundle": "^1.16",
"villfa/invert-color": "^0.5",
"wyrihaximus/html-compress": "^4.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.17",
"friendsoftwig/twigcs": "^6.0",
"friendsoftwig/twigcs": "6.0.*",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.5",
"symfony/phpunit-bridge": "^5.0",
"symfony/dotenv": "^5.3 || ^6.0",
"symfony/dotenv": "6.0.*",
"symfony/maker-bundle": "^1.35",
"symfony/profiler-pack": "^1.0",
"symplify/monorepo-builder": "^9.0"
Expand Down
8 changes: 4 additions & 4 deletions packages/new/composer.json
Expand Up @@ -12,11 +12,11 @@
"symfony/flex": "^1.3.1"
},
"flex-require": {
"symfony/console": "^5.3 || ^6.0",
"symfony/dotenv": "^5.3 || ^6.0",
"symfony/framework-bundle": "^5.3 || ^6.0",
"symfony/console": "6.0.*",
"symfony/dotenv": "6.0.*",
"symfony/framework-bundle": "6.0.*",
"symfony/runtime": "*",
"symfony/yaml": "^5.3 || ^6.0",
"symfony/yaml": "6.0.*",
"pushword/core": "*"
},
"require-dev": {
Expand Down
58 changes: 33 additions & 25 deletions packages/page-scanner/src/Scanner/LinkedDocsScanner.php
Expand Up @@ -3,8 +3,10 @@
namespace Pushword\PageScanner\Scanner;

use Doctrine\ORM\EntityManagerInterface;
use PiedWeb\Curl\Request;
use PiedWeb\UrlHarvester\Harvest;
use PiedWeb\Curl\ExtendedClient;
use PiedWeb\Curl\Helper;
use PiedWeb\Extractor\CanonicalExtractor;
use PiedWeb\Extractor\Url;
use Pushword\Core\Repository\Repository;
use Pushword\Core\Twig\AppExtension;
use Pushword\Core\Utils\F;
Expand All @@ -22,8 +24,6 @@ final class LinkedDocsScanner extends AbstractScanner

private int $linksCheckedCounter = 0;

private ?Request $previousRequest = null;

private ?DomCrawler $domPage = null;

/**
Expand Down Expand Up @@ -203,33 +203,41 @@ private function targetExist(string $target): bool
*
* @return bool|mixed|string
*/
private function urlExist(string $uri)
private function urlExist(string $url)
{
if (isset($this->urlExistCache[$uri])) {
return $this->urlExistCache[$uri];
if (isset($this->urlExistCache[$url])) {
return $this->urlExistCache[$url];
}

$client = new ExtendedClient($url);
$client
->setDefaultSpeedOptions()
->fakeBrowserHeader()
->setNoFollowRedirection()
->setMaximumResponseSize()
->setDownloadOnlyIf([Helper::class, 'checkStatusCode'])
->setMobileUserAgent();
// if ($this->proxy) { $client->setProxy($this->proxy); }
$client->request();

if (200 !== $client->getCurlInfo(\CURLINFO_HTTP_CODE) && 0 !== $client->getCurlInfo(\CURLINFO_HTTP_CODE)) {
return $this->urlExistCache[$url] = $this->trans('page_scan.status_code').' ('.$client->getCurlInfo(\CURLINFO_HTTP_CODE).')';
}

$harvest = Harvest::fromUrl(
$uri,
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.107 Safari/537.36',
'en,en-US;q=0.5',
$this->previousRequest
);

if (\is_int($harvest)) {
$return = $this->trans('page_scan.unreachable', ['errorCode' => curl_strerror($harvest)]);
} elseif (200 !== $errorCode = $harvest->getResponse()->getStatusCode()) {
$return = $this->trans('page_scan.status_code').' ('.$errorCode.')';
} elseif (! $harvest->isCanonicalCorrect()) {
$return = $this->trans('page_scan.canonical').' ('.$harvest->getCanonical().')';
} else {
$this->previousRequest = $harvest->getResponse()->getRequest();
$return = true;
if ($client->getError() > 0) {
return $this->urlExistCache[$url] = $this->trans(
'page_scan.unreachable',
92832 === $client->getError() ? [' - errorMessage' => ''] : ['errorMessage' => $client->getErrorMessage()]
);
}

$this->urlExistCache[$uri] = $return;
$canonical = new CanonicalExtractor(new Url($url), new DomCrawler($client->getResponse()->getBody()));
if ($canonical->canonicalExists()
&& (! $canonical->isCanonicalPartiallyCorrect() || ! $canonical->isCanonicalCorrect())) {
return $this->urlExistCache[$url] = $this->trans('page_scan.canonical').' ('.$canonical->get().')';
}

return $return;
return $this->urlExistCache[$url] = true;
}

private function uriExist(string $uri): bool
Expand Down
2 changes: 1 addition & 1 deletion packages/page-scanner/src/translations/messages.en.yaml
Expand Up @@ -2,6 +2,6 @@ page_scan:
different_host: Parent page has a different host
encrypt_mail: to prevent spam, encrypt this link.
not_found: not found
unreachable: unreacheable - errorCode
unreachable: unreacheable - errorMessage
status_code: Unexpected status code
canonical: Canonical is different
2 changes: 1 addition & 1 deletion packages/page-scanner/src/translations/messages.fr.yaml
Expand Up @@ -2,6 +2,6 @@ page_scan:
different_host: La page parente a un domaine différent
encrypt_mail: pour prévenir le spam, vous pouvez encrypter ce lien.
not_found: non trouvé
unreachable: inaccessible - errorCode
unreachable: inaccessible - errorMessage
status_code: Code de réponse HTTP innatendu
canonical: La canonical est différente
6 changes: 3 additions & 3 deletions packages/page-scanner/tests/LinkedDocsScannerTest.php
Expand Up @@ -9,7 +9,7 @@

class LinkedDocsScannerTest extends KernelTestCase
{
public function testIt()
public function testLinkedDocsScanner()
{
self::bootKernel();
$linkedDocsScanner = new LinkedDocsScanner(
Expand All @@ -21,8 +21,8 @@ public function testIt()
$errors = $linkedDocsScanner->scan($this->getPage(), file_get_contents(__DIR__.'/data/page.html'));

$knowedErrors = [
"<code>https://localhost.dev/feed.xml</code> unreacheable - Couldn't resolve host name",
"<code>https://localhost.dev/</code> unreacheable - Couldn't resolve host name",
'<code>https://localhost.dev/feed.xml</code> unreacheable',
'<code>https://localhost.dev/</code> unreacheable',
'<code>#install</code> target not found',
];

Expand Down
Binary file modified packages/skeleton/var/app.db
Binary file not shown.

0 comments on commit 9b5ac09

Please sign in to comment.