Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Sir Osis of Liver on March 02, 2018, 01:02:16 PM

Title: Subs-Post.php server errors
Post by: Sir Osis of Liver on March 02, 2018, 01:02:16 PM
Server is logging these errors in bursts -



[01-Mar-2018 16:00:35 US/Pacific] PHP Notice:  Undefined index: server in  /Sources/Subs-Post.php on line 627
[01-Mar-2018 16:00:35 US/Pacific] PHP Notice:  Undefined index: utf8 in  /Sources/Subs-Post.php on line 1262
[01-Mar-2018 16:00:35 US/Pacific] PHP Notice:  Undefined index: utf8 in  /Sources/Subs-Post.php on line 1264
[01-Mar-2018 16:00:35 US/Pacific] PHP Notice:  Undefined index: server in  /Sources/Subs-Post.php on line 627
[01-Mar-2018 16:00:35 US/Pacific] PHP Notice:  Undefined index: utf8 in  /Sources/Subs-Post.php on line 1262
[01-Mar-2018 16:00:35 US/Pacific] PHP Notice:  Undefined index: utf8 in  /Sources/Subs-Post.php on line 1264
[01-Mar-2018 16:00:35 US/Pacific] PHP Notice:  Undefined index: server in  /Sources/Subs-Post.php on line 627
[01-Mar-2018 16:00:35 US/Pacific] PHP Notice:  Undefined index: utf8 in  /Sources/Subs-Post.php on line 1262
[01-Mar-2018 16:00:35 US/Pacific] PHP Notice:  Undefined index: utf8 in  /Sources/Subs-Post.php on line 1264
[01-Mar-2018 16:02:05 US/Pacific] PHP Notice:  Undefined index: server in  /Sources/Subs.php on line 820
[01-Mar-2018 16:02:05 US/Pacific] PHP Notice:  Undefined index: server in  /Sources/Subs-Post.php on line 627
[01-Mar-2018 16:02:05 US/Pacific] PHP Notice:  Undefined index: character_set in  /Sources/Subs-Post.php on line 1219
[01-Mar-2018 16:02:05 US/Pacific] PHP Notice:  Undefined index: character_set in  /Sources/Subs-Post.php on line 1219
[01-Mar-2018 16:02:05 US/Pacific] PHP Notice:  Undefined index: character_set in  /Sources/Subs-Post.php on line 1219
[01-Mar-2018 16:02:05 US/Pacific] PHP Notice:  Undefined index: utf8 in  /Sources/Subs-Post.php on line 1262
[01-Mar-2018 16:02:05 US/Pacific] PHP Notice:  Undefined index: utf8 in  /Sources/Subs-Post.php on line 1264
[01-Mar-2018 16:02:05 US/Pacific] PHP Notice:  Undefined index: character_set in  /Sources/Subs-Post.php on line 1219



As you can see, they all occurred in a minute and a half, no other errors for past 24 hours.  What can cause this?

Title: Re: Subs-Post.php server errors
Post by: Illori on March 02, 2018, 01:19:50 PM
i dont believe we have ever figured this one out. you can search the forum for other topics related to this.
Title: Re: Subs-Post.php server errors
Post by: GigaWatt on March 02, 2018, 08:17:18 PM
Based on the errors... maybe related to the database character set encoding options ???.... UTF-8 vs. ANSII ???.
Title: Re: Subs-Post.php server errors
Post by: Sir Osis of Liver on March 02, 2018, 10:54:23 PM
I've seen some of these errors on another forum, they don't appear in forum error log, only server log.  Fudged them on the other forum, nothing bad happened -



/// Fix undefined index error
if (!isset ($context['utf8']))
$context['utf8'] = '';


/// Fix undefined index error
if (!isset ($context['server']['is_windows']))
$context['server']['is_windows'] = '';



Think I'll do the same here.  I've downgraded php 7.0.27 -> 5.6.33, will let it run for a while before changing anything, see if errors are reduced.

