partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 6dbcb74cfd796a6179ff81c6c7b17d5964e8ea39
parent ec4a076508c89bd682b661dd209a934aa0d17197
Author: Felicitus <felicitus@felicitus.org>
Date:   Wed, 30 Sep 2015 16:16:06 +0200

Automatically use the appropriate method to load remote files (either file_get_contents or curl, depending on the user's PHP environment), fixes #433

Diffstat:
Mapp/AppKernel.php | 1+
Mcomposer.json | 3++-
Mcomposer.lock | 150++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------
Msrc/PartKeepr/CoreBundle/Resources/config/services.xml | 1+
Msrc/PartKeepr/CoreBundle/Services/VersionService.php | 11+++++++++--
Msrc/PartKeepr/TipOfTheDayBundle/Resources/config/services.xml | 1+
Msrc/PartKeepr/TipOfTheDayBundle/Services/TipOfTheDayService.php | 18+++++++++---------
7 files changed, 126 insertions(+), 59 deletions(-)

diff --git a/app/AppKernel.php b/app/AppKernel.php @@ -70,6 +70,7 @@ class AppKernel extends Kernel new Brainbits\FugueIconsBundle\BrainbitsFugueIconsBundle(), new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(), new JMS\TranslationBundle\JMSTranslationBundle(), + new \PartKeepr\RemoteFileLoader\PartKeeprRemoteFileLoaderBundle() ); // Developer bundles diff --git a/composer.json b/composer.json @@ -58,7 +58,8 @@ "escapestudios/wsse-authentication-bundle": "2.3.x-dev", "atelierspierrot/famfamfam-silk-sprite": "^1.0", "reputation-vip/composer-assets-installer": "^1.0", - "jms/translation-bundle": "dev-master" + "jms/translation-bundle": "dev-master", + "partkeepr/remote-file-loader": "dev-master" }, "require-dev": { "phpunit/phpunit": "4.8.*", diff --git a/composer.lock b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "89fe89830a0016838b97be2856adfa05", + "hash": "151b5e0a91463043b58cb73202780aec", "packages": [ { "name": "atelierspierrot/famfamfam-silk-sprite", @@ -55,16 +55,16 @@ }, { "name": "behat/transliterator", - "version": "v1.0.1", + "version": "v1.1.0", "source": { "type": "git", "url": "https://github.com/Behat/Transliterator.git", - "reference": "c93521d3462a554332d1ef5bb0e9b5b8ca4106c4" + "reference": "868e05be3a9f25ba6424c2dd4849567f50715003" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Behat/Transliterator/zipball/c93521d3462a554332d1ef5bb0e9b5b8ca4106c4", - "reference": "c93521d3462a554332d1ef5bb0e9b5b8ca4106c4", + "url": "https://api.github.com/repos/Behat/Transliterator/zipball/868e05be3a9f25ba6424c2dd4849567f50715003", + "reference": "868e05be3a9f25ba6424c2dd4849567f50715003", "shasum": "" }, "require": { @@ -73,7 +73,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.1-dev" } }, "autoload": { @@ -91,7 +91,7 @@ "slug", "transliterator" ], - "time": "2014-05-15 22:08:22" + "time": "2015-09-28 16:26:35" }, { "name": "brainbits/fugue-icons-bundle", @@ -911,12 +911,12 @@ "source": { "type": "git", "url": "https://github.com/doctrine/DoctrineMigrationsBundle.git", - "reference": "238aaa5fa04b5755a9957715e269d542cd0f8e39" + "reference": "93ec729e3f2f1bb882904cce9d2c1dde6f139ec8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/DoctrineMigrationsBundle/zipball/238aaa5fa04b5755a9957715e269d542cd0f8e39", - "reference": "238aaa5fa04b5755a9957715e269d542cd0f8e39", + "url": "https://api.github.com/repos/doctrine/DoctrineMigrationsBundle/zipball/93ec729e3f2f1bb882904cce9d2c1dde6f139ec8", + "reference": "93ec729e3f2f1bb882904cce9d2c1dde6f139ec8", "shasum": "" }, "require": { @@ -928,7 +928,7 @@ "type": "symfony-bundle", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.1-dev" } }, "autoload": { @@ -961,7 +961,7 @@ "migrations", "schema" ], - "time": "2015-08-04 22:31:10" + "time": "2015-09-29 10:07:00" }, { "name": "doctrine/inflector", @@ -1144,12 +1144,12 @@ "source": { "type": "git", "url": "https://github.com/doctrine/migrations.git", - "reference": "6c527d8ccbccec5257bb2c92bca973653b1e3976" + "reference": "d196ddc229f50c66c5a015c158adb78a2dfb4351" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/migrations/zipball/6c527d8ccbccec5257bb2c92bca973653b1e3976", - "reference": "6c527d8ccbccec5257bb2c92bca973653b1e3976", + "url": "https://api.github.com/repos/doctrine/migrations/zipball/d196ddc229f50c66c5a015c158adb78a2dfb4351", + "reference": "d196ddc229f50c66c5a015c158adb78a2dfb4351", "shasum": "" }, "require": { @@ -1175,7 +1175,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "v1.0.x-dev" + "dev-master": "v1.1.x-dev" } }, "autoload": { @@ -1203,7 +1203,7 @@ "database", "migrations" ], - "time": "2015-09-21 09:51:07" + "time": "2015-09-29 11:13:06" }, { "name": "doctrine/orm", @@ -1674,16 +1674,16 @@ }, { "name": "gedmo/doctrine-extensions", - "version": "v2.4.6", + "version": "v2.4.7", "source": { "type": "git", "url": "https://github.com/Atlantic18/DoctrineExtensions.git", - "reference": "5d330411e27ab0ced67e1e5383ccae975c23c17d" + "reference": "1a86ba1c7426238b4f765089e0af51174a38af7f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Atlantic18/DoctrineExtensions/zipball/5d330411e27ab0ced67e1e5383ccae975c23c17d", - "reference": "5d330411e27ab0ced67e1e5383ccae975c23c17d", + "url": "https://api.github.com/repos/Atlantic18/DoctrineExtensions/zipball/1a86ba1c7426238b4f765089e0af51174a38af7f", + "reference": "1a86ba1c7426238b4f765089e0af51174a38af7f", "shasum": "" }, "require": { @@ -1693,7 +1693,7 @@ }, "require-dev": { "doctrine/common": ">=2.5.0", - "doctrine/mongodb-odm": "dev-master", + "doctrine/mongodb-odm": ">=1.0.2", "doctrine/orm": ">=2.5.0", "phpunit/phpunit": "~4.4", "phpunit/phpunit-mock-objects": "~2.3", @@ -1749,20 +1749,20 @@ "tree", "uploadable" ], - "time": "2015-08-28 11:07:14" + "time": "2015-09-28 16:39:27" }, { "name": "imagine/imagine", - "version": "0.6.2", + "version": "v0.6.3", "source": { "type": "git", "url": "https://github.com/avalanche123/Imagine.git", - "reference": "83ca8babede0e54f935ec09d55a726bf4b0a3f7c" + "reference": "149041d2a1b517107bfe270ca2b1a17aa341715d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/avalanche123/Imagine/zipball/83ca8babede0e54f935ec09d55a726bf4b0a3f7c", - "reference": "83ca8babede0e54f935ec09d55a726bf4b0a3f7c", + "url": "https://api.github.com/repos/avalanche123/Imagine/zipball/149041d2a1b517107bfe270ca2b1a17aa341715d", + "reference": "149041d2a1b517107bfe270ca2b1a17aa341715d", "shasum": "" }, "require": { @@ -1806,7 +1806,7 @@ "image manipulation", "image processing" ], - "time": "2014-11-11 11:36:02" + "time": "2015-09-19 16:54:05" }, { "name": "incenteev/composer-parameter-handler", @@ -2439,6 +2439,60 @@ "time": "2015-07-01 20:21:32" }, { + "name": "partkeepr/remote-file-loader", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/felicitus/remote-file-loader.git", + "reference": "28ebb808e854f9f3ca0e1efb406d0b25336312ec" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/felicitus/remote-file-loader/zipball/28ebb808e854f9f3ca0e1efb406d0b25336312ec", + "reference": "28ebb808e854f9f3ca0e1efb406d0b25336312ec", + "shasum": "" + }, + "require": { + "php": ">=5.5", + "symfony/framework-bundle": "~2.6|~3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.6" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "PartKeepr\\RemoteFileLoader\\": "" + } + }, + "license": [ + "GPL-3.0+" + ], + "authors": [ + { + "name": "Timo A. Hummel", + "email": "felicitus@felicitus.org", + "homepage": "http://www.felicitus.org", + "role": "Project Lead, Developer" + } + ], + "description": "Abstraction for loading files remotely", + "keywords": [ + "curl", + "file_get_contents" + ], + "support": { + "source": "https://github.com/felicitus/remote-file-loader/tree/master", + "issues": "https://github.com/felicitus/remote-file-loader/issues" + }, + "time": "2015-09-30 13:47:50" + }, + { "name": "phpdocumentor/reflection", "version": "1.0.7", "source": { @@ -2585,12 +2639,12 @@ "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "77a34348d52d18d6f2224ba7635808d52a7a725f" + "reference": "2fb164fd889120a9d9ba19d825e270e5293eecc5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/77a34348d52d18d6f2224ba7635808d52a7a725f", - "reference": "77a34348d52d18d6f2224ba7635808d52a7a725f", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/2fb164fd889120a9d9ba19d825e270e5293eecc5", + "reference": "2fb164fd889120a9d9ba19d825e270e5293eecc5", "shasum": "" }, "require": { @@ -2600,6 +2654,7 @@ "rhumsaa/uuid": "self.version" }, "require-dev": { + "apigen/apigen": "^4.1", "ircmaxell/random-lib": "^1.1", "jakub-onderka/php-parallel-lint": "^0.9.0", "moontoast/math": "^1.1", @@ -2650,7 +2705,7 @@ "identifier", "uuid" ], - "time": "2015-09-04 03:28:07" + "time": "2015-09-29 17:21:43" }, { "name": "reputation-vip/composer-assets-installer", @@ -3089,12 +3144,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/doctrine-bridge.git", - "reference": "783a83b50b688fc5be3becb92462bdc4511dc292" + "reference": "e5ed757d6dcd6fd60dde5da8b7cbec2fab7cb48a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/doctrine-bridge/zipball/783a83b50b688fc5be3becb92462bdc4511dc292", - "reference": "783a83b50b688fc5be3becb92462bdc4511dc292", + "url": "https://api.github.com/repos/symfony/doctrine-bridge/zipball/e5ed757d6dcd6fd60dde5da8b7cbec2fab7cb48a", + "reference": "e5ed757d6dcd6fd60dde5da8b7cbec2fab7cb48a", "shasum": "" }, "require": { @@ -3150,38 +3205,38 @@ ], "description": "Symfony Doctrine Bridge", "homepage": "https://symfony.com", - "time": "2015-09-19 19:59:23" + "time": "2015-09-27 10:08:38" }, { "name": "symfony/monolog-bundle", - "version": "v2.7.1", + "version": "v2.8.0", "source": { "type": "git", "url": "https://github.com/symfony/monolog-bundle.git", - "reference": "9320b6863404c70ebe111e9040dab96f251de7ac" + "reference": "78883d8c1cfa523ac3a28a482b7793036b243f7d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/monolog-bundle/zipball/9320b6863404c70ebe111e9040dab96f251de7ac", - "reference": "9320b6863404c70ebe111e9040dab96f251de7ac", + "url": "https://api.github.com/repos/symfony/monolog-bundle/zipball/78883d8c1cfa523ac3a28a482b7793036b243f7d", + "reference": "78883d8c1cfa523ac3a28a482b7793036b243f7d", "shasum": "" }, "require": { "monolog/monolog": "~1.8", "php": ">=5.3.2", - "symfony/config": "~2.3", - "symfony/dependency-injection": "~2.3", - "symfony/http-kernel": "~2.3", - "symfony/monolog-bridge": "~2.3" + "symfony/config": "~2.3|3.*", + "symfony/dependency-injection": "~2.3|3.*", + "symfony/http-kernel": "~2.3|3.*", + "symfony/monolog-bridge": "~2.3|3.*" }, "require-dev": { - "symfony/console": "~2.3", + "symfony/console": "~2.3|3.*", "symfony/yaml": "~2.3" }, "type": "symfony-bundle", "extra": { "branch-alias": { - "dev-master": "2.7.x-dev" + "dev-master": "2.8.x-dev" } }, "autoload": { @@ -3209,7 +3264,7 @@ "log", "logging" ], - "time": "2015-01-04 20:21:17" + "time": "2015-09-29 17:13:11" }, { "name": "symfony/swiftmailer-bundle", @@ -4899,6 +4954,7 @@ "friendsofsymfony/user-bundle": 20, "escapestudios/wsse-authentication-bundle": 20, "jms/translation-bundle": 20, + "partkeepr/remote-file-loader": 20, "codeclimate/php-test-reporter": 20 }, "prefer-stable": false, diff --git a/src/PartKeepr/CoreBundle/Resources/config/services.xml b/src/PartKeepr/CoreBundle/Resources/config/services.xml @@ -17,6 +17,7 @@ <service id="partkeepr.versionservice" class="PartKeepr\CoreBundle\Services\VersionService"> <argument type="service" id="partkeepr.systemnoticeservice"/> <argument type="service" id="translator"/> + <argument type="service" id="partkeepr.remote_file_loader.factory"/> </service> </services> </container> diff --git a/src/PartKeepr/CoreBundle/Services/VersionService.php b/src/PartKeepr/CoreBundle/Services/VersionService.php @@ -3,6 +3,7 @@ namespace PartKeepr\CoreBundle\Services; use PartKeepr\CoreBundle\PartKeeprVersion; +use PartKeepr\RemoteFileLoader\RemoteFileLoaderFactory; use Symfony\Component\Translation\TranslatorInterface; class VersionService @@ -27,10 +28,16 @@ class VersionService */ private $version; - public function __construct(SystemNoticeService $systemNoticeService, TranslatorInterface $translator) + /** + * @var RemoteFileLoaderFactory + */ + private $remoteFileLoader; + + public function __construct(SystemNoticeService $systemNoticeService, TranslatorInterface $translator, RemoteFileLoaderFactory $remoteFileLoader) { $this->systemNoticeService = $systemNoticeService; $this->translator = $translator; + $this->remoteFileLoader = $remoteFileLoader; if (PartKeeprVersion::PARTKEEPR_VERSION == "{V_GIT}") { $this->setVersion("GIT development version"); @@ -91,7 +98,7 @@ class VersionService public function getLatestVersion() { - $data = file_get_contents($this->versionURI); + $data = $this->remoteFileLoader->createLoader()->load($this->versionURI); $versions = json_decode($data, true); if (!is_array($versions)) { diff --git a/src/PartKeepr/TipOfTheDayBundle/Resources/config/services.xml b/src/PartKeepr/TipOfTheDayBundle/Resources/config/services.xml @@ -9,6 +9,7 @@ <argument type="service" id="service_container"/> <argument type="service" id="doctrine.orm.entity_manager"/> <argument type="service" id="partkeepr.cronlogger_service"/> + <argument type="service" id="partkeepr.remote_file_loader.factory"/> </service> </services> </container> diff --git a/src/PartKeepr/TipOfTheDayBundle/Services/TipOfTheDayService.php b/src/PartKeepr/TipOfTheDayBundle/Services/TipOfTheDayService.php @@ -1,11 +1,9 @@ <?php - - namespace PartKeepr\TipOfTheDayBundle\Services; - use Doctrine\ORM\EntityManager; use PartKeepr\CronLoggerBundle\Services\CronLoggerService; +use PartKeepr\RemoteFileLoader\RemoteFileLoaderFactory; use PartKeepr\TipOfTheDayBundle\Entity\TipOfTheDay; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -27,11 +25,17 @@ class TipOfTheDayService */ private $cronLoggerService; - public function __construct(ContainerInterface $container, EntityManager $entityManager, CronLoggerService $cronLoggerService) + /** + * @var RemoteFileLoaderFactory + */ + private $remoteFileLoader; + + public function __construct(ContainerInterface $container, EntityManager $entityManager, CronLoggerService $cronLoggerService, RemoteFileLoaderFactory $remoteFileLoader) { $this->container = $container; $this->entityManager = $entityManager; $this->cronLoggerService = $cronLoggerService; + $this->remoteFileLoader = $remoteFileLoader; } /** @@ -41,13 +45,9 @@ class TipOfTheDayService */ public function syncTips() { - if (ini_get("allow_url_fopen") == 0) { - throw new \Exception("allow_url_fopen is disabled, but required to query the TipOfTheDay database."); - } - $uri = $this->container->getParameter("partkeepr.tip_of_the_day_list"); - $tipsString = file_get_contents($uri); + $tipsString = $this->remoteFileLoader->createLoader()->load($uri); $aPageNames = $this->extractPageNames($tipsString);