Support » Plugin: Rank Math SEO - Best SEO Plugin for WordPress » PHP Notice: Constant FS_METHOD already defined in wp-config.php

  • Resolved aziad


    Hello Rank Math developers.

    After install plugin, my error log file fills by php notices:
    PHP Notice: Constant FS_METHOD already defined in wp-config.php

    I’ve read same topics:

    Here’s what I found out:
    1) WP_DEBUG constant is set to FALSE and FS_METHOD to ‘direct’ on my site (wp-config.php)
    2) I used the linux utility “ack” to find “FS_METHOD” text in all php files in directories “/public/wp-content/plugins” and “/public/wp-content/themes/trestoo”. It found only one file “public/wp-content/plugins/seo-by-rank-math/vendor/mythemeshop/wordpress-helpers/src/helpers/class-wordpress.php”

    [user@server plugins]# ack --php 'FS_METHOD'
    74:             if ( ! defined( 'FS_METHOD' ) ) {
    75:                     define( 'FS_METHOD', 'direct' );

    3) I understand that this code checks if a constant is defined and then set it to ‘direct’. But when I comment 75 row, php notices are gone.

    How can I get rid of these notifications?
    I use last version of WP, PHP 7.3.27.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter aziad


    My additional reflections:
    Is it possible that 75 line “define( ‘FS_METHOD’, ‘direct’ )” rewrites GBOBAL constant FS_METHOD and set it as LOCAL in function’s scope “public static function get_filesystem()” in “class-wordpress.php”? So when this function ends, FS_METHOD constant no longer exists.

    • This reply was modified 1 month, 3 weeks ago by aziad.
    Thread Starter aziad


    Could I know what about my problem?

    Plugin Author Rank Math


    Hello @aziad

    Thank you for contacting the support and sorry for not following up quickly and any inconvenience that might have been caused due to that.

    What you stated in your first post is correct: the code is supposed to check if a constant is defined and if it is not, then it sets it to direct. Something about this fails on your site, and it tries to re-define the constant, which is not allowed by PHP, that is what’s causing the error.

    We will investigate the issue and possibly fix it in a future update. Until then, we recommend deleting one of the two instances of the define( ‘FS_METHOD’, ‘direct’ ) code, either the one in your wp-config.php file, or the one in Rank Math.

    Hope that helps.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.