Skip to content

Commit 1c7d794

Browse files
authored
Merge pull request #2 from ExpressionEngine/feature/php8.4
PHP 8.4 Support
2 parents 01b7b1c + 4f92c6b commit 1c7d794

2,496 files changed

Lines changed: 13882 additions & 51333 deletions

File tree

Some content is hidden

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

.github/workflows/docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ jobs:
3535
npm install
3636
npm run build
3737
- name: Upload artifact
38-
uses: actions/upload-pages-artifact@v1
38+
uses: actions/upload-pages-artifact@v3
3939
with:
4040
path: 'docs/build'
4141
- name: Setup Pages
42-
uses: actions/configure-pages@v2
42+
uses: actions/configure-pages@v5
4343
deploy:
4444
environment:
4545
name: github-pages
@@ -49,4 +49,4 @@ jobs:
4949
steps:
5050
- name: Deploy to GitHub Pages
5151
id: deployment
52-
uses: actions/deploy-pages@v1
52+
uses: actions/deploy-pages@v4

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
rm -f .gitignore
8080
8181
- name: Archive Add-on
82-
uses: actions/upload-artifact@v2
82+
uses: actions/upload-artifact@v4
8383
with:
8484
name: cloud_files
8585
path: cloud_files

.github/workflows/tests.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Setup PHP
3434
uses: shivammathur/setup-php@v2
3535
with:
36-
php-version: '7.4'
36+
php-version: '8.2'
3737
extensions: dom, curl, sqlite, libxml, mbstring, zip, pcntl, pdo, mysql, bcmath, soap, intl, gd, exif, iconv, imagick
3838
coverage: none
3939
ini-values: error_log=/home/runner/php_errors.log, memory_limit=128M
@@ -52,7 +52,7 @@ jobs:
5252
working-directory: ee/build-tools
5353
run: |
5454
content=`node -pe 'JSON.parse(process.argv[1]).tag' "$(cat build.json)"`
55-
echo "::set-output name=BUILD_VERSION::$content"
55+
echo "BUILD_VERSION=$content" >> $GITHUB_OUTPUT
5656
5757
- name: Run build process
5858
working-directory: ee/build-tools
@@ -98,7 +98,7 @@ jobs:
9898
strategy:
9999
fail-fast: false
100100
matrix:
101-
php: [7.4, 8.0, 8.1, 8.2]
101+
php: [7.4, 8.0, 8.1, 8.2, 8.3, 8.4]
102102
os: [ubuntu-latest]
103103

104104
name: Cypress Tests, PHP${{ matrix.php }} - ${{ matrix.os }}
@@ -175,13 +175,12 @@ jobs:
175175
run: php tests/serve.php &
176176

177177
- name: Run Cypress Tests
178-
uses: cypress-io/github-action@v3
178+
uses: cypress-io/github-action@v6
179179
with:
180180
spec: cypress/integration/addon_cloud_files/**
181181
browser: chrome
182-
headless: true
183182
working-directory: tests/cypress
184-
config-file: cypress.json
183+
config-file: cypress.config.js
185184
env:
186185
CYPRESS_AWS_S3_KEY: ${{secrets.AWS_S3_KEY}}
187186
CYPRESS_AWS_S3_SECRET: ${{secrets.AWS_S3_SECRET}}
@@ -196,18 +195,22 @@ jobs:
196195
CYPRESS_CF_R2_SECRET: ${{secrets.CF_R2_SECRET}}
197196
CYPRESS_CF_R2_BUCKET: ${{secrets.CF_R2_BUCKET}}
198197
CYPRESS_CF_R2_URL: ${{secrets.CF_R2_URL}}
198+
CYPRESS_BB_B2_KEY: ${{secrets.BB_B2_KEY}}
199+
CYPRESS_BB_B2_SECRET: ${{secrets.BB_B2_SECRET}}
200+
CYPRESS_BB_B2_REGION: ${{secrets.BB_B2_REGION}}
201+
CYPRESS_BB_B2_BUCKET: ${{secrets.BB_B2_BUCKET}}
199202
CYPRESS_CF_TEST_FOLDER: ${{ matrix.php }}_${{ github.sha }}
200203
CYPRESS_KEEP_DEBUG: ${{vars.KEEP_DEBUG != 'false'}}
201204

202205
- name: Archive screenshots
203-
uses: actions/upload-artifact@v2
206+
uses: actions/upload-artifact@v4
204207
if: vars.KEEP_DEBUG != 'false' && failure()
205208
with:
206209
name: cypress-tests-PHP${{ matrix.php }}
207210
path: tests/cypress/cypress/screenshots/
208211

209212
- name: Archive server errors
210-
uses: actions/upload-artifact@v2
213+
uses: actions/upload-artifact@v4
211214
if: vars.KEEP_DEBUG != 'false' && failure()
212215
with:
213216
name: error.PHP${{ matrix.php }}.log

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.DS_Store
22
/vendor/
3-
/vendor-bin/*/vendor
3+
/vendor-bin/*/vendor
4+
node_modules/

Adapter/BackblazeB2.php

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?php
2+
3+
namespace CloudFiles\Adapter;
4+
5+
use ExpressionEngine\Dependency\Aws\S3\S3Client;
6+
use ExpressionEngine\Dependency\League\Flysystem;
7+
use ExpressionEngine\Library\Filesystem\Adapter\AdapterInterface;
8+
use ExpressionEngine\Library\Filesystem\Adapter\AdapterTrait;
9+
use ExpressionEngine\Service\Validation\ValidationAware;
10+
11+
class BackblazeB2 extends Flysystem\AwsS3v3\AwsS3Adapter implements AdapterInterface, ValidationAware
12+
{
13+
use AdapterTrait;
14+
15+
protected $_validation_rules = [
16+
'key' => 'required',
17+
'secret' => 'required',
18+
'region' => 'required',
19+
'bucket' => 'required',
20+
];
21+
22+
public function __construct($settings = [])
23+
{
24+
$this->settings = $settings;
25+
$client = new S3Client([
26+
'credentials' => [
27+
'key' => $settings['key'],
28+
'secret' => $settings['secret']
29+
],
30+
'region' => $settings['region'] ?: 'east-001',
31+
'version' => 'latest',
32+
'endpoint' => "https://s3.{$settings['region']}.backblazeb2.com",
33+
'exception_class' => \ExpressionEngine\Dependency\Aws\S3\Exception\S3Exception::class
34+
]);
35+
36+
parent::__construct($client, $settings['bucket']);
37+
}
38+
39+
public static function getSettingsForm($settings)
40+
{
41+
return [
42+
[
43+
'title' => 'Application Key ID',
44+
'desc' => 'Enter your Backblaze B2 Key ID',
45+
'fields' => [
46+
'adapter_settings[key]' => [
47+
'type' => 'text',
48+
'value' => $settings['key'] ?? '',
49+
'required' => true
50+
]
51+
]
52+
],
53+
[
54+
'title' => 'Application Key',
55+
'desc' => 'Enter your Backblaze B2 Key',
56+
'fields' => [
57+
'adapter_settings[secret]' => [
58+
'type' => 'text',
59+
'value' => $settings['secret'] ?? '',
60+
'required' => true
61+
]
62+
]
63+
],
64+
[
65+
'title' => 'Region',
66+
'desc' => 'Enter the region for your Backblaze B2 Bucket',
67+
'fields' => [
68+
'adapter_settings[region]' => [
69+
'type' => 'text',
70+
'value' => $settings['region'] ?? '',
71+
'required' => true
72+
]
73+
]
74+
],
75+
[
76+
'title' => 'Bucket Name',
77+
'desc' => 'Enter the name of your Backblaze B2 Bucket',
78+
'fields' => [
79+
'adapter_settings[bucket]' => [
80+
'type' => 'text',
81+
'value' => $settings['bucket'] ?? '',
82+
'required' => true
83+
]
84+
]
85+
],
86+
[
87+
'title' => 'Path',
88+
'desc' => 'Enter the path inside your Backblaze B2 Bucket',
89+
'fields' => [
90+
'server_path' => [
91+
'type' => 'text',
92+
'value' => $settings['server_path'] ?? '',
93+
'required' => false
94+
]
95+
]
96+
],
97+
[
98+
'title' => 'Url',
99+
'desc' => 'Enter the url used to access your Backblaze B2 Bucket',
100+
'fields' => [
101+
'url' => [
102+
'type' => 'text',
103+
'value' => $settings['url'] ?? '',
104+
'required' => false
105+
]
106+
]
107+
]
108+
];
109+
}
110+
111+
public function getBaseUrl()
112+
{
113+
return implode('/', array_filter([
114+
'https://s3.'.$this->settings['region'].'.backblazeb2.com',
115+
$this->getBucket(),
116+
$this->getPathPrefix()
117+
]));
118+
}
119+
}

Adapter/CloudflareR2.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,16 @@ public function getBaseUrl()
118118
$this->getPathPrefix()
119119
]));
120120
}
121+
122+
/**
123+
* Get the object acl presented as a visibility.
124+
*
125+
* @param string $path
126+
*
127+
* @return string
128+
*/
129+
protected function getRawVisibility($path)
130+
{
131+
return Flysystem\AdapterInterface::VISIBILITY_PRIVATE;
132+
}
121133
}

Adapter/DigitalOcean.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct($settings = [])
2727
'key' => $settings['key'],
2828
'secret' => $settings['secret']
2929
],
30-
'region' => $settings['region'],
30+
'region' => $settings['region'] ?: 'nyc1',
3131
'version' => 'latest',
3232
'endpoint' => "https://{$settings['region']}.digitaloceanspaces.com",
3333
'exception_class' => \ExpressionEngine\Dependency\Aws\S3\Exception\S3Exception::class

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
## [Unreleased]
44

5+
### Added
6+
7+
- Filesystem Adapter for integrating with Backblaze B2 service
8+
- Support for PHP 8.4
9+
10+
### Fixed
11+
12+
- An issue with Cloudflare R2 where moving a file into a different subfolder would fail
13+
514
## [1.1.0] - 2023-07-28
615

716
### Added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Cloud Files
22

3-
For installation and usage please [read the documentation](docs/index.md)
3+
For installation and usage please [read the documentation](docs/docs/index.md)
44

55
## Contributing
66

addon.setup.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
<?php
2+
// Cloud Files works with all PHP versions supported by ExpressionEngine 7
3+
// However the S3 SDK is now showing warnings when used with older PHP versions
4+
// https://aws.amazon.com/blogs/developer/announcing-the-end-of-support-for-php-runtimes-8-0-x-and-below-in-the-aws-sdk-for-php/
5+
$_ENV['AWS_SUPPRESS_PHP_DEPRECATION_WARNING'] = $_ENV['AWS_SUPPRESS_PHP_DEPRECATION_WARNING'] ?? true;
26

37
require __DIR__ . '/vendor-build/autoload.php';
48

@@ -12,7 +16,8 @@
1216
'settings_exist' => false,
1317
'filesystem_adapters' => [
1418
\CloudFiles\Adapter\AwsS3::class,
15-
\CloudFiles\Adapter\DigitalOcean::class,
19+
\CloudFiles\Adapter\BackblazeB2::class,
1620
\CloudFiles\Adapter\CloudflareR2::class,
21+
\CloudFiles\Adapter\DigitalOcean::class,
1722
]
1823
);

0 commit comments

Comments
 (0)