-
Notifications
You must be signed in to change notification settings - Fork 40
Restore backup #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Restore backup #119
Changes from all commits
6af270d
86e8030
88bc995
7a90ef7
8fc5564
38e0029
39fb07b
2521b11
834e024
8b380e3
c8b54f5
a3fb73a
befe6d5
de2e855
a252aab
c77f3ea
2feb2f3
5b1193c
498c6f1
70b68bb
959d0a4
af5cdc6
7018b13
94eda1b
2d67c26
d39dea5
dd43184
13f9626
f605450
f029496
eb220d1
c648f7a
431106b
2d91d6f
73d1a04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,12 +115,10 @@ public static function get_mimetype( $input ) { | |
| * Gets or initializes the WordPress filesystem instance. | ||
| * | ||
| * Returns the global WP_Filesystem instance, initializing it if necessary. | ||
| * This helper prevents repeated initialization code throughout the plugin. | ||
| * | ||
| * @since 3.7.0 | ||
| * | ||
| * @return WP_Filesystem_Base The WP_Filesystem instance. | ||
| * @throws Exception If the filesystem cannot be initialized. | ||
| * @return WP_Filesystem_Base|false The WP_Filesystem instance, or false on failure. | ||
| */ | ||
| public static function get_wp_filesystem() { | ||
| global $wp_filesystem; | ||
|
|
@@ -129,14 +127,15 @@ public static function get_wp_filesystem() { | |
| return $wp_filesystem; | ||
| } | ||
|
|
||
| // Initialize the filesystem only if the function isn't available yet. | ||
| if ( ! function_exists( 'WP_Filesystem' ) ) { | ||
| require_once ABSPATH . 'wp-admin/includes/file.php'; | ||
| } | ||
| WP_Filesystem(); | ||
|
|
||
| if ( ! ( $wp_filesystem instanceof WP_Filesystem_Base ) ) { | ||
| throw new Exception( 'Unable to initialize WordPress filesystem.' ); | ||
| // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log | ||
| error_log( 'Tiny Compress: Unable to initialize WordPress filesystem.' ); | ||
| return false; | ||
|
Comment on lines
+136
to
+138
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- target file context ---'
sed -n '100,155p' src/class-tiny-helpers.php
printf '%s\n' '--- related filesystem calls and declarations ---'
rg -n -C 3 'WP_Filesystem|wp_filesystem|WP_Filesystem_Base' src tests .github 2>/dev/null || true
printf '%s\n' '--- repository metadata and dependency references ---'
rg -n -C 2 'wordpress|WP_Filesystem' composer.json composer.lock package.json phpunit.xml* README.md 2>/dev/null || trueRepository: tinify/wordpress-plugin Length of output: 16525 🌐 Web query:
💡 Result: In the WordPress core function WP_Filesystem, the global variable $wp_filesystem is indeed assigned an instance of the chosen filesystem class before the $wp_filesystem->connect method is called [1][2][3]. The implementation follows this sequence: 1. The filesystem method is determined via get_filesystem_method [1][4]. 2. The corresponding filesystem class is instantiated and assigned to the global variable: $wp_filesystem = new $method($args); [1][5]. 3. The function then proceeds to perform checks (such as verifying potential errors) and defines connection timeouts [1][5][3]. 4. Finally, it attempts to connect using $wp_filesystem->connect [1][5][3]. If $wp_filesystem->connect returns false, the function returns false [1][5][3]. Because the assignment to the global $wp_filesystem has already occurred, the global variable remains populated with the instantiated object even if the connection attempt fails [1][2]. Consequently, developers should verify both that the function returned true and that the filesystem object successfully connected or is ready for use, rather than relying solely on the existence of the global variable [6][7][8]. Citations:
🏁 Script executed: #!/bin/bash
set -eu
python3 - <<'PY'
import urllib.request
url = "https://raw.githubusercontent.com/WordPress/wordpress-develop/trunk/src/wp-admin/includes/file.php"
text = urllib.request.urlopen(url, timeout=10).read().decode()
start = text.index("function WP_Filesystem(")
end = text.find("\n}", start) + 2
print(text[start:end])
PYRepository: tinify/wordpress-plugin Length of output: 2447 🏁 Script executed: #!/bin/bash
set -eu
python3 - <<'PY'
import ssl
import urllib.request
url = "https://raw.githubusercontent.com/WordPress/wordpress-develop/trunk/src/wp-admin/includes/file.php"
context = ssl._create_unverified_context()
text = urllib.request.urlopen(url, context=context, timeout=10).read().decode()
start = text.index("function WP_Filesystem(")
# Print only the function body region, bounded by the next documented top-level function.
next_function = text.find("\nfunction ", start + 1)
print(text[start:next_function if next_function != -1 else start + 5000])
PYRepository: tinify/wordpress-plugin Length of output: 3341 Check the return value from A failed connection can leave a 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| return $wp_filesystem; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: tinify/wordpress-plugin
Length of output: 3042
🏁 Script executed:
Repository: tinify/wordpress-plugin
Length of output: 10307
🏁 Script executed:
Repository: tinify/wordpress-plugin
Length of output: 18033
🏁 Script executed:
Repository: tinify/wordpress-plugin
Length of output: 2592
Handle every
WP_Errorfromcreate_diagnostic_zip()before callingdownload_zip().The error paths
zip_not_available,filesystem_unavailable, andzip_create_failedpass aWP_Errorobject to a method that requires a string path. Add anis_wp_error( $zippath )guard and report the error message.🤖 Prompt for AI Agents