bmlt-enabled / bread

BMLT Meeting List Generator Plugin For Wordpress https://wordpress.org/plugins/bread/
https://wordpress.org/plugins/bread/
GNU General Public License v2.0
6 stars 9 forks source link

Unlink Errors #164

Closed erleichdaarchiving closed 2 years ago

erleichdaarchiving commented 3 years ago

Hello,

We are getting the following errors, they only started with the 2.5.8 update and continue in the 2.6.0 update. This is happening on all installs of bread on main and subdomain WordPress installs. All have their cache set to 0.

Is there something we need to do on our side to fix?

Thank you

Warning: unlink(/tmp/ebayomatic_0_1): Operation not permitted in /home4/eparnaws/public_html/wp-content/plugins/bread/mpdf/vendor/mpdf/mpdf/src/Cache.php on line 97
Warning: unlink(/tmp/phpcsOJ7Eh5): Operation not permitted in /home4/eparnaws/public_html/wp-content/plugins/bread/mpdf/vendor/mpdf/mpdf/src/Cache.php on line 97
Warning: unlink(/tmp/ebayomatic_0_0): Operation not permitted in /home4/eparnaws/public_html/wp-content/plugins/bread/mpdf/vendor/mpdf/mpdf/src/Cache.php on line 97
Warning: unlink(/tmp/phpcsvHktEi): Operation not permitted in /home4/eparnaws/public_html/wp-content/plugins/bread/mpdf/vendor/mpdf/mpdf/src/Cache.php on line 97
Fatal error: Uncaught Mpdf\MpdfException: Data has already been sent to output (/home4/eparnaws/public_html/wp-content/plugins/bread/mpdf/vendor/mpdf/mpdf/src/Cache.php at line 97), unable to output PDF file in /home4/eparnaws/public_html/wp-content/plugins/bread/mpdf/vendor/mpdf/mpdf/src/Mpdf.php:9512 Stack trace: #0 /home4/eparnaws/public_html/wp-content/plugins/bread/bmlt-meeting-list.php(1131): Mpdf\Mpdf->Output('meetinglist_1_3...', 'I') #1 /home4/eparnaws/public_html/wp-includes/class-wp-hook.php(292): Bread->bmlt_meeting_list('') #2 /home4/eparnaws/public_html/wp-includes/class-wp-hook.php(316): WP_Hook->apply_filters(NULL, Array) #3 /home4/eparnaws/public_html/wp-includes/plugin.php(484): WP_Hook->do_action(Array) #4 /home4/eparnaws/public_html/wp-settings.php(423): do_action('plugins_loaded') #5 /home4/eparnaws/public_html/wp-config.php(89): require_once('/home4/eparnaws...') #6 /home4/eparnaws/public_html/wp-load.php(37): require_once('/home4/eparnaws...') #7 /home4/eparnaws/public_html/wp-blog-header.php(13): r in /home4/eparnaws/public_html/wp-content/plugins/bread/mpdf/vendor/mpdf/mpdf/src/Mpdf.php on line 9512
otrok7 commented 3 years ago

I think you have a few problems here. The "unlink" error is caused by Wordpress not having sufficient permissions on the /tmp directory. Depending on your hosting service, you may not have the ability to set permissions here. In that case, you can alway define a non-default temp directory in your wp-config.php file.

But the system's inability to delete the file is only a warning, and shouldn't be that problematic... do you have define( 'WP_DEBUG', true ); set in your wp-config.php? This would cause these warnings to be sent to the browser, which I guess is causing the fatal error. It is also a major, major security problem. Never have this on in a publically accessible server.

Hope that helps. Let me know either way.

erleichdaarchiving commented 3 years ago

otrok7, thank you for the reply!

I did some digging and ended up finding that the subdomains that threw the error were set to PHP 7.4. I was able to change PHP version setting to use PHP 7.1 and the error disappeared and PDF's begun to appear again. So, I am changing all subdomains for 7.1 for now.

I checked the wp-config.php files on this server, they are all set to define('WP_DEBUG', false);

Thank you for taking the time to respond! Very much appreciated!

otrok7 commented 3 years ago

I am glad you got this working, but I'd still like to know what is/was going on. Sooner or later, someone will have the same problem.

I am assuming that the warnings are being displayed in your browser. Is that right? If so, and if WP_DEBUG is false, then you might have to overwrite some setting in php.ini. Please replace define('WP_DEBUG', false); with ini_set('log_errors','On'); ini_set('display_errors','Off'); ini_set('error_reporting', E_ALL ); define('WP_DEBUG', false); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false);

I'd also be interested in what ls -ld /tmp/ returns, provided you have ssh access.

erleichdaarchiving commented 3 years ago

Our server is not connecting to SSH, it should work not sure why... will try again tomorrow. Thank you for your help, will let you know what we discover asap.

EDIT: PuTTY did not seem to work so just jumped into Ubuntu and SSH worked first try...

# ls -ld /tmp/
drwxrwxrwt 16 root root 4190208 Mar 29 22:06 /tmp//
otrok7 commented 3 years ago

Well, that explains the warning, or rather, the "t" in drwxrwxrwt does. Normally, the tmp directory is writable by all, but with this "sticky bit" set, only the owner of a file can delete it. Since the /tmp directory is share by everyone and everything on your server, you have files there from other processes. MPdf, which does the PDF generation, is trying to clean up after itself by deleting everything in the directory, but can't, so it issues a warning. Bread can avoid this by creating a subdirectory of /tmp, and putting it's temp files there. I will add this in the next release.

But this is only a warning, it should actually just be ignored in production code, or at most, written to your debug log. The real problem is that this warning is being output to your browser, and that of course screws everything up when we are expecting a PDF to be coming out.

Normally, you can turn debugging output to the browser off and on with WP_DEBUG, but that seems to be overridden in your case. My guess is that your php.ini has debugging turned on. This is consistent with things working on 7.1 and not on 7.4, not because the versions are different, but because each would have a different php.ini, and the problem might be only in 7.4. You can try to override off in wp-config, as I described a few comments ago.