This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 5 replies, has 3 voices.

Last updated by gaborN-2 1 month, 3 weeks ago.

Assigned support staff: Bobby.

Author Posts
August 19, 2019 at 9:09 pm #4419203

jeffreyF-2

brand new install with default theme and I'm getting these warnings when I edit a page:

Use of undefined constant FS_CHMOD_DIR - assumed 'FS_CHMOD_DIR' (this will throw an Error in a future version of PHP) in /var/www/fr/wpml-test/wp-admin/includes/class-wp-filesystem-direct.php on line 504

deactivating your string translation plugin makes the warnings go away. reactivating brings them back. they seem to be firing before each of your inline JS in the head.

to fix you just need to replace FS_CHMOD_DIR with 'FS_CHMOD_DIR'

August 19, 2019 at 11:00 pm #4419467

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

The notice is not quite pointing to WPML or WPML String Translation.

As far as i am aware of we are not using FS_CHMOD_DIR or FS_CHMOD_FILE in our plugins

There is a possibility your 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

(ex. defining FS_CHMOD_DIR in your wp-config.php should resolve the warning)

https://wordpress.org/support/article/editing-wp-config-php/#override-of-default-file-permissions

The FS_CHMOD_DIR and FS_CHMOD_FILE define statements allow override of default file permissions.

what are your results if you define FS_CHMOD_DIR in your wp_config.php ?

August 20, 2019 at 2:02 pm #4424291

jeffreyF-2

I have tried other themes as well twentysixteen, twentyseventeen and a clients theme. all show the same warnings every time JS is printed in the footer like this:

<b>Warning</b>: Use of undefined constant FS_CHMOD_DIR - assumed 'FS_CHMOD_DIR' (this will throw an Error in a future version of PHP) in <b>/var/www/fr/wpml-test/wp-admin/includes/class-wp-filesystem-direct.php</b> on line <b>504</b><br />
<script type='text/javascript'>
( function( domain, translations ) {
var localeData = translations.locale_data[ domain ] || translations.locale_data.messages;
localeData[""].domain = domain;
wp.i18n.setLocaleData( localeData, domain );
} )( "default", { "locale_data": { "messages": { "": {} } } } );
</script>

I know that the error is being thrown on a core file but again deactivating the string translation plugin fixes the issue. if you're setup to show warnings you should be seeing these.

all that being said adding:

define( 'FS_CHMOD_DIR', ( 0755 & ~ umask() ) );
define( 'FS_CHMOD_FILE', ( 0644 & ~ umask() ) );

to wp-config does silence the warning.

August 20, 2019 at 6:31 pm #4425995

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

On a staging environment i am not able to reproduce the warnings with both error logging activated and WP_DEBUG_DISPLAY on

if resolving this with the solution provided above through wp-config.php is acceptable then we can mark this ticket as resolved but if you would like me to take a closer look at this then as you have already test the theme i would say the next step would be to test your installation on a different server.

you could provide me with a duplicator package(using the duplicator plugin) to install on both my local environment and staging environment on cloudways to see if this is related to your hosting environment or any other 3rd party plugin.

August 23, 2019 at 5:46 pm #4449231

jeffreyF-2

My issue is resolved now. Thank you!

August 29, 2019 at 10:46 am #4480301

gaborN-2

We had the same issue, here is a backtrace at that line:

