From d70c8d2c3bf50ae25e28768ef8482ec55d22aa63 Mon Sep 17 00:00:00 2001 From: Luke Fromhold Date: Mon, 29 Oct 2018 15:35:33 +1100 Subject: [PATCH 01/14] Applying injection pattern of framework dbfield classes, fixing InjectorNotFoundException error 'ExternalURL does not exist' --- _config/config.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 _config/config.yml diff --git a/_config/config.yml b/_config/config.yml new file mode 100644 index 0000000..586e40b --- /dev/null +++ b/_config/config.yml @@ -0,0 +1,6 @@ +--- +Name: externalurlfield +--- +SilverStripe\Core\Injector\Injector: + ExternalURL: + class: BurnBright\ExternalURLField\ExternalURL From f4c415105aad603e5bb6810042ed809f46c709fe Mon Sep 17 00:00:00 2001 From: Luke Fromhold Date: Mon, 29 Oct 2018 15:38:08 +1100 Subject: [PATCH 02/14] Update field setValue to resolve E_STRICT notice 'declaration of methods should be compatible with parent methods in php' --- src/ExternalURLField.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ExternalURLField.php b/src/ExternalURLField.php index 60acda7..7924960 100644 --- a/src/ExternalURLField.php +++ b/src/ExternalURLField.php @@ -116,13 +116,15 @@ public function getAttributes() /** * Rebuild url on save * @param string $url + * @param array|DataObject $data {@see Form::loadDataFrom} + * @return $this */ - public function setValue($url) + public function setValue($url, $data = null) { if ($url) { $url = $this->rebuildURL($url); } - parent::setValue($url); + parent::setValue($url, $data); } /** From da4fa932f1ac74eb1d7670809b5406b9ba81dcde Mon Sep 17 00:00:00 2001 From: Luke Fromhold Date: Mon, 29 Oct 2018 15:38:58 +1100 Subject: [PATCH 03/14] Update composer package type so that module is installed to vendor directory rather than project root --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 22e4e95..c948557 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "burnbright/silverstripe-externalurlfield", "description": "Provides SilverStripe with a DBField and FormField for handling external URLs.", - "type": "silverstripe-module", + "type": "silverstripe-vendormodule", "license": "MIT", "keywords": ["silverstripe", "url", "link", "form", "field"], "require": { From af19d881041cc941bcc823bdb77497d1eab79d9a Mon Sep 17 00:00:00 2001 From: Luke Fromhold Date: Mon, 29 Oct 2018 15:39:45 +1100 Subject: [PATCH 04/14] Removing now-superfluous 'installer-name' extra var from composer --- composer.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/composer.json b/composer.json index c948557..d60d181 100644 --- a/composer.json +++ b/composer.json @@ -8,9 +8,6 @@ "silverstripe/framework": "^4.0@dev", "jakeasmith/http_build_url": "^1" }, - "extra": { - "installer-name": "externalurlfield" - }, "authors": [ { "name": "Jeremy Shipman", From 194901c1420deafdc1817da414a748f4c68ba050 Mon Sep 17 00:00:00 2001 From: Luke Fromhold Date: Mon, 29 Oct 2018 16:28:00 +1100 Subject: [PATCH 05/14] Adding composer vendor-plugin dependency --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index d60d181..9945c75 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "keywords": ["silverstripe", "url", "link", "form", "field"], "require": { "silverstripe/framework": "^4.0@dev", + "silverstripe/vendor-plugin": "^1.0", "jakeasmith/http_build_url": "^1" }, "authors": [ From 45febcbcfd9b504e40cfcaff2e28f6c6db2aaace Mon Sep 17 00:00:00 2001 From: Luke Fromhold Date: Mon, 29 Oct 2018 16:29:57 +1100 Subject: [PATCH 06/14] Removing PHP 5.5 from travis build, as SS4 is only supporting PHP >=5.6 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 202ee53..8d44cc7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.5 - 5.6 - 7.0 - 7.1 From da757fb615e1ac4e61a4355c5b5bc43a74e93895 Mon Sep 17 00:00:00 2001 From: Luke Fromhold Date: Mon, 29 Oct 2018 17:59:12 +1100 Subject: [PATCH 07/14] Updating travis.yml for SS4 configuration (per SS blog post https://bit.ly/2PuWUWo ) --- .travis.yml | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8d44cc7..0c85743 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,34 +1,31 @@ language: php -php: - - 5.6 - - 7.0 - - 7.1 - env: - - DB=MYSQL CORE_RELEASE=4 + global: + - COMPOSER_ROOT_VERSION="4.x-dev" matrix: include: - - php: 7.1 - env: DB=SQLITE CORE_RELEASE=4 COVERAGE=1 - php: 5.6 - env: DB=PGSQL CORE_RELEASE=4 + env: DB=MYSQL PHPCS_TEST=1 PHPUNIT_TEST=1 + - php: 7.0 + env: DB=PGSQL PHPUNIT_TEST=1 + - php: 7.1 + env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1 before_script: - - composer self-update - phpenv rehash - - git clone git://github.com/silverstripe/silverstripe-travis-support.git ~/travis-support - - php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss - - cd ~/builds/ss + - phpenv config-rm xdebug.ini + + - composer validate + - composer require --no-update silverstripe/recipe-core:1.0.x-dev + - if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql:2.0.x-dev; fi + - composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile script: - - "if [ \"$COVERAGE\" != \"1\" ]; then vendor/bin/phpunit externalurlfield/tests; fi" - - "if [ \"$COVERAGE\" = \"1\" ]; then vendor/bin/phpunit --coverage-clover ~/coverage.xml externalurlfield/tests; fi" + - if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests/; fi + - if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi + - if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs --standard=vendor/silverstripe/framework/phpcs.xml.dist src/ tests/ ; fi after_success: - - > - test "$COVERAGE" = "1" - && cd externalurlfield - && wget https://scrutinizer-ci.com/ocular.phar - && php ocular.phar code-coverage:upload -v --format=php-clover ~/coverage.xml + - if [[ $PHPUNIT_COVERAGE_TEST ]]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload -v --format=php-clover coverage.xml; fi From 0bfca99960e67079ab12653a12f6066dfbceaf5c Mon Sep 17 00:00:00 2001 From: Luke Fromhold Date: Mon, 29 Oct 2018 18:09:19 +1100 Subject: [PATCH 08/14] Updating recipe-core version --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0c85743..53c6846 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,8 +18,8 @@ before_script: - phpenv config-rm xdebug.ini - composer validate - - composer require --no-update silverstripe/recipe-core:1.0.x-dev - - if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql:2.0.x-dev; fi + - composer require --no-update silverstripe/recipe-core:4.x-dev + - if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql:2.x-dev; fi - composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile script: From 37ebdf29b52f63f0cac29c443915bf615a89abce Mon Sep 17 00:00:00 2001 From: Luke Fromhold Date: Mon, 29 Oct 2018 18:18:12 +1100 Subject: [PATCH 09/14] Adjusting module min stability --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 9945c75..d5e8116 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "license": "MIT", "keywords": ["silverstripe", "url", "link", "form", "field"], "require": { - "silverstripe/framework": "^4.0@dev", + "silverstripe/framework": "^4.0", "silverstripe/vendor-plugin": "^1.0", "jakeasmith/http_build_url": "^1" }, @@ -21,5 +21,6 @@ "BurnBright\\ExternalURLField\\": "src/", "BurnBright\\ExternalURLField\\Tests\\": "tests/" } - } + }, + "minimum-stability": "dev" } From 8002749df409f0f9a5a790abcef9f64f2216837c Mon Sep 17 00:00:00 2001 From: Luke Fromhold Date: Mon, 29 Oct 2018 18:45:56 +1100 Subject: [PATCH 10/14] Including root phpunit/phpcs --- composer.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/composer.json b/composer.json index d5e8116..fbfbfb4 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,10 @@ "silverstripe/vendor-plugin": "^1.0", "jakeasmith/http_build_url": "^1" }, + "require-dev": { + "phpunit/phpunit": "^5.7", + "squizlabs/php_codesniffer": "^3.0" + }, "authors": [ { "name": "Jeremy Shipman", From a0a930b2fa841db1e26ed40b78b12cadfb7389ad Mon Sep 17 00:00:00 2001 From: Luke Fromhold Date: Mon, 29 Oct 2018 18:55:17 +1100 Subject: [PATCH 11/14] Updating phpunit config for ss4/vendormodule paths plus codesniffer config --- phpcs.xml.dist | 9 +++++++++ phpunit.xml.dist | 10 ++++------ 2 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 phpcs.xml.dist diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..1b984f8 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,9 @@ + + + CodeSniffer ruleset for SilverStripe coding conventions. + + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2afe2c2..98c899d 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,18 +1,16 @@ - + + tests - - - - - src/ + src/. tests/ + From 39a2868f43cf40100fd695656269af69ea8a7fb6 Mon Sep 17 00:00:00 2001 From: Luke Fromhold Date: Mon, 29 Oct 2018 18:58:32 +1100 Subject: [PATCH 12/14] Removing phpcs config --- phpcs.xml.dist | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 phpcs.xml.dist diff --git a/phpcs.xml.dist b/phpcs.xml.dist deleted file mode 100644 index 1b984f8..0000000 --- a/phpcs.xml.dist +++ /dev/null @@ -1,9 +0,0 @@ - - - CodeSniffer ruleset for SilverStripe coding conventions. - - - - - - From b3ac388492d605da02596e7ff474c3d6bd17498a Mon Sep 17 00:00:00 2001 From: Luke Fromhold Date: Mon, 29 Oct 2018 19:17:10 +1100 Subject: [PATCH 13/14] We haven't given up. --- .travis.yml | 6 +++--- phpcs.xml.dist | 11 +++++++++++ phpunit.xml.dist | 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 phpcs.xml.dist diff --git a/.travis.yml b/.travis.yml index 53c6846..6084cdc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,12 +20,12 @@ before_script: - composer validate - composer require --no-update silverstripe/recipe-core:4.x-dev - if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql:2.x-dev; fi - - composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile + - composer install --prefer-source --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile script: - - if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests/; fi + - if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi - if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi - - if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs --standard=vendor/silverstripe/framework/phpcs.xml.dist src/ tests/ ; fi + - if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src tests; fi after_success: - if [[ $PHPUNIT_COVERAGE_TEST ]]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload -v --format=php-clover coverage.xml; fi diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..3e2e380 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,11 @@ + + + CodeSniffer ruleset for SilverStripe coding conventions. + + + + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 98c899d..9508444 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,12 +1,12 @@ - tests + tests/ - src/. + src/ tests/ From 7f4074d785ccd707439c332072edb91c895f8488 Mon Sep 17 00:00:00 2001 From: Luke Fromhold Date: Mon, 29 Oct 2018 19:25:38 +1100 Subject: [PATCH 14/14] Yet. --- src/ExternalURLField.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ExternalURLField.php b/src/ExternalURLField.php index 7924960..1de1323 100644 --- a/src/ExternalURLField.php +++ b/src/ExternalURLField.php @@ -33,7 +33,10 @@ class ExternalURLField extends TextField 'fragment' => false ), 'html5validation' => true, - 'validregex' => '%^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@|\d{1,3}(?:\.\d{1,3}){3}|(?:(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)(?:\.(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)*(?:\.[a-z\x{00a1}-\x{ffff}]{2,6}))(?::\d+)?(?:[^\s]*)?$%iu' + 'validregex' => '%^(?:(?:https?|ftp)://)(?:\S+(?::\S*)' + . '?@|\d{1,3}(?:\.\d{1,3}){3}|(?:(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)' + . '(?:\.(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)*(?:\.[a-z\x{00a1}-\x{ffff}]{2,6}))' + . '(?::\d+)?(?:[^\s]*)?$%iu' ); /**