Title: Re: Subs-Post.php server errors
Post by: richardwbb on March 09, 2018, 03:41:40 PM
Where is that code put Sir Osis of Liver? Would that work within index.php all of SMF?
Title: Re: Subs-Post.php server errors
Post by: Sir Osis of Liver on March 09, 2018, 09:08:53 PM
Subs-Post.php



// Unicode, baby.
$charset = 'UTF-8';
}
}

/// Fix undefined index error
if (!isset ($context['utf8']))
$context['utf8'] = '';

// Convert all special characters to HTML entities...just for Hotmail :-\





// Use sendmail if it's set or if no SMTP server is set.
$use_sendmail = empty($modSettings['mail_type']) || $modSettings['smtp_host'] == '';


/// Fix undefined index error
if (!isset ($context['server']['is_windows']))
$context['server']['is_windows'] = '';

// Line breaks need to be \r\n only in windows or for SMTP.



There are others in other source files that I haven't bothered with.  Errors are not logged in forum error log, and don't seem to cause any problems, but you should be able to use the same hack for any of them.

Title: Re: Subs-Post.php server errors
Post by: shawnb61 on March 10, 2018, 01:00:33 AM
I have seen these same errors - also posted in the unusual error log.  This makes me think they are not app errors, but something posted outside normal app processing (because the smf error handler isn't invoked), e.g., from cron.php or proxy.php (I don't use ssi.php).  But I believe these errors existed before the proxy... So my suspicion is cron.php (or ssi.php) somehow is invoking something without the environment setup...   Haven't nailed it down yet. 
Title: Re: Subs-Post.php server errors
Post by: Illori on March 10, 2018, 06:04:46 AM
Quote from: shawnb61 on March 10, 2018, 01:00:33 AM
So my suspicion is cron.php (or ssi.php) somehow is invoking something without the environment setup...   Haven't nailed it down yet. 

cant be cron.php as SMF 2.0 does not have cron.php.
Title: Re: Subs-Post.php server errors
Post by: Sir Osis of Liver on March 10, 2018, 04:34:38 PM
Odd thing is, the errors occur in bursts.  In the following log, you can see approx. 80 errors with same timestamp.  This was the entire errorlog for approx. 12 hours on a busy forum.  There have been no errors logged in past 18 hours.



