• Resolved Oleg Meglin

    (@omeglin)


    Hello,

    I’m currently testing the Free Version of WP Total Cache. You have built a great plugin there. I’m thinking of trying the pro version soon too.

    One thing that I have noticed so far and that bothers me a lot are two PHP warnings that keep appearing:

    PHP Warning:  Undefined variable $rewrite_rules in /home/users/name/www/www.example.com/public/wp-content/plugins/w3-total-cache/BrowserCache_Environment.php on line 97
    
    PHP Warning:  foreach() argument must be of type array|object, null given in /home/users/name/www/www.example.com/public/wp-content/plugins/w3-total-cache/BrowserCache_Environment.php on line 160

    This Warnings appears on every single page load in the backend while im navigation through the “Performance” settings and also when I delete the cache from the admin bar.

    I’m using the latest WordPress Version and also the latest WP Total Cache Version.

    This is my configuration:

    • Page Cache: enabled (Redis)
    • Minify: enabled (Redis)
      • Mode: Auto
      • HTML Tidy
      • JSMin
      • CSS Tidy
    • Database Cache: enabled (Redis)
    • Object Cache: enabled (Redis)
    • Browser Cache: enabled

    Let me know if you need some more information about my system.

    Many thanks for the support.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @omeglin

    Thank you for reaching out and I am happy to assist you with this.

    Can you please share if you are on apache or Nginx? Also, Can you please share if your filesystem permissions allow writing to files and folders to allow W3TC to add the Browser Cache rules??

    Thanks!

    Thread Starter Oleg Meglin

    (@omeglin)

    Hi Marko,

    thank you for the reply. Here are some more informations:

    • Webserver: Apache 2.4
    • PHP: 8.1.14
    • Using the recommended WordPress file permission: 644 on files and 755 on folders
    Thread Starter Oleg Meglin

    (@omeglin)

    Hi Marko,

    I have to correct one of my given information. PHP 8.0.27 is in use and not 8.1.14.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @omeglin

    Thank you for your feedback.
    Can you please share if the Browser Cache is enabled in the General settings and let me know which settings are enabled in Performance>Browser Cache, and if the W3TC rules are in your .htaccess file?

    Thanks!

    Thread Starter Oleg Meglin

    (@omeglin)

    Hello @vmarko,

    sure.

    Browser Cache is enabled. Here is a screenshot with all Settings:

    I don’t see any W3TC rules inside the .htaccess file.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @omeglin

    Thank you for your feedback. Well this is odd!
    Can the .htaccess should have the W3TC rules for Browser Caching according to your settings?
    Can you please confirm you are checking the .htaccess in your website folder?
    Also, please check the Performance>Install section, which has all the rewrite rules according to your settings.
    You can manually add them to your .htaccess

    Thanks!

    Thread Starter Oleg Meglin

    (@omeglin)

    Hi @vmarko,

    thank you for your commitment.

    Yes, I’m checking the correct .htaccess file. I suspect the rules disappeared because the .htaccess file was accidentally overwritten. So the missing rules shouldn’t be a bug in your plugin.

    However, it would be nice if your plugin catches the errors in such a case and gives you the opportunity to restore the rules.

    When I visit the page you suggested (Performance > Install) I get more errors. One of them is new:

    [07-Mar-2023 08:54:59 UTC] PHP Warning:  Undefined variable $rewrite_rules in /www/www.example.com/public/wp-content/plugins/w3-total-cache/BrowserCache_Environment.php on line 97
    [07-Mar-2023 08:54:59 UTC] PHP Warning:  foreach() argument must be of type array|object, null given in /www/www.example.com/public/wp-content/plugins/w3-total-cache/BrowserCache_Environment.php on line 160
    [07-Mar-2023 08:54:59 UTC] PHP Warning:  Undefined variable $other_areas in /www/www.example.com/public/wp-content/plugins/w3-total-cache/inc/options/common/header.php on line 372
    [07-Mar-2023 08:54:59 UTC] PHP Fatal error:  Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /www/www.example.com/public/wp-content/plugins/w3-total-cache/inc/options/common/header.php:372
    Stack trace:
    #0 /www/www.example.com/public/wp-content/plugins/w3-total-cache/inc/options/common/header.php(372): count()
    #1 /www/www.example.com/public/wp-content/plugins/w3-total-cache/inc/options/install.php(8): require('...')
    #2 /www/www.example.com/public/wp-content/plugins/w3-total-cache/Generic_Page_Install.php(28): include('...')
    #3 /www/www.example.com/public/wp-content/plugins/w3-total-cache/Base_Page_Settings.php(71): W3TC\Generic_Page_Install->view()
    #4 /www/www.example.com/public/wp-content/plugins/w3-total-cache/Root_AdminMenu.php(289): W3TC\Base_Page_Settings->options()
    #5 /www/www.example.com/public/wp-includes/class-wp-hook.php(308): W3TC\Root_AdminMenu->options()
    #6 /www/www.example.com/public/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
    #7 /www/www.example.com/public/wp-includes/plugin.php(517): WP_Hook->do_action()
    #8 /www/www.example.com/public/wp-admin/admin.php(259): do_action()
    #9 {main}
      thrown in /www/www.example.com/public/wp-content/plugins/w3-total-cache/inc/options/common/header.php on line 372

    What I tried to restore the rules:

    1. Deactivate and activate the Plugin. Didn’t help.
    2. Changed various settings to force the plugin to re-modify the .htaccess. Didn’t help.
    3. Run the Setup Guide again. Didn’t help.
    4. Disabled and enabled the Browser Cache to force the plugin to re-modify the .htaccess. Didn’t help.

    Again as a summary to avoid misunderstandings:

    • We are talking about the standard .htaccess file, which is located in the root directory of the WordPress installation.
    • This .htaccess file should have the file permission “644”.
    • This .htaccess file should contain a few rules created by your plugin.

    Are these statements correct?

    Is there a way to force the plugin to create the rules?

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @omeglin

    Thank you for your feedback.

    The .htaccess should be in the folder of your website. Meaning in the wordpress installation /yourwebstite.com/.htaccess

    It should contain rewrite rules depending on the configuration BEGIN W3TC Browser Cache

    Let me make tests and check for those errors/warnings since I was not able to replicate this.

    Sharing the website URL and where the website is hosted would be helpful.

    Thanks!

    Thread Starter Oleg Meglin

    (@omeglin)

    Hi @vmarko,

    I tried to replicate the errors on a fresh installed WordPress system. I installed a few of the Plugins that are also installed on the system with the errors. However, only a few plugins that I considered critical (like Really Simple SSL Pro and Siteground Security). I couldn’t replicate the errors either.

    Unfortunately, I cannot make the link to the affected page public. I’m also running out of time to do more research on this issue. So I would leave it alone for now.

    There could be so many causes. The system is also a bit more complicated:

    • The system is a bit old (built in 2016).
    • The theme does not support Gutenberg (Classic Editor mode enabled).
    • It used to be a multisite and has been converted to a single site.
    • There are 33 plugins installed.

    If I ever find the cause of the error, I’ll let you know. Thank you again for your commitment.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @omeglin

    Thank you for your feedback.

    So it’s something specific to the environment and other plugins. I understand that sharing more specific information is not possible.

    Please drop us a note directly via the plugin in Performance>Support>Bug report if you want to explore this further and share more details.

    Thanks again!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Multiple PHP Warnings’ is closed to new replies.