DISALLOW_FILE_EDIT is false but I still am not able to edit files from the admin interface and the menus do not show up

Question

I have checked the constant DISALLOW_FILE_EDIT and it’s set to false.

I am using Trellis to setup my sites, and it is working correctly on my actually staging server VPS. But on the local virtual machine it’s not working.

Looking for help in how I can debug this, what source file or WP to check … I assume this has something with the NFS shared folders mechanic the files are shared across the host OS and guest VM.

Host OS is Ubuntu 22.04 and guest is Ubuntu 20.04. I went into the VM and ran sudo chmod 777 -Rv /srv/ but trellis already takes care of permissions, so I was not really expecting this to work, and it did not. I have tested that PHP can create files with this code:

function logfile( string $name, $var, string $file ) {
    $msg = $name . var_export( $var, true ) . PHP_EOL; //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
    error_log( $msg . PHP_EOL, 3, "$file.log" ); //phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
}

logfile( 'nn', 'vr', __FILE__ ); 

It can create and write to a log file inside my mu-plugins folder and probably everywhere else in the WP installation. But it seems WP makes some checks on being able to write files that fail.

I found some code in the Gutenberg patch I like to try out.

    /**
     * Checks whether the user has permission to edit themes. In classic themes
     * this controls access to Appearance > Theme Editor to edit theme files.
     * In block themes editing theme files via the visual editor is similar.
     *
     * @return WP_Error|bool True if the request has access, or WP_Error object.
     */
    public function permissions_check() {
        if ( current_user_can( 'edit_themes' ) ) {
            return true;
        }

        return new WP_Error(
            'rest_cannot_edit_theme',
            __( 'Sorry, you are not allowed to edit theme templates and template parts.', 'gutenberg' ),
            array( 'status' => rest_authorization_required_code() )
        );
    }

This message is triggered for me so it seems my user does not have the permission ot edit themes. But I do not get why, its the default admin user that is created by Trellis.

0
NextGenThemes 2 months 2022-05-09T22:16:09-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse