Make WordPress Core

Opened 5 weeks ago

Closed 5 weeks ago

#65209 closed defect (bug) (fixed)

Connectors: Expose isFileModDisabled flag to connector script module data.

Reported by: jorgefilipecosta's profile jorgefilipecosta Owned by: wildworks's profile wildworks
Milestone: 7.0 Priority: normal
Severity: normal Version: 7.0
Component: General Keywords: has-patch dev-reviewed gutenberg-merge
Focuses: Cc:

Description

Backports PR https://github.com/WordPress/gutenberg/pull/77521.
Makes an enhacement so the connectors screen say if the website has disallowed file modifications.

The connectors admin screen needs to know whether file modifications are permitted (e.g. when DISALLOW_FILE_MODS is set, when the filesystem is not writable, or when the file_mod_allowed filter denies it) so the UI can adapt accordingly — for example, surfacing the appropriate messaging or disabling plugin-install affordances when those operations are not allowed.

Proposed change

Expose a new isFileModDisabled boolean on the connectors script module data, derived from wp_is_file_mod_allowed( 'install_plugins' ):

<?php
$data['isFileModDisabled'] = ! wp_is_file_mod_allowed( 'install_plugins' );

Testing

  1. Load the connectors admin screen and inspect the script module data payload — isFileModDisabled should be present and false on a standard install.
  2. Add define( 'DISALLOW_FILE_MODS', true ); to wp-config.php and reload — isFileModDisabled should now be true.
  3. Confirm the value also flips when a filter denies the install_plugins context, e.g.:
    <?php
    add_filter( 'file_mod_allowed', function ( $allowed, $context ) {
        return 'install_plugins' === $context ? false : $allowed;
    }, 10, 2 );
    

Patch

GitHub PR: [https://github.com/WordPress/wordpress-develop/pull/11779

Change History (8)

This ticket was mentioned in PR #11779 on WordPress/wordpress-develop by @jorgefilipecosta.


5 weeks ago
#1

  • Keywords has-patch added

## Summary

  • Adds isFileModsDisabled (derived from wp_is_file_mod_allowed( 'install_plugins' )) to the data exposed through the script_module_data_options-connectors-wp-admin filter so the connectors UI can react when plugin installs are disabled.

Ticket: https://core.trac.wordpress.org/ticket/65209

## Test plan

  • [ ] Load the connectors admin screen and verify isFileModsDisabled is present on the script module data with the expected value.
  • [ ] Toggle file mods off (e.g. define( 'DISALLOW_FILE_MODS', true )) and confirm the value flips to true.

@jorgefilipecosta commented on PR #11779:


5 weeks ago
#2

@jorgefilipecosta is there a trac ticket for this / is this targeted for 7.0?

Hi @jeffpaul, yes it will go with 7.0 it is a backport of https://github.com/WordPress/gutenberg/pull/77521. Ticket is available at https://core.trac.wordpress.org/ticket/65209.

@jorgefilipecosta commented on PR #11779:


5 weeks ago
#3

cc: @t-hamano, @westonruter as reviewers of https://github.com/WordPress/gutenberg/pull/77521 would you be able to review / sign this one. Thank you in advance.

@jorgefilipecosta commented on PR #11779:


5 weeks ago
#4

Thank you @westonruter!

#5 @jorgefilipecosta
5 weeks ago

In 62341:

Connectors: Expose isFileModDisabled flag to connector script module data.

Adds an isFileModDisabled boolean — derived from wp_is_file_mod_allowed( 'install_plugins' ) — to the data exposed via the script_module_data_options-connectors-wp-admin filter, so the connectors UI can adapt when file modifications are disabled.

Props jorgefilipecosta, westonruter, jeffpaul.
See #65209.

@wildworks commented on PR #11779:


5 weeks ago
#6

This was commited in r62341.

#7 @wildworks
5 weeks ago

  • Keywords dev-reviewed gutenberg-merge added

r62341 looks good to be backported to 7.0.

#8 @wildworks
5 weeks ago

  • Owner set to wildworks
  • Resolution set to fixed
  • Status changed from new to closed

In 62350:

Connectors: Expose isFileModDisabled flag to connector script module data.

Adds an isFileModDisabled boolean — derived from wp_is_file_mod_allowed( 'install_plugins' ) — to the data exposed via the script_module_data_options-connectors-wp-admin filter, so the connectors UI can adapt when file modifications are disabled.

Reviewed by wildworks.
Merges [62341] to the 7.0 branch.

Props jorgefilipecosta, westonruter, jeffpaul.
Fixes #65209.

Note: See TracTickets for help on using tickets.