From 40c47f7023577d410818569b3be953c4aa2604cc Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 9 Sep 2016 21:30:13 +0200 Subject: [PATCH 1/4] Check if asset is enable instead of opposite Instead of defining ASSETS all the time, just define it when we want to use it Might give us more clearer build --- .travis.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index c343d5ae4..749b8ef73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,9 +30,9 @@ node_js: - "5" env: - - DB=mysql ASSETS=nobuild - - DB=pgsql ASSETS=nobuild - - DB=sqlite ASSETS=nobuild + - DB=mysql + - DB=pgsql + - DB=sqlite matrix: fast_finish: true @@ -57,7 +57,7 @@ matrix: group: edge env: DB=sqlite - php: 7.0 - env: CS_FIXER=run VALIDATE_TRANSLATION_FILE=run DB=sqlite ASSETS=nobuild + env: CS_FIXER=run VALIDATE_TRANSLATION_FILE=run DB=sqlite - php: 7.0 env: DB=sqlite ASSETS=build allow_failures: @@ -77,11 +77,11 @@ before_script: - if [[ ! $PHP = hhvm* ]]; then phpenv config-rm xdebug.ini || echo "xdebug not available"; fi - if [[ $PHP = 5.5 ]]; then composer require "phpunit/phpunit:4.*" --no-update; fi; - composer self-update --no-progress - - if [[ "$DB" = "pgsql" ]]; then psql -c 'create database wallabag_test;' -U postgres; fi; + - if [[ $DB = pgsql ]]; then psql -c 'create database wallabag_test;' -U postgres; fi; install: - - if [[ $ASSETS != nobuild ]]; then source ~/.nvm/nvm.sh && nvm install 5.0; fi; - - if [[ $ASSETS != nobuild ]]; then npm install -g npm@latest; fi; + - if [[ $ASSETS = build ]]; then source ~/.nvm/nvm.sh && nvm install 5.0; fi; + - if [[ $ASSETS = build ]]; then npm install -g npm@latest; fi; before_install: - if [[ $TRAVIS_REPO_SLUG = wallabag/wallabag ]]; then cp .composer-auth.json ~/.composer/auth.json; fi; @@ -90,5 +90,5 @@ script: - travis_wait bash install.sh - ant prepare-$DB - phpunit -v - - if [ "$CS_FIXER" = "run" ]; then php bin/php-cs-fixer fix src/ --verbose --dry-run ; fi; - - if [ "$VALIDATE_TRANSLATION_FILE" = "run" ]; then php bin/console lint:yaml src/Wallabag/CoreBundle/Resources/translations -v ; fi; + - if [[ $CS_FIXER = run ]]; then php bin/php-cs-fixer fix src/ --verbose --dry-run ; fi; + - if [[ $VALIDATE_TRANSLATION_FILE = run ]]; then php bin/console lint:yaml src/Wallabag/CoreBundle/Resources/translations -v ; fi; From 04d5c60216eb4577fbf9846d10862a332d7656fd Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 11 Sep 2016 12:52:42 +0200 Subject: [PATCH 2/4] Update install.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since $ASSETS can be empty now and only be “build”. --- install.sh | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/install.sh b/install.sh index 414f73f27..a486e8a5b 100755 --- a/install.sh +++ b/install.sh @@ -1,15 +1,8 @@ #! /usr/bin/env bash -if [[ $ASSETS == 'nobuild' ]]; then - composer install --no-interaction --no-progress --prefer-dist -o -else - +if [[ $ASSETS == 'build' ]]; then echo "Installing PHP dependencies through Composer..." - if [[ $ASSETS == 'build' ]]; then - composer install --no-interaction --no-progress --prefer-dist -o - else - SYMFONY_ENV=prod composer install --no-dev -o --prefer-dist - fi + composer install --no-interaction --no-progress --prefer-dist -o chmod ugo+x vendor/mouf/nodejs-installer/bin/local/npm echo "Downloading javascript librairies through npm..." @@ -20,10 +13,6 @@ else echo "Concat, minify and installing assets..." node_modules/grunt/bin/grunt - - if [[ $ASSETS != 'build' ]]; then - echo "Installing wallabag..." - php bin/console wallabag:install --env=prod - fi - +else + composer install --no-interaction --no-progress --prefer-dist -o fi From 58fadbc9df3f8b735c04995919b6cf913ca6a977 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 11 Sep 2016 15:53:16 +0200 Subject: [PATCH 3/4] Fix error on EntityManager clear Introduced in the recent 2.5.5 release. Also updated deps. --- bin/symfony_requirements | 13 ++-- .../ImportBundle/Import/PocketImport.php | 5 +- .../ImportBundle/Import/ReadabilityImport.php | 5 +- .../ImportBundle/Import/WallabagImport.php | 5 +- var/SymfonyRequirements.php | 74 ++++++++++++++----- 5 files changed, 76 insertions(+), 26 deletions(-) diff --git a/bin/symfony_requirements b/bin/symfony_requirements index 8825a9646..a7bf65a1b 100755 --- a/bin/symfony_requirements +++ b/bin/symfony_requirements @@ -22,7 +22,6 @@ echo '> Checking Symfony requirements:'.PHP_EOL.' '; $messages = array(); foreach ($symfonyRequirements->getRequirements() as $req) { - /** @var $req Requirement */ if ($helpText = get_error_message($req, $lineSize)) { echo_style('red', 'E'); $messages['error'][] = $helpText; @@ -121,10 +120,14 @@ function echo_block($style, $title, $message) echo PHP_EOL.PHP_EOL; - echo_style($style, str_repeat(' ', $width).PHP_EOL); - echo_style($style, str_pad(' ['.$title.']', $width, ' ', STR_PAD_RIGHT).PHP_EOL); - echo_style($style, str_pad($message, $width, ' ', STR_PAD_RIGHT).PHP_EOL); - echo_style($style, str_repeat(' ', $width).PHP_EOL); + echo_style($style, str_repeat(' ', $width)); + echo PHP_EOL; + echo_style($style, str_pad(' ['.$title.']', $width, ' ', STR_PAD_RIGHT)); + echo PHP_EOL; + echo_style($style, $message); + echo PHP_EOL; + echo_style($style, str_repeat(' ', $width)); + echo PHP_EOL; } function has_color_support() diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php index 798cfdaef..841f829d0 100644 --- a/src/Wallabag/ImportBundle/Import/PocketImport.php +++ b/src/Wallabag/ImportBundle/Import/PocketImport.php @@ -255,7 +255,10 @@ class PocketImport extends AbstractImport // flush every 20 entries if (($i % 20) === 0) { $this->em->flush(); - $this->em->clear($entry); + + // clear only affected entities + $this->em->clear(Entry::class); + $this->em->clear(Tag::class); } ++$i; } diff --git a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php index 37b160c5c..7bae647d7 100644 --- a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php +++ b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php @@ -169,7 +169,10 @@ class ReadabilityImport extends AbstractImport // flush every 20 entries if (($i % 20) === 0) { $this->em->flush(); - $this->em->clear($entry); + + // clear only affected entities + $this->em->clear(Entry::class); + $this->em->clear(Tag::class); } ++$i; } diff --git a/src/Wallabag/ImportBundle/Import/WallabagImport.php b/src/Wallabag/ImportBundle/Import/WallabagImport.php index a1cc085b3..9cd3dcb8b 100644 --- a/src/Wallabag/ImportBundle/Import/WallabagImport.php +++ b/src/Wallabag/ImportBundle/Import/WallabagImport.php @@ -172,7 +172,10 @@ abstract class WallabagImport extends AbstractImport // flush every 20 entries if (($i % 20) === 0) { $this->em->flush(); - $this->em->clear($entry); + + // clear only affected entities + $this->em->clear(Entry::class); + $this->em->clear(Tag::class); } ++$i; } diff --git a/var/SymfonyRequirements.php b/var/SymfonyRequirements.php index 0a5de5461..f3e8ca8eb 100644 --- a/var/SymfonyRequirements.php +++ b/var/SymfonyRequirements.php @@ -168,6 +168,9 @@ class PhpIniRequirement extends Requirement */ class RequirementCollection implements IteratorAggregate { + /** + * @var Requirement[] + */ private $requirements = array(); /** @@ -265,7 +268,7 @@ class RequirementCollection implements IteratorAggregate /** * Returns both requirements and recommendations. * - * @return array Array of Requirement instances + * @return Requirement[] */ public function all() { @@ -275,7 +278,7 @@ class RequirementCollection implements IteratorAggregate /** * Returns all mandatory requirements. * - * @return array Array of Requirement instances + * @return Requirement[] */ public function getRequirements() { @@ -292,7 +295,7 @@ class RequirementCollection implements IteratorAggregate /** * Returns the mandatory requirements that were not met. * - * @return array Array of Requirement instances + * @return Requirement[] */ public function getFailedRequirements() { @@ -309,7 +312,7 @@ class RequirementCollection implements IteratorAggregate /** * Returns all optional recommendations. * - * @return array Array of Requirement instances + * @return Requirement[] */ public function getRecommendations() { @@ -326,7 +329,7 @@ class RequirementCollection implements IteratorAggregate /** * Returns the recommendations that were not met. * - * @return array Array of Requirement instances + * @return Requirement[] */ public function getFailedRecommendations() { @@ -376,7 +379,8 @@ class RequirementCollection implements IteratorAggregate */ class SymfonyRequirements extends RequirementCollection { - const REQUIRED_PHP_VERSION = '5.3.3'; + const LEGACY_REQUIRED_PHP_VERSION = '5.3.3'; + const REQUIRED_PHP_VERSION = '5.5.9'; /** * Constructor that initializes the requirements. @@ -386,16 +390,26 @@ class SymfonyRequirements extends RequirementCollection /* mandatory requirements follow */ $installedPhpVersion = phpversion(); + $requiredPhpVersion = $this->getPhpRequiredVersion(); - $this->addRequirement( - version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>='), - sprintf('PHP version must be at least %s (%s installed)', self::REQUIRED_PHP_VERSION, $installedPhpVersion), - sprintf('You are running PHP version "%s", but Symfony needs at least PHP "%s" to run. - Before using Symfony, upgrade your PHP installation, preferably to the latest version.', - $installedPhpVersion, self::REQUIRED_PHP_VERSION), - sprintf('Install PHP %s or newer (installed version is %s)', self::REQUIRED_PHP_VERSION, $installedPhpVersion) + $this->addRecommendation( + $requiredPhpVersion, + 'Vendors should be installed in order to check all requirements.', + 'Run the composer install command.', + 'Run the "composer install" command.' ); + if (false !== $requiredPhpVersion) { + $this->addRequirement( + version_compare($installedPhpVersion, $requiredPhpVersion, '>='), + sprintf('PHP version must be at least %s (%s installed)', $requiredPhpVersion, $installedPhpVersion), + sprintf('You are running PHP version "%s", but Symfony needs at least PHP "%s" to run. + Before using Symfony, upgrade your PHP installation, preferably to the latest version.', + $installedPhpVersion, $requiredPhpVersion), + sprintf('Install PHP %s or newer (installed version is %s)', $requiredPhpVersion, $installedPhpVersion) + ); + } + $this->addRequirement( version_compare($installedPhpVersion, '5.3.16', '!='), 'PHP version must not be 5.3.16 as Symfony won\'t work properly with it', @@ -433,7 +447,7 @@ class SymfonyRequirements extends RequirementCollection ); } - if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) { + if (false !== $requiredPhpVersion && version_compare($installedPhpVersion, $requiredPhpVersion, '>=')) { $timezones = array(); foreach (DateTimeZone::listAbbreviations() as $abbreviations) { foreach ($abbreviations as $abbreviation) { @@ -689,7 +703,7 @@ class SymfonyRequirements extends RequirementCollection $this->addRecommendation( \Symfony\Component\Intl\Intl::getIcuDataVersion() === \Symfony\Component\Intl\Intl::getIcuVersion(), sprintf('intl ICU version installed on your system (%s) does not match the ICU data bundled with Symfony (%s)', \Symfony\Component\Intl\Intl::getIcuVersion(), \Symfony\Component\Intl\Intl::getIcuDataVersion()), - 'To avoid internationalization data incosistencies upgrade the symfony/intl component.' + 'To avoid internationalization data inconsistencies upgrade the symfony/intl component.' ); } } @@ -725,9 +739,9 @@ class SymfonyRequirements extends RequirementCollection if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $this->addRecommendation( - $this->getRealpathCacheSize() > 1000, - 'realpath_cache_size should be above 1024 in php.ini', - 'Set "realpath_cache_size" to e.g. "1024" in php.ini* to improve performance on windows.' + $this->getRealpathCacheSize() > 5 * 1024 * 1024, + 'realpath_cache_size should be above 5242880 in php.ini', + 'Setting "realpath_cache_size" to e.g. "5242880" or "5000k" in php.ini* may improve performance on Windows significantly in some cases.' ); } @@ -778,4 +792,28 @@ class SymfonyRequirements extends RequirementCollection return (int) $size; } } + + /** + * Defines PHP required version from Symfony version. + * + * @return string|false The PHP required version or false if it could not be guessed + */ + protected function getPhpRequiredVersion() + { + if (!file_exists($path = __DIR__.'/../composer.lock')) { + return false; + } + + $composerLock = json_decode(file_get_contents($path), true); + foreach ($composerLock['packages'] as $package) { + $name = $package['name']; + if ('symfony/symfony' !== $name && 'symfony/http-kernel' !== $name) { + continue; + } + + return (int) $package['version'][1] > 2 ? self::REQUIRED_PHP_VERSION : self::LEGACY_REQUIRED_PHP_VERSION; + } + + return false; + } } From 88e88016b9a86d76940082b62c85c3756f461cb2 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 11 Sep 2016 16:30:01 +0200 Subject: [PATCH 4/4] Clearing entities in the loop fail on Postgres It looks like when you clear entities on Postgres some references are lost and tags are not saved :-/ --- src/Wallabag/ImportBundle/Import/PocketImport.php | 5 +---- src/Wallabag/ImportBundle/Import/ReadabilityImport.php | 5 +---- src/Wallabag/ImportBundle/Import/WallabagImport.php | 5 +---- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php index 841f829d0..a6f905b14 100644 --- a/src/Wallabag/ImportBundle/Import/PocketImport.php +++ b/src/Wallabag/ImportBundle/Import/PocketImport.php @@ -255,14 +255,11 @@ class PocketImport extends AbstractImport // flush every 20 entries if (($i % 20) === 0) { $this->em->flush(); - - // clear only affected entities - $this->em->clear(Entry::class); - $this->em->clear(Tag::class); } ++$i; } $this->em->flush(); + $this->em->clear(); } } diff --git a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php index 7bae647d7..c7cfe15d9 100644 --- a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php +++ b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php @@ -169,14 +169,11 @@ class ReadabilityImport extends AbstractImport // flush every 20 entries if (($i % 20) === 0) { $this->em->flush(); - - // clear only affected entities - $this->em->clear(Entry::class); - $this->em->clear(Tag::class); } ++$i; } $this->em->flush(); + $this->em->clear(); } } diff --git a/src/Wallabag/ImportBundle/Import/WallabagImport.php b/src/Wallabag/ImportBundle/Import/WallabagImport.php index 9cd3dcb8b..581ec178f 100644 --- a/src/Wallabag/ImportBundle/Import/WallabagImport.php +++ b/src/Wallabag/ImportBundle/Import/WallabagImport.php @@ -172,15 +172,12 @@ abstract class WallabagImport extends AbstractImport // flush every 20 entries if (($i % 20) === 0) { $this->em->flush(); - - // clear only affected entities - $this->em->clear(Entry::class); - $this->em->clear(Tag::class); } ++$i; } $this->em->flush(); + $this->em->clear(); } /**