[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: is_admin in  /Sources/Security.php on line 824
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: is_admin in  /Sources/Security.php on line 824
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: is_admin in  /Sources/Security.php on line 824
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: is_admin in  /Sources/Security.php on line 824
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: is_guest in  /Sources/Load.php on line 1580
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: mod_cache in  /Sources/Load.php on line 1585
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: username in  /Sources/Load.php on line 1586
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: language in  /Sources/Load.php on line 1587
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: email in  /Sources/Load.php on line 1588
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: ignoreusers in  /Sources/Load.php on line 1589
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: name in  /Sources/Load.php on line 1592
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: smiley_set in  /Sources/Load.php on line 1597
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: smiley_set in  /Sources/Load.php on line 1597
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined variable: _SESSION in  /Sources/Load.php on line 1613
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined variable: _SESSION in  /Sources/Load.php on line 1614
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  array_unshift() expects parameter 1 to be array, null given in  /Sources/Load.php on line 1647
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Use of undefined constant WIRELESS - assumed 'WIRELESS' in  /Sources/Load.php on line 1663
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Use of undefined constant WIRELESS_PROTOCOL - assumed 'WIRELESS_PROTOCOL' in  /Sources/Load.php on line 1665
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: language in  /Sources/Load.php on line 1756
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: time_offset in  /Sources/Subs.php on line 756
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: time_format in  /Sources/Subs.php on line 795
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Use of undefined constant WIRELESS - assumed 'WIRELESS' in  /Sources/Subs.php on line 901
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: avatar in  /Sources/Subs.php on line 3264
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: avatar in  /Sources/Subs.php on line 3267
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: avatar in  /Sources/Subs.php on line 3267
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: avatar in  /Sources/Subs.php on line 3283
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: total_time_logged_in in  /Sources/Subs.php on line 3291
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: total_time_logged_in in  /Sources/Subs.php on line 3292
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: total_time_logged_in in  /Sources/Subs.php on line 3293
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 834
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  array_intersect(): Argument #2 is not an array in  /Sources/Security.php on line 834
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 834
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  array_intersect(): Argument #2 is not an array in  /Sources/Security.php on line 834
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: groups in  /Sources/Subs.php on line 3960
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  implode(): Invalid arguments passed in  /Sources/Subs.php on line 3960
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: language in  /Sources/Subs.php on line 3960
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 834
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  array_intersect(): Argument #2 is not an array in  /Sources/Security.php on line 834
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 834
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  array_intersect(): Argument #2 is not an array in  /Sources/Security.php on line 834
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Notice:  Undefined index: permissions in  /Sources/Security.php on line 831
[09-Mar-2018 13:55:03 US/Pacific] PHP Warning:  in_array() expects parameter 2 to be array, null given in  /Sources/Security.php on line 831
[09-Mar-2018 16:04:39 US/Pacific] PHP Notice:  Undefined index: server in  /Sources/Subs-Post.php on line 627
[09-Mar-2018 16:04:39 US/Pacific] PHP Notice:  Undefined index: server in  /Sources/Subs-Post.php on line 627
[09-Mar-2018 16:04:39 US/Pacific] PHP Notice:  Undefined index: server in  /Sources/Subs-Post.php on line 627


Title: Re: Subs-Post.php server errors
Post by: Aleksi "Lex" Kilpinen on March 11, 2018, 03:24:54 AM
That does sound odd, have you taken a look at what those lines mentioned are actually about?
I mean, there are other files mentioned as well - there must be some connection.
Title: Re: Subs-Post.php server errors
Post by: Sir Osis of Liver on March 11, 2018, 11:29:04 PM
Errors seem to be random.  This is the log for past 24 hours -



[10-Mar-2018 16:00:27 US/Pacific] PHP Notice:  Undefined index: server in  /Sources/Subs-Post.php on line 627
[10-Mar-2018 16:00:27 US/Pacific] PHP Notice:  Undefined index: server in  /Sources/Subs-Post.php on line 627
[10-Mar-2018 16:00:27 US/Pacific] PHP Notice:  Undefined index: server in  /Sources/Subs-Post.php on line 627
[11-Mar-2018 17:00:06 US/Pacific] PHP Notice:  Undefined index: server in  /Sources/Subs-Post.php on line 627
[11-Mar-2018 17:00:06 US/Pacific] PHP Notice:  Undefined index: server in  /Sources/Subs-Post.php on line 627
[11-Mar-2018 17:00:06 US/Pacific] PHP Notice:  Undefined index: server in  /Sources/Subs-Post.php on line 627



It's core code -



// Line breaks need to be \r\n only in windows or for SMTP.
$line_break = $context['server']['is_windows'] || !$use_sendmail ? "\r\n" : "\n";



Best guess it's server related, but no clue what causes the errors.  I've seen it on other forums, never on mine.

Title: Re: Subs-Post.php server errors
Post by: shawnb61 on March 12, 2018, 12:40:06 AM
Doesn't look random to me...   The daily time corresponds to a few of my daily scheduled tasks. 

I just staggered the start times of all my scheduled tasks by a few minutes, to make it painfully obvious which one is the culprit...   Now to wait a day.   ::)

My theory is that some of the batch code assumes it has a full environment... 
Title: Re: Subs-Post.php server errors
Post by: Sir Osis of Liver on March 12, 2018, 12:41:14 AM
Are you seeing these errors on your installs?  I've been unable to replicate the problem.
Title: Re: Subs-Post.php server errors
Post by: shawnb61 on March 12, 2018, 12:42:30 AM
Yes, I am seeing it on my main forum.  I suspect a mod.  Will know more tomorrow. 

