Skip to content

Commit 3eef4bb

Browse files
authored
Release/4.14.0 (#564)
* fix: Updated namespace CF to Cloudfare\APO implementation to resolve and prevent namespace conflicts with other plugins. * feat: Add PHP-Scoper build system for vendor namespace prefixing Implement a complete build pipeline to prefix vendor dependencies with `Cloudflare\APO\Vendor\` namespace to prevent conflicts with other plugins. Changes: - Add PHP-Scoper configuration files for psr/log, cloudflare/cf-ip-rewrite, and symfony polyfills (config/php-scoper/*.inc.php) - Add build scripts: build.sh, prefix-dependencies.sh, update-namespaces.php - Add composer.build.json for generating optimized autoloader with prefixed namespaces - Update release workflow to use PHP-Scoper in CI/CD pipeline - Add .gitattributes for export-ignore rules on dev files and vendor dev deps - Update .distignore to exclude build artifacts and test files - Update .gitignore to exclude build/ directory - Add composer scripts: prefix-deps, build * version bump and changelog 4.14.0-beta1 * composer update * added Github workflow related files to .distignore so they don't get added to zip file * Tested up to version bump to 6.9.0 * 4.14.0 release commit. version bump, changelog and compose no-dev update
1 parent 1139d9b commit 3eef4bb

File tree

76 files changed

+691
-326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+691
-326
lines changed

.distignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@
44
/xdebug
55
/scripts
66
/docs
7+
/build
8+
/config
9+
/src/Test
10+
11+
DOCKER_ENV
12+
Dockerfile-php-build
13+
output.log
714

815
.distignore
916
.gitignore
17+
.gitattributes
1018
.editorconfig
1119
CONTRIBUTING.md
1220
docker-compose.yaml

.gitattributes

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Distribution files - exclude from exports and deployments
2+
/.github export-ignore
3+
/build export-ignore
4+
/config export-ignore
5+
/docs export-ignore
6+
/scripts export-ignore
7+
/src/Test export-ignore
8+
/xdebug export-ignore
9+
/.gitignore export-ignore
10+
/.gitattributes export-ignore
11+
/docker-compose.yaml export-ignore
12+
/Dockerfile.wordpress export-ignore
13+
/phpcs.xml export-ignore
14+
/phpunit.xml export-ignore
15+
/CONTRIBUTING.md export-ignore
16+
17+
# Vendor dev dependencies (handled by scoper build process)
18+
/vendor/bin export-ignore
19+
/vendor/johnkary export-ignore
20+
/vendor/php-mock export-ignore
21+
/vendor/phpunit export-ignore
22+
/vendor/squizlabs export-ignore
23+
/vendor/phpcompatibility export-ignore
24+
/vendor/dealerdirect export-ignore
25+
/vendor/phpdocumentor export-ignore
26+
/vendor/nikic export-ignore
27+
/vendor/phpstan export-ignore
28+
/vendor/doctrine export-ignore
29+
/vendor/myclabs export-ignore
30+
/vendor/phar-io export-ignore
31+
/vendor/sebastian export-ignore
32+
/vendor/theseer export-ignore

.github/workflows/release.yml

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Release plugin
22
on:
33
release:
44
types: [published]
5+
56
jobs:
67
release:
78
name: New release
@@ -10,27 +11,79 @@ jobs:
1011
- name: Checkout code
1112
uses: actions/checkout@v3
1213

13-
- name: Build
14-
uses: php-actions/composer@v6
14+
- name: Setup PHP
15+
uses: shivammathur/setup-php@v2
1516
with:
16-
command: install
17-
dev: no
18-
version: 2
19-
php_version: 7.4
17+
php-version: '8.4'
18+
extensions: mbstring, intl
19+
tools: composer:v2
20+
21+
- name: Install dependencies
22+
run: composer install --no-dev --optimize-autoloader --prefer-dist --no-progress
23+
24+
- name: Install PHP-Scoper
25+
run: composer global require humbug/php-scoper:^0.18 --prefer-dist --no-progress
26+
27+
- name: Run PHP-Scoper to prefix vendor dependencies
28+
run: composer prefix-deps
29+
30+
- name: Prepare plugin for deployment
31+
run: |
32+
mkdir -p build/cloudflare/vendor/composer
33+
mkdir -p build/cloudflare/vendor/psr/log
34+
mkdir -p build/cloudflare/vendor/cloudflare/cf-ip-rewrite/src
35+
mkdir -p build/cloudflare/vendor/symfony
36+
37+
# Copy plugin source files (unmodified)
38+
cp -r src build/cloudflare/
39+
cp cloudflare.php build/cloudflare/
40+
cp cloudflare.loader.php build/cloudflare/
41+
cp index.php build/cloudflare/
42+
cp readme.txt build/cloudflare/
43+
cp LICENSE.md build/cloudflare/ 2>/dev/null || true
44+
cp config.json build/cloudflare/ 2>/dev/null || true
45+
cp userConfig.js build/cloudflare/ 2>/dev/null || true
46+
cp compiled.js build/cloudflare/ 2>/dev/null || true
47+
48+
# Copy non-PHP assets
49+
cp -r assets build/cloudflare/ 2>/dev/null || true
50+
cp -r fonts build/cloudflare/ 2>/dev/null || true
51+
cp -r lang build/cloudflare/ 2>/dev/null || true
52+
cp -r stylesheets build/cloudflare/ 2>/dev/null || true
53+
54+
# Copy prefixed vendor dependencies
55+
cp -r build/vendor_prefixed/psr/Psr build/cloudflare/vendor/psr/log/
56+
cp -r build/vendor_prefixed/cloudflare/src/CloudFlare build/cloudflare/vendor/cloudflare/cf-ip-rewrite/src/
57+
cp -r build/vendor_prefixed/symfony/polyfill-intl-idn build/cloudflare/vendor/symfony/
58+
cp -r build/vendor_prefixed/symfony/polyfill-intl-normalizer build/cloudflare/vendor/symfony/
59+
60+
# Generate autoloader with prefixed namespaces using Composer
61+
cp config/composer.build.json build/cloudflare/composer.json
62+
(cd build/cloudflare && composer dump-autoload --optimize --quiet)
63+
rm build/cloudflare/composer.json
64+
65+
- name: Update source files to use prefixed vendor namespaces
66+
run: php scripts/update-namespaces.php build/cloudflare
2067

2168
- name: Remove unsupported PHP 8 symfony/polyfill return types
2269
uses: jacobtomlinson/gha-find-replace@v2
2370
with:
2471
find: ": string|false"
2572
replace: " "
26-
include: "**/symfony/polyfill-intl-{idn,normalizer}/bootstrap80.php"
73+
include: "build/cloudflare/**/symfony/polyfill-intl-{idn,normalizer}/bootstrap80.php"
2774
regex: false
2875

76+
- name: Replace source with built plugin
77+
run: |
78+
rm -rf src vendor
79+
cp -r build/cloudflare/* .
80+
2981
- name: WordPress Plugin Deploy
3082
id: deploy
3183
uses: 10up/action-wordpress-plugin-deploy@stable
3284
with:
3385
generate-zip: true
86+
dry-run: true
3487
env:
3588
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
3689
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ vendor/
33
xdebug/*
44
.phpunit.result.cache
55
.idea
6+
7+
# PHP-Scoper build output
8+
build/

cloudflare.loader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
}
3434

3535
// Initialize Hooks class which contains WordPress hook functions
36-
$cloudflareHooks = new \CF\WordPress\Hooks();
36+
$cloudflareHooks = new \Cloudflare\APO\WordPress\Hooks();
3737

3838
add_action('plugins_loaded', array($cloudflareHooks, 'getCloudflareRequestJSON'));
3939

cloudflare.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Cloudflare
44
Plugin URI: https://blog.cloudflare.com/new-wordpress-plugin/
55
Description: Cloudflare speeds up and protects your WordPress site.
6-
Version: 4.13.0
6+
Version: 4.14.0
77
Requires PHP: 7.4
88
Author: Cloudflare, Inc.
99
License: BSD-3-Clause

composer.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"autoload": {
33
"psr-4": {
4-
"CF\\": "src/"
4+
"Cloudflare\\APO\\": "src/"
55
}
66
},
77
"description": "A Cloudflare plugin for WordPress",
@@ -27,12 +27,14 @@
2727
"format": "php vendor/bin/phpcs -d date.timezone=UTC --standard=phpcs.xml",
2828
"test": "php vendor/bin/phpunit",
2929
"clean-crash-test": "rm -f vendor/phpunit/php-code-coverage/tests/_files/Crash.php",
30-
"remove-php-8-symfony-polyfill-bootstraps": "rm -f vendor/symfony/polyfill-ctype/bootstrap80.php vendor/symfony/polyfill-intl-idn/bootstrap80.php vendor/symfony/polyfill-intl-normalizer/bootstrap80.php"
30+
"remove-php-8-symfony-polyfill-bootstraps": "rm -f vendor/symfony/polyfill-ctype/bootstrap80.php vendor/symfony/polyfill-intl-idn/bootstrap80.php vendor/symfony/polyfill-intl-normalizer/bootstrap80.php",
31+
"prefix-deps": "bash scripts/prefix-dependencies.sh",
32+
"build": "bash scripts/build.sh"
3133
},
3234
"_comment": [
3335
"php-compatibility-install comes from https://github.com/wimg/PHPCompatibility/issues/102#issuecomment-255778195"
3436
],
35-
"version": "4.13.0",
37+
"version": "4.14.0",
3638
"config": {
3739
"platform": {
3840
"php": "7.4"

0 commit comments

Comments
 (0)