Advertisement:

Author Topic: Log errors - Subs-Post.php on line 1264 and Subs-Post.php on line 627  (Read 760 times)

Offline jamesde

  • Newbie
  • *
  • Posts: 3
PHP Notice:  Undefined index: server in /home/xxxxxx/public_html/Sources/Subs-Post.php on line 627
PHP Notice:  Undefined index: utf8 in /home/xxxxxx/public_html/Sources/Subs-Post.php on line 1262
PHP Notice:  Undefined index: utf8 in /home/xxxxxx/public_html/Sources/Subs-Post.php on line 1264

Thank you all in advance. I'm getting a few folks on my forum who say they get a "database error" when trying to reply to a post. This is only happening sporadically it seems. What's even more troubling is a member got a "database error" today, but the last error in the server log is from yesterday, but the forum admin error log shows his errors. (We are both in the same time zone in the USA.) Then the member might try again in a little while, and it will allow him to post. I've included screen shots.

I just moved the fairly large site (63807 MB) to a new dedicated server, and updated the forum since the errors started. Please tell me if you need more information from me. THANKS IN ADVANCE FOR ANY SUGGESTIONS AT ALL.

Jimmy

modelersforum.com PHP 5.6





Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,429
  • Gender: Male
    • Kindred-999 on GitHub
And what is the code at/around those lines?
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Illori

  • Project Manager
  • SMF Legend
  • *
  • Posts: 51,133
PHP Notice:  Undefined index: server in /home/xxxxxx/public_html/Sources/Subs-Post.php on line 627
PHP Notice:  Undefined index: utf8 in /home/xxxxxx/public_html/Sources/Subs-Post.php on line 1262
PHP Notice:  Undefined index: utf8 in /home/xxxxxx/public_html/Sources/Subs-Post.php on line 1264

I believe these errors are known with no known fix, due to difficulty duplicating the issue.

Offline jamesde

  • Newbie
  • *
  • Posts: 3
And what is the code at/around those lines?

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,429
  • Gender: Male
    • Kindred-999 on GitHub
please use code tags and paste actual code, not images
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline jamesde

  • Newbie
  • *
  • Posts: 3
Code: [Select]
// Send off an email.
function sendmail($to, $subject, $message, $from = null, $message_id = null, $send_html = false, $priority = 3, $hotmail_fix = null, $is_private = false)
{
global $webmaster_email, $context, $modSettings, $txt, $scripturl;
global $smcFunc;

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

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

// So far so good.
$mail_result = true;

// If the recipient list isn't an array, make it one.
$to_array = is_array($to) ? $to : array($to);

// Once upon a time, Hotmail could not interpret non-ASCII mails.
// In honour of those days, it's still called the 'hotmail fix'.
if ($hotmail_fix === null)
{
$hotmail_to = array();
foreach ($to_array as $i => $to_address)
{
if (preg_match('~@(att|comcast|bellsouth)\.[a-zA-Z\.]{2,6}$~i', $to_address) === 1)
{
$hotmail_to[] = $to_address;
$to_array = array_diff($to_array, array($to_address));
}
}

Code: [Select]
// Convert all special characters to HTML entities...just for Hotmail :-\
if ($hotmail_fix && ($context['utf8'] || function_exists('iconv') || $context['character_set'] === 'ISO-8859-1'))
{
if (!$context['utf8'] && function_exists('iconv'))
{
$newstring = @iconv($context['character_set'], 'UTF-8', $string);
if ($newstring)
$string = $newstring;
}

// Convert all 'special' characters to HTML entities.
return array($charset, preg_replace_callback('~([\x80-\x{10FFFF}])~u', 'mime_convert__preg_callback', $string), '7bit');
}

Offline Sesquipedalian

  • The Mad Doctor
  • Lead Developer
  • Sr. Member
  • *
  • Posts: 944
  • Gender: Male
  • It works! ... in theory.
    • Sesquipedalian on GitHub
Although the Subs-Post.php file is involved in both cases, it looks like you have two distinct sets of issues happening here.

The first is that some expected variables are undefined when the forum tries to send email notifications. This is the source of the "PHP Notice" errors recorded in your Apache log. Since these errors always appear a few minutes after 19:00 every day, I suspect that something is wrong in one of your scheduled tasks, possibly one added or changed by a mod.

The second is that sometimes malformed data is being submitted when trying to create a new post. This is the source of the "Database Error" messages recorded in the SMF error log. The reported line number, 1817, doesn't match with the line numbers in a vanilla copy of Subs-Post.php, so I suspect that the file has been modified.

Please (1) attach full copies of your Subs-Post.php and ScheduledTasks.php files, and (2) tell us which tasks are scheduled to run at 19:00  on your forum.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Offline Illori

  • Project Manager
  • SMF Legend
  • *
  • Posts: 51,133
Please (1) attach full copies of your Subs-Post.php and ScheduledTasks.php files, and (2) tell us which tasks are scheduled to run at 19:00  on your forum.

I bet it is the birthday email and does not happen daily. this one has been mentioned many times in the past without a fix.

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 9,242
I've seen those Subs-Post.php errors on several forums that were not experiencing any problems.

it looks like you have two distinct sets of issues happening here.

Offline shawnb61

  • Developer
  • Sophist Member
  • *
  • Posts: 1,334
    • sbulen on GitHub
I can reproduce the subs-post undefined 'server' and 'utf8' issues in vanilla 2.0.x at will.  These issues are not due to a mod - it's vanilla code.  These issues have been around for a very long time...  My understanding was that we were not going to address these in 2.0.x, but that they were fixed in 2.1. 

An earlier writeup, explaining the problem: 
https://www.simplemachines.org/community/index.php?topic=559132.msg3965264#msg3965264

I believe that different scheduled tasks may have different sets of undefined issues, depending on the data. 

I can document the exact steps to reproduce, if we really do want to fix this in 2.0.x. 

Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 9,242
Re: Log errors - Subs-Post.php on line 1264 and Subs-Post.php on line 627
« Reply #10 on: June 24, 2019, 11:46:01 PM »
Doesn't seem to break anything, would guess that's why it wasn't fixed in 2.0.  Interesting to see an explanation of the cause.

Offline digzu

  • Newbie
  • *
  • Posts: 9
Re: Log errors - Subs-Post.php on line 1264 and Subs-Post.php on line 627
« Reply #11 on: June 25, 2019, 04:50:24 AM »
Even if it doesn’t break anything as-is I don’t see any harm fixing things like errors/notices just to keep the code more consistent and less “unnecessary” logging.

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 9,242
Re: Log errors - Subs-Post.php on line 1264 and Subs-Post.php on line 627
« Reply #12 on: June 25, 2019, 03:37:06 PM »
That's been discussed here previously, error logs are often flooded with miscellaneous user errors, to the point that admins just ignore the log.  When something serious goes wrong, they're often unaware of it until the wheels come off.  Error handling could use a bit of tweaking.