Title: Re: Subs-Post.php server errors
Post by: Illori on March 12, 2018, 05:08:32 AM
do you have the send birthday email scheduled task enabled? i believe this was determined to be related to that.
Title: Re: Subs-Post.php server errors
Post by: shawnb61 on March 12, 2018, 07:14:53 AM
I believe it is the daily notification summary.   Now tp look at that a little deeper...
Title: Re: Subs-Post.php server errors
Post by: Sir Osis of Liver on March 12, 2018, 12:52:29 PM
The errors vary, at different times and on different forums.  Core scheduled tasks wouldn't be causing it, so it must be mods, or non-default core tasks.
Title: Re: Subs-Post.php server errors
Post by: Illori on March 12, 2018, 12:56:28 PM
if you search this forum you will find it is caused by the scheduled tasks. each forum has those run at different times.
Title: Re: Subs-Post.php server errors
Post by: Sir Osis of Liver on March 12, 2018, 01:08:35 PM
Doesn't happen on any of my installs, is it server related?
Title: Re: Subs-Post.php server errors
Post by: Illori on March 12, 2018, 01:12:38 PM
we dont know. all that i can recall is it is related to the birthday email that is sent out.
Title: Re: Subs-Post.php server errors
Post by: Sir Osis of Liver on March 12, 2018, 01:21:07 PM
Just ran it manually, received birthday email, no errors. (https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.thekrashsite.com%2Fpics%2Fidk.gif&hash=9ac7acf13f4cfaa1b58390444a38dea11e5473d2)
Title: Re: Subs-Post.php server errors
Post by: Illori on March 12, 2018, 01:22:05 PM
then no one had a birthday for it to send an email.
Title: Re: Subs-Post.php server errors
Post by: Sir Osis of Liver on March 12, 2018, 01:23:55 PM
I set birth date to today, ran task, received email.  I have it set to run automatically tomorrow, will see what happens.
Title: Re: Subs-Post.php server errors
Post by: shawnb61 on March 12, 2018, 11:56:11 PM
I can reproduce the "utf8" and "server" ones at will.  These two can be generated from the daily digest. 

The basic problem is that when run via the call to AutoTask() in index.php ~L88, $context variables aren't set yet because it is so early in index.php.  We haven't loaded user or theme stuff.  Also, our normal error handler isn't yet set, that also comes later in index.php. 

So, we have no error handler and we have no $context.  Hence the odd messages & odd error logging location. 

During the daily digest's call to sendmail, $context['server'] is referenced, that generates the "undefined index: server" message. 

The utf8 errors come later when it thinks the email addresses need the "hotmail fix".  Same thing - $context isn't set.  So it gets set only when trying to send emails to att/comcast/bellsouth addresses.  That's why those are more sporadic. 

The scheduled tasks know stuff is missing, and there is a function to LoadEssentialThemeData() that attempts to fill in some of the blanks.  Maybe we need a LoadMinimalContext() as well to fill in the other missing stuff for scheduled tasks. 

This will not happen when you run a task from the maint menu, because as a user, index.php has loaded all of the user info, theme info & the error handler. 

I imagine each of the auto-scheduled tasks may have its own set of needed/missing $context variables. 

EDIT:  To fix the error logging part of this issue, we need to move the error handler before the call to AutoTask(). 
EDIT2: The hotmail thing isn't just used for hotmail/att/comcast/bellsouth addresses, it's more involved than that... 
Title: Re: Subs-Post.php server errors
Post by: shawnb61 on March 13, 2018, 11:22:48 AM
And...  I see this has been discussed frequently before.  But known & fixed in 2.1.   Not likely fixed in 2.0.

One reference:
https://www.simplemachines.org/community/index.php?topic=517547.msg3748605#msg3748605
Title: Re: Subs-Post.php server errors
Post by: Sir Osis of Liver on March 13, 2018, 05:09:28 PM
It seems to be at least somewhat server related.  Received a birthday email overnight from 2.0.15 test install, no errors.