From 2dc22f8eda4feca68020bc08b58ab4d2c4a73b1e Mon Sep 17 00:00:00 2001 From: Luca Tumedei Date: Wed, 19 Aug 2020 15:43:27 +0200 Subject: [PATCH 1/3] build(Makefile) add refresh_wp target --- Makefile | 32 +++++++++++++++++++++++++++++--- docker-compose.yml | 6 +++++- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 6fb7807bf..20bbf9272 100644 --- a/Makefile +++ b/Makefile @@ -10,9 +10,6 @@ PROJECT_NAME = $(notdir $(PWD)) # Suppress `make` own output. .SILENT: -# Define what targets should always run. -.PHONY: docker_pull lint sniff fix fix_n_sniff phpstan pre_commit clean docs check_exports build_suites test debug major minor patch - # PUll all the Docker images this repository will use in building images or running processes. docker_pull: images=( \ @@ -31,6 +28,7 @@ docker_pull: for image in "$${images[@]}"; do \ docker pull "$$image"; \ done; +.PHONY: docker_pull # Lint the project source files to make sure they are PHP 5.6 compatible. lint: @@ -38,6 +36,7 @@ lint: --colors \ --exclude /project/src/tad/WPBrowser/Traits/_WithSeparateProcessChecksPHPUnitGte70.php \ /project/src +.PHONY: lint # Use the PHP Code Sniffer container to sniff the relevant source files. sniff: @@ -48,6 +47,7 @@ sniff: --standard=phpcs.xml $(SRC) \ --ignore=src/data,src/includes,src/tad/scripts,src/tad/WPBrowser/Compat \ src +.PHONY: sniff # Use the PHP Code Beautifier container to fix the source and tests code. fix: @@ -58,15 +58,18 @@ fix: --standard=phpcs.xml $(SRC) \ --ignore=src/data,src/includes,src/tad/scripts,_build \ src tests +.PHONY: fix # Fix the PHP code, then sniff it. fix_n_sniff: fix sniff +.PHONY: fix_n_sniff # Use phpstan container to analyze the source code. # Configuration will be read from the phpstan.neon.dist file. PHPSTAN_LEVEL?=2 phpstan: docker run --rm -v ${PWD}:/project lucatume/wpstan analyze -l ${PHPSTAN_LEVEL} +.PHONY: phpstan # Clean the project Docker containers, volumes and networks. clean: @@ -84,6 +87,7 @@ clean: || echo "No networks found". echo "Removing .bak files." && rm -f *.bak echo "Emptying tests/_output directory." && rm -rf tests/_output && mkdir tests/_output && echo "*" > tests/_output/.gitignore +.PHONY: clean # Produces the Modules documentation in the docs/modules folder. docs: composer.lock src/Codeception/Module @@ -114,10 +118,12 @@ docs: composer.lock src/Codeception/Module # Prints a list of files that will be exported from the project on package pull. check_exports: bash ./_build/check_exports.sh +.PHONY: check_exports build_suites: DOCKER_RUN_USER=$$(id -u) DOCKER_RUN_GROUP=$$(id -g) XDE=0 TEST_SUBNET=27 \ docker-compose --project-name=${PROJECT_NAME}_build run --rm codeception build +.PHONY: build_suites test: DOCKER_RUN_USER=$$(id -u) DOCKER_RUN_GROUP=$$(id -g) XDEBUG_DISABLE=1 TEST_SUBNET=128 \ @@ -171,24 +177,31 @@ test: DOCKER_RUN_USER=$$(id -u) DOCKER_RUN_GROUP=$$(id -g) XDEBUG_DISABLE=1 TEST_SUBNET=144 \ docker-compose --project-name=${PROJECT_NAME}_isolated \ run --rm ccf run isolated +.PHONY: test ready: test -f "${PWD}/.ready" && echo $$(<${PWD}/.ready) || echo "No .ready file found." +.PHONY: ready major: _build/release.php major +.PHONY: major minor: _build/release.php minor +.PHONY: minor patch: _build/release.php patch +.PHONY: patch composer_hash_bump: sh "${PWD}/_build/composer-hash.sh" +.PHONY: composer_hash_bump # Run a set of checks on the code before commit. pre_commit: lint fix sniff docs +.PHONY: pre_commit test_56: DOCKER_RUN_USER=$$(id -u) DOCKER_RUN_GROUP=$$(id -g) XDEBUG_DISABLE=1 TEST_SUBNET=89 \ @@ -239,6 +252,7 @@ test_56: DOCKER_RUN_USER=$$(id -u) DOCKER_RUN_GROUP=$$(id -g) XDEBUG_DISABLE=1 TEST_SUBNET=104 \ docker-compose --project-name=${PROJECT_NAME}_isolated \ run --rm cc56 run isolated +.PHONY: test_56 # A variable target to debug issues in a PHP 5.6 environment. debug: @@ -247,6 +261,7 @@ debug: -f docker-compose.debug.yml \ run --rm \ cc56 shell +.PHONY: debug # A variable target to debug issues in a PHP 7.2 environment. debug_7: @@ -255,6 +270,7 @@ debug_7: -f docker-compose.debug.yml \ run --rm \ codeception shell +.PHONY: debug_7 # Populate the vendor/wordpres/wordpress directory. setup_wp: @@ -262,6 +278,16 @@ setup_wp: _build/dc.sh --project-name=${PROJECT_NAME}_setup_wordpress \ -f docker-compose.debug.yml \ up -d wordpress +.PHONY: setup_wp + +# Remove the current WordPress installation, if any, and set it up again. +refresh_wp: + rm -rf vendor/wordpress/wordpress && \ + _build/dc.sh --project-name=${PROJECT_NAME}_refresh_wp \ + -f docker-compose.yml \ + run --rm cli wp core download +.PHONY: refresh_wp build_debug: docker-compose -f docker-compose.yml -f docker-compose.debug.yml build +.PHONY: build_debug diff --git a/docker-compose.yml b/docker-compose.yml index 7fde4caea..e6db80716 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -71,7 +71,6 @@ services: user: ${DOCKER_RUN_USER:-}:${DOCKER_RUN_GROUP:-} networks: test: - ipv4_address: 172.${TEST_SUBNET:-28}.1.1 # Make the WordPress files source directory world writeable, readable and executable, then exit. entrypoint: [ "chmod", "-R" ,"a+rwx", "/usr/src/wordpress" ] volumes: @@ -215,3 +214,8 @@ services: volumes: - .:/project:cached - wordpress:/project/vendor/wordpress/wordpress:cached + + cli : + image: wordpress:cli + volumes: + - ./vendor/wordpress/wordpress:/var/www/html From eb2287447223ca51d24af526b67d66ad27a62bf6 Mon Sep 17 00:00:00 2001 From: Luca Tumedei Date: Wed, 19 Aug 2020 16:06:48 +0200 Subject: [PATCH 2/3] fix(includes) conditionally include newer PHP mailer --- CHANGELOG.md | 3 +++ src/includes/mock-mailer.php | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85ae4b5ec..024fd5f54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ All notable changes after version 1.6.16 to this project will be documented in t This project adheres to [Semantic Versioning](http://semver.org/). ## [unreleased] Unreleased +### Fixed + +- avoid deprecation notices when loading `MockPHPMailer`, fixes #436 ## [2.6.7] 2020-08-14; diff --git a/src/includes/mock-mailer.php b/src/includes/mock-mailer.php index 7acfd579b..c85fa31f8 100644 --- a/src/includes/mock-mailer.php +++ b/src/includes/mock-mailer.php @@ -1,5 +1,16 @@ = 5.5, replicate the aliasing logic here. + require_once ABSPATH . '/wp-includes/PHPMailer/PHPMailer.php'; + require_once ABSPATH . '/wp-includes/PHPMailer/Exception.php'; + class_alias( PHPMailer\PHPMailer\PHPMailer::class, 'PHPMailer' ); + class_alias( PHPMailer\PHPMailer\Exception::class, 'phpmailerException' ); +} else { + // WordPress < 5.5, use the pre-5.5 class name. + require_once( ABSPATH . '/wp-includes/class-phpmailer.php' ); +} +// phpcs:enable class MockPHPMailer extends PHPMailer { var $mock_sent = array(); From f65e76e84fec1d8007983003995e502acb95a66a Mon Sep 17 00:00:00 2001 From: Luca Tumedei Date: Wed, 19 Aug 2020 16:21:31 +0200 Subject: [PATCH 3/3] doc(src) remove wrong comment --- src/tad/WPBrowser/process.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/tad/WPBrowser/process.php b/src/tad/WPBrowser/process.php index 687e84e97..6da84a280 100644 --- a/src/tad/WPBrowser/process.php +++ b/src/tad/WPBrowser/process.php @@ -155,8 +155,6 @@ function process($cmd = [], $cwd = null, $env = null) * @param string|array $command The command line to parse, if in array format it will not be modified. * * @return array The parsed command line, in array format. Untouched if originally already an array. - * - * @uses \Symfony\Component\Process\Process To parse and escape the command line. */ function buildCommandline($command) {