-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Plugins: Fix wp_edit_theme_plugin_file() to detect network-active plugins #13620
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: trunk
Are you sure you want to change the base?
Changes from all commits
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -463,4 +463,49 @@ function () { | |||||
| '.tmp', | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * @ticket 66129 | ||||||
| * @group multisite | ||||||
| * @group ms-required | ||||||
| */ | ||||||
| public function test_wp_edit_theme_plugin_file_runs_loopback_check_for_network_active_plugin() { | ||||||
| $user_id = self::factory()->user->create(); | ||||||
| grant_super_admin( $user_id ); | ||||||
| wp_set_current_user( $user_id ); | ||||||
|
|
||||||
| $plugin = 'hello.php'; | ||||||
| activate_plugin( $plugin, '', true ); | ||||||
|
|
||||||
| $loopback_requested = false; | ||||||
| add_filter( | ||||||
| 'pre_http_request', | ||||||
| function ( $preempt, $parsed_args, $url ) use ( &$loopback_requested ) { | ||||||
|
Member
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.
Suggested change
|
||||||
| if ( str_contains( $url, 'wp_scrape_key' ) ) { | ||||||
| $loopback_requested = true; | ||||||
| return array( | ||||||
| 'body' => '', | ||||||
| 'response' => array( 'code' => 200 ), | ||||||
| ); | ||||||
| } | ||||||
| return $preempt; | ||||||
| }, | ||||||
| 10, | ||||||
| 3 | ||||||
| ); | ||||||
|
|
||||||
| wp_edit_theme_plugin_file( | ||||||
| array( | ||||||
| 'plugin' => $plugin, | ||||||
| 'file' => $plugin, | ||||||
| 'newcontent' => file_get_contents( WP_PLUGIN_DIR . '/' . $plugin ), | ||||||
| 'nonce' => wp_create_nonce( 'edit-plugin_' . $plugin ), | ||||||
| ) | ||||||
| ); | ||||||
|
Comment on lines
+497
to
+504
Member
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. Shouldn't this assert that the return value is |
||||||
|
|
||||||
| deactivate_plugins( $plugin ); | ||||||
| revoke_super_admin( $user_id ); | ||||||
|
|
||||||
|
Comment on lines
+506
to
+508
Member
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. These shouldn't be needed. The they are automatically cleaned up.
Suggested change
|
||||||
| $this->assertTrue( $loopback_requested, 'Editing a network-active plugin file should trigger the fatal-error loopback check.' ); | ||||||
| } | ||||||
| } | ||||||
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.