Use of undefined constant FS_CHMOD_DIR – assumed ‘FS_CHMOD_DIR’

It’s really quite simple. The theme author is using a constant that you can put in wp-config.php, but because you don’t use that constant, and the author never checks if it’s actually defined, the code throws a PHP warning

https://codex.wordpress.org/Editing_wp-config.php#Override_of_default_file_permissions

Override of default file permissions

The FS_CHMOD_DIR and
FS_CHMOD_FILE define statements allow override of default file
permissions. These two variables were developed in response to the
problem of the core update function failing with hosts running under
suexec. If a host uses restrictive file permissions (e.g. 400) for all
user files, and refuses to access files which have group or world
permissions set, these definitions could solve the problem. Note that
the ‘0755’ is an octal value. Octal values must be prefixed with a 0
and are not delineated with single quotes (‘). See Also: Changing File
Permissions

FAQ

So Who’s to Blame?

The theme author for not checking if a constant is defined before using it. I’ve never needed this constant and i’ve worked on a lot of sites, and from the sounds of it neither have you.

The check is an easy thing to do:

$chmod_dir = ( 0755 & ~ umask() );
if ( defined( 'FS_CHMOD_DIR' ) ) {
    $chmod_dir = FS_CHMOD_DIR;
}

You use a variable, give it a default variable, then assign the constant to it if it exists.

What about this file PHP extension?

It’s BS, a red herring, my guess is you’ve either been fobbed off, or the developer has made a guess, probably the latter. The constant is a WordPress constant, and you should never rely on all constants being defined ( they’re mostly optional after all )

Is all of this above board?

Why would your theme need the chmod files and folders? This all sounds very suspicious, themes shouldn’t be writing to the disk, especially on the frontend. That’s how sites fail to scale or slow down.

I would cast a sceptical eye on the theme, it sounds from the file name like the theme is generating files and saving them in a subfolder, a massive no no, afterall there’s a set of APIs for writing to the uploads folder, and you can generate and return a cacheable CSS file via PHP and rewrite rules ( there are security consequences too if you have a writable theme folder )

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)