rtCamp / nginx-helper

Nginx Helper for WordPress caching, permalinks & efficient file handling in multisite
https://wordpress.org/plugins/nginx-helper/
224 stars 117 forks source link

"Save All Changes" button missing #265

Open HandyGadget opened 2 years ago

HandyGadget commented 2 years ago

With only two plugins installed and activated there is no blue button to save changes.

[Operating System] Description: Ubuntu 20.04.4 LTS

[NGINX] Branch: mainline Version: 1.20.2

[PHP] Info: PHP 8.0.16 (cli) (built: Feb 21 2022 14:42:00) ( NTS )

arafatkn commented 2 years ago

Hello @HandyGadget , Thanks for sharing the issue with us.

As i have checked in PHP 8.0 and WP 5.8, in Nginx Helper settings page, there is a blue button showing "Save All Changes". Please check the plugin's settings page again.

Can you please share more details? i.e. screenshot or video or related error_log so that the issue can be identified.

asule-star commented 1 year ago

I actually encountered this issue recently using php 8.1. Also tested on php 7.4 and this doesn't happen.

On further investigation, I noticed the issue could be fixed by setting the "$recursive" parameter to true to ensure all directories are created in the path.

Code path location: /nginx-helper/admin/partials/nginx-helper-general-options.php

Code line causing issue (line: 630) if ( ! is_dir( $log_path ) ) { mkdir( $log_path ); // error happens here }

Code with proposed fix (line: 630) if ( ! is_dir( $log_path ) ) { mkdir( $log_path,0777,true ); // setting $recursive to true fixes the issue }

danish17 commented 1 year ago

@HandyGadget : Upon analyzing the code, this issue may happen if the directories are non-existent and the code preceding /nginx-helper/admin/partials/nginx-helper-general-options.php#630 throws a fatal error OR submit_button() fails for some reason.

As we do not have the screenshot available, or the details pertaining to the environment, the true cause of the problem could not be ascertained.

Regarding the proposed fix

@asule-star: If ( ! is_dir( $log_path ) ) { mkdir( $log_path ); fails to create the directory, it will throw a warning instead of a fatal error, i.e., the code execution will not stop. Even if it does, something like this will happen:

image

# Warning if #630 fails to create the directory:
Warning: mkdir(): No such file or directory in /app/wordpress/wp-content/plugins/nginx-helper/admin/partials/nginx-helper-general-options.php on line 630
Can't write on log file.

Check you have write permission on /app/wordpress/wp-content/uploads/nginx-helper/nginx.log

The issue reported was for missing button, not the whole section. Is that correct? @HandyGadget @asule-star

I would request you to kindly share the screenshot and the server environment being used. If possible, please share the error log as well.

Tested on:

Server architecture: Linux 5.15.0-58-generic x86_64
Web server: nginx/1.17.10
PHP version: 8.1.14 (Supports 64bit values) (also on: PHP 7.4, 8.0)
PHP SAPI: fpm-fcgi
Version: 6.1.1