Skip to content

Commit 4f1a4ff

Browse files
committed
Merge branch 'release/1.1.2'
2 parents c2f3fcd + 9b77f8f commit 4f1a4ff

File tree

5 files changed

+53
-8
lines changed

5 files changed

+53
-8
lines changed

.github/workflows/test.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
PHPCS:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v2
11+
- name: Install dependencies
12+
run: composer install --no-progress
13+
- name: Coding Standards
14+
run: composer phpcs
15+
PHPUnit:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v2
23+
- name: Install dependencies
24+
run: composer install --no-progress
25+
- name: PHPUnit
26+
run: |
27+
composer setup-local-tests
28+
composer phpunit

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## 1.1.2 - 10.02.2020
5+
6+
### Changed:
7+
- WP Filesystem is not cached scroll all Filesystem instances for better performance.
8+
49
## 1.1.1 - 05.02.2020
510

611
### Fixed:

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"scripts": {
1212
"phpcs": "phpcs",
1313
"phpcbf": "phpcbf",
14-
"phpunit": "phpunit"
14+
"phpunit": "phpunit",
15+
"phpunit-coverage": "phpunit --coverage-text",
16+
"setup-local-tests": "bash bin/install-wp-tests.sh wordpress_test root root localhost latest"
1517
},
1618
"require": {
1719
"php": ">=5.6"

phpunit.xml.dist renamed to phpunit.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
12
<phpunit
23
bootstrap="tests/bootstrap.php"
34
backupGlobals="false"
@@ -11,4 +12,9 @@
1112
<directory prefix="test-" suffix=".php">./tests/</directory>
1213
</testsuite>
1314
</testsuites>
15+
<filter>
16+
<whitelist>
17+
<directory suffix=".php">./src</directory>
18+
</whitelist>
19+
</filter>
1420
</phpunit>

src/Filesystem.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Filesystem {
2626
*
2727
* @var WP_Filesystem_*
2828
*/
29-
protected $wp_filesystem;
29+
protected static $wp_filesystem;
3030

3131
/**
3232
* WP_Filesystem's methods
@@ -72,7 +72,7 @@ public function __construct( $base_dir ) {
7272

7373
$this->base_dir = trailingslashit( wp_normalize_path( $base_dir ) );
7474

75-
$this->init_wp_filesystem();
75+
self::init_wp_filesystem();
7676

7777
}
7878

@@ -82,14 +82,18 @@ public function __construct( $base_dir ) {
8282
* @since 1.0.0
8383
* @return void
8484
*/
85-
private function init_wp_filesystem() {
85+
private static function init_wp_filesystem() {
86+
87+
if ( self::$wp_filesystem ) {
88+
return;
89+
}
8690

8791
global $wp_filesystem;
8892

8993
require_once ABSPATH . '/wp-admin/includes/file.php';
9094
WP_Filesystem();
9195

92-
$this->wp_filesystem = $wp_filesystem;
96+
self::$wp_filesystem = $wp_filesystem;
9397

9498
}
9599

@@ -111,7 +115,7 @@ public function __call( $method_name, $arguments ) {
111115
$arguments[0] = $this->path( $arguments[0] );
112116
}
113117

114-
return call_user_func_array( [ $this->wp_filesystem, $method_name ], $arguments );
118+
return call_user_func_array( [ self::$wp_filesystem, $method_name ], $arguments );
115119

116120
}
117121

@@ -133,12 +137,12 @@ public function __call( $method_name, $arguments ) {
133137
*/
134138
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false, $recursive = false ) {
135139

136-
if ( ! $this->wp_filesystem instanceof \WP_Filesystem_Direct ) {
140+
if ( ! self::$wp_filesystem instanceof \WP_Filesystem_Direct ) {
137141
if ( $recursive ) {
138142
throw new \Exception( 'Current filesystem method does not support recursive directory creation.' );
139143
}
140144

141-
$this->wp_filesystem->mkdir( $path, $chmod, $chown, $chgrp );
145+
self::$wp_filesystem->mkdir( $path, $chmod, $chown, $chgrp );
142146
}
143147

144148
// Safe mode fails with a trailing slash under certain PHP versions.

0 commit comments

Comments
 (0)