Prosites - PHP notices in the WP admin

We are periodically seeing these PHP notices in the WP admin - refreshing the page will generally make it go away but they come back after a few page refreshes.

Notice</b>: session_start(): ps_files_cleanup_dir: opendir(C:\Windows\TEMP) failed: No such file or directory (2) in <b>D:\...\plugins\pro-sites\pro-sites-files\lib\ProSites\Helper\Session.php</b> on line <b>29</b>

Also, when accessing the theme customizer this notice shows at the top of the theme preview.

Notice: Undefined index: theme in D:\...\plugins\pro-sites\pro-sites-files\modules\premium-themes.php on line 375

It's not theme specific -- it happens even with the default twenty fifteen theme. I've tried disabling other plugins to see if that made a difference but no joy.

Can you advise on how we can clear these? I'm aware that disabling debug will cause them to go away but I can't do that in my development environment as it stops me from seeing other issues.

thanks,
CC

  • Adam Czajczyk

    Hey CC,

    I hope you're well today and thank you for your question!

    Turning debugging OFF would not solve the issue but only suppress warning notices, which is actually an acceptable way of dealing with this in a production environment as otherwise you'd have to alter the default session_handling/"garbage collection" settings of php.

    However, in a development environment disabling debugging surely isn't an option. Judging upon the file path I guess you're running server such as WAMP or similar under Windows. The solution here would be to edit your php configuration.

    To do this, please locate your "php.ini" file and open it with "clean text" editor such as Notepad++ or similar (or within your dev IDE like Eclipse etc) and find this line:

    session.gc_divisor=1

    Change the value of "1" to "0" (if it's already a "0" then change it to "1"), save the file and restart your server.

    Also, when accessing the theme customizer this notice shows at the top of the theme preview.

    This is again the matter of PHP settings. In PHP there's no need to declare variables prior to using them but it's highly recommended. In this case the line 375 of the file indicated in error notice is

    $theme = wp_get_theme( $_REQUEST['theme'] );

    The "Undefined index: theme" means that the "theme" key of the REQUEST array (either POST or GET) wasn't declared before. Usually this is not an issue on most production servers, however sometimes strict php settings result in this error. There are a few ways of dealing with it but we have to eliminate those that involve changing plugins code, thus the the option below would be the way to go:

    - open your php.ini file for editing again
    - locate line starting with "error_reporting"
    - change it to: error_reporting(E_ALL ^ E_NOTICE);

    I hope that helps!

    Cheers,
    Adam

  • fireflyinteractive

    Thanks for the response - Changing the error reporting, however, affects development also as it prevents us seeing issues with our own code.

    Perhaps this would be a better solution?

    $theme = isset($_REQUEST['theme']) ? wp_get_theme( $_REQUEST['theme'] ) : NULL;

    You note that it's necessary to rule out any changes to the plugin -- just to clarify - is this something that will be fixed in the next release or will we need to keep patching it at our end?

  • Predrag Dubajic

    Hi @fireflyinteractive,

    I would be happy to report this to plugin developer even though I'm not able to replicate it on my installation, which is leading me to believe that notices should be gone if you go through Pro Sites settings and just save settings on each page.

    Before trying that could you attach some screenshots of the errors so we can give as much info possible to our developer?

    Let me ping @Adam Czajczyk in here to advise you on the code above :slight_smile:

    Best regards,
    Predrag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.