#0  WP_Filesystem_Direct->mkdir(/var/www/project_directory/public/wp-content/languages/wpml) called at [/var/www/project_directory/public/wp-content/plugins/wpml-string-translation/classes/jed-translations/wpml-st-jed-file-manager.php:89]
#1  WPML_ST_JED_File_Manager->maybe_create_subdir() called at [/var/www/project_directory/public/wp-content/plugins/wpml-string-translation/classes/jed-translations/wpml-st-jed-file-manager.php:41]
#2  WPML_ST_JED_File_Manager->add(default-wp-components, en_US) called at [/var/www/project_directory/public/wp-content/plugins/wpml-string-translation/classes/jed-translations/wpml-st-script-translations-hooks.php:52]
#3  WPML_ST_Script_Translations_Hooks->override_jed_file(, wp-components, default-wp-components) called at [/var/www/project_directory/public/wp-includes/class-wp-hook.php:286]
#4  WP_Hook->apply_filters(, Array ([0] => ,[1] => wp-components,[2] => default)) called at [/var/www/project_directory/public/wp-includes/plugin.php:208]
#5  apply_filters(load_script_translation_file, , wp-components, default) called at [/var/www/project_directory/public/wp-includes/l10n.php:1047]
#6  load_script_translations(, wp-components, default) called at [/var/www/project_directory/public/wp-includes/l10n.php:1006]
#7  load_script_textdomain(wp-components, default, ) called at [/var/www/project_directory/public/wp-includes/class.wp-scripts.php:542]
#8  WP_Scripts->print_translations(wp-components, ) called at [/var/www/project_directory/public/wp-includes/class.wp-scripts.php:333]
#9  WP_Scripts->do_item(wp-components, 0) called at [/var/www/project_directory/public/wp-includes/class.wp-dependencies.php:106]
#10 WP_Dependencies->do_items(Array ([0] => jquery,[1] => thickbox,[2] => installer-dismiss-nag,[3] => common,[4] => admin-bar,[5] => autosave,[6] => admin-comments,[7] => post,[8] => editor-expand,[9] => media-editor,[10] => media-audiovideo,[11] => mce-view,[12] => image-edit,[13] => utils,[14] => svg-painter,[15] => sitepress-post-edit-tags,[16] => sitepress-scripts,[17] => wp-auth-check,[18] => sitepress,[19] => otgs-notices,[20] => wpml-meta-box,[21] => owl-carousel-js,[22] => wpml-st-db-troubleshooting,[23] => wpml-tm-scripts,[24] => wpml-tm-post-edit-alert,[25] => wpml-post-edit-tm-mode,[26] => wpml-theme-plugin-localization-scan,[27] => wpml-enable-fastest-settings,[28] => wpml-st-tracking-all-strings-as-english-notice,[29] => yoast-seo-admin-global-script,[30] => yoast-seo-metabox,[31] => yoast-seo-help-center,[32] => yoast-seo-admin-media,[33] => yoast-seo-post-scraper,[34] => yoast-seo-replacevar-plugin,[35] => yoast-seo-shortcode-plugin,[36] => yoast-seo-featured-image,[37] => icl-admin-notifier,[38] => otgs-installer-components-save-setting,[39] => wpml-end-user,[40] => wpml-requirements-plugins-activation,[41] => json2,[42] => fl-builder-admin-posts,[43] => acf-input,[44] => acf-pro-input,[45] => select2,[46] => jquery-ui-datepicker,[47] => acf-timepicker,[48] => wp-color-picker,[49] => sitepress-post-edit), 0) called at [/var/www/project_directory/public/wp-includes/class.wp-scripts.php:601]
#11 WP_Scripts->do_head_items() called at [/var/www/project_directory/public/wp-includes/script-loader.php:2309]
#12 print_head_scripts() called at [/var/www/project_directory/public/wp-includes/class-wp-hook.php:286]
#13 WP_Hook->apply_filters(, Array ([0] => )) called at [/var/www/project_directory/public/wp-includes/class-wp-hook.php:310]
#14 WP_Hook->do_action(Array ([0] => )) called at [/var/www/project_directory/public/wp-includes/plugin.php:465]
#15 do_action(admin_print_scripts) called at [/var/www/project_directory/public/wp-admin/admin-header.php:127]
#16 require_once(/var/www/project_directory/public/wp-admin/admin-header.php) called at [/var/www/project_directory/public/wp-admin/edit-form-advanced.php:389]
#17 include(/var/www/project_directory/public/wp-admin/edit-form-advanced.php) called at [/var/www/project_directory/public/wp-admin/post.php:197]
<br />
<b>Warning</b>:  Use of undefined constant FS_CHMOD_DIR - assumed 'FS_CHMOD_DIR' (this will throw an Error in a future version of PHP) in <b>/var/www/project_directory/public/wp-admin/includes/class-wp-filesystem-direct.php</b> on line <b>410</b><br />

The languages folder was not present in the wp-content folder.
I created it with write permission, then some refresh removed the warning message.
Then the wpml directory was created in the languages folder.