• Resolved abdullahthinkun

    (@abdullahthinkun)


    We have a few sites on the same server using the plugin version 4.4.4. Recently, some of them have this error at the top of all pages, which also breaks /wp-admin/.

    Warning: fopen(/tmp/tribe_tmp_file_logger_2017-04-05.log): failed to open stream: Permission denied in /home/[redacted]/public_html/wp-content/plugins/the-events-calendar/common/src/Tribe/Log/File_Logger.php on line 68
    
    Warning: fopen(/tmp/tribe_tmp_file_logger_2017-04-05.log): failed to open stream: Permission denied in /home/[redacted]/public_html/wp-content/plugins/the-events-calendar/common/src/Tribe/Log/File_Logger.php on line 68
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/[redacted]/public_html/wp-content/plugins/the-events-calendar/common/src/Tribe/Log/File_Logger.php:68) in /home/[redacted]/public_html/wp-includes/pluggable.php on line 1179

    The problem is arising because two sites (2 different shell users) are attempting to open the same log file. The weird part is that the log files are all empty (0 bytes) and only certain sites on certain days decide to create a log file and open it. There also doesn’t seem to be a way to disable the creation of these files. I think if they are going to be created in /tmp maybe they should have the site name or user name or something in the filename otherwise these conflicts will arise.

    Is this intended behaviour or are our sites functioning differently due to other server settings?

    ls -al /tmp:

    
    -rw-r--r--  1 xxxxxxxx         xxxxxxxx                0 Dec 19 21:35 tribe_tmp_file_logger_2016-12-19.log
    -rw-r--r--  1 xxxxxxxxxx       xxxxxxxxxx              0 Jan 18 17:31 tribe_tmp_file_logger_2017-01-18.log
    -rw-r--r--  1 xxxxxxxx         xxxxxxxx                0 Apr  3 17:54 tribe_tmp_file_logger_2017-04-03.log
    -rw-r--r--  1 xxxxxxxx         xxxxxxxx                0 Apr  4 10:15 tribe_tmp_file_logger_2017-04-04.log
    -rwxrwxrwx  1 xxxxxxxx         xxxxxxxx                0 Apr  5 10:09 tribe_tmp_file_logger_2017-04-05.log*
    
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter abdullahthinkun

    (@abdullahthinkun)

    I found a kinda related issue online: https://theeventscalendar.com/support/forums/topic/warning-file_exists-open_basedir-restriction-in-effect-2/ which said to add a filter for “tribe_file_logger_directory”. I tried adding filters for several of the filtered strings in ‘File_Logger.php’ with no luck because the logging action is executed before functions.php.

    Thread Starter abdullahthinkun

    (@abdullahthinkun)

    I’ve implemented a workaround for now on the sites experiencing the issue. functions.php:

    
    if (class_exists('Tribe__Log__File_Logger')) {
    	class New_Tribe__Log__File_Logger extends Tribe__Log__File_Logger {
    		public function get_log_file_name() {
    			return parent::get_log_file_name();
    		}
    	};
    	$newtribelogger = new New_Tribe__Log__File_Logger();
    	$tribelogfile = $newtribelogger->get_log_file_name();
    	if (getmyuid() == fileowner($tribelogfile)) {
    		chmod($tribelogfile, 0777);
    	}
    	unset($newtribelogger); unset($tribelogfile);
    }
    

    As you can see it isn’t even easy to get the log file name from the plugin since that function is protected. My script has to try retrieve the current log filename, check if the current user owns it, and then make it world readable/writable so that the other sites don’t throw an error.

    Barry

    (@barryhughes-1)

    Hi @abdullahthinkun,

    Thanks for your patience.

    If you don’t need or want logging, you can disable it via the settings in the Events → Help screen. On the other hand:

    I tried adding filters for several of the filtered strings in ‘File_Logger.php’ with no luck because the logging action is executed before functions.php.

    Using a theme’s functions.php file isn’t always ideal for exactly this sort of reason. How about using a mu-plugin (or regular plugin) for this instead?

    Thread Starter abdullahthinkun

    (@abdullahthinkun)

    Thanks for your reply. I wasn’t aware of the Events → Help screen. I’ve look at it now and it reports that logging is already disabled on both of the offending sites, which is very odd.

    I will try the plugin method.

    Barry

    (@barryhughes-1)

    OK – hopefully that works for you. If not or if you find this is still a problem, I’d love to know what the trigger for this issue might be (ie if it occurs when you try to perform a certain function on a certain admin screen, or something like that).

    Hey there! This thread has been inactive for a while so we’re going to go ahead and mark it Resolved. Please feel free to open a new thread if any other questions come up and we’d be happy to help. ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Warning: fopen(/tmp/tribe_tmp_file_logger_2017-04-05.log): failed to open stream’ is closed to new replies.