Simple Machines Community Forum

SMF Support => SMF 2.1.x Support => Topic started by: MazziBig on January 26, 2022, 12:59:41 AM

Title: Errors 'Trying to access array offset on value of type null' in Error log
Post by: MazziBig on January 26, 2022, 12:59:41 AM
In Error log we have many similar error
Trying to access array offset on value of type null in Sources/Subs-Editor.php line 2263
What's this?
Antispam verification questions settings:
2022-01-26 08_57_26-Антиспам — Firefox Nightly.png
PHP 7.4.25
SMF 2.1 RC4
Title: Re: Errors 'Trying to access array offset on value of type null' in Error log
Post by: Kindred on January 26, 2022, 08:00:39 AM
we need the full error message, plus the lines of code (5-10 before and after)  since we don't know what might have modified your file to have different code lines from ours.
Title: Re: Errors 'Trying to access array offset on value of type null' in Error log
Post by: MazziBig on January 26, 2022, 08:47:19 AM
Quote from: Kindred on January 26, 2022, 08:00:39 AMwe need the full error message, plus the lines of code (5-10 before and after)  since we don't know what might have modified your file to have different code lines from ours.
Subs-Editor.php not modified
2022-01-26 16_43_40-public_html_Sources_Subs-Editor.php — Firefox Nightly.png
Tracelog
2022-01-26 16_39_15-Данные трассировки — Firefox Nightly.png
Error in Error Log page
2022-01-26 16_44_56-Журнал ошибок — Firefox Nightly.png

Title: Re: Errors 'Trying to access array offset on value of type null' in Error log
Post by: Kindred on January 26, 2022, 10:33:11 AM
ummm....  next time you're asked for code bits, can you please do text, not screenshots. It's nearly impossible to read/work from screen shots.

Where did you get your copy of 2.1 RC4? (specifically: as a download from this site -- or updated from GitHub?)
Title: Re: Errors 'Trying to access array offset on value of type null' in Error log
Post by: Arantor on January 26, 2022, 10:54:17 AM
Try deleting and re-adding the Q&A, it seems like it got corrupted somehow.
Title: Re: Errors 'Trying to access array offset on value of type null' in Error log
Post by: MazziBig on January 27, 2022, 12:19:04 AM
Quote from: Kindred on January 26, 2022, 10:33:11 AMnext time you're asked for code bits, can you please do text, not screenshots.
Ok. Do it next time :) But so difficult copy text from error log source code window with line numbers.
Quote from: Kindred on January 26, 2022, 10:33:11 AMWhere did you get your copy of 2.1 RC4?
GitHub version from Oct 21, 2021 (fixed quotes)
Lines in Subs-Editor.php are same link (https://github.com/SimpleMachines/SMF2.1/blob/806ab1cd2ad06a23fdfe1b5e4742995d7deb4ea8/Sources/Subs-Editor.php#L2263)
Quote from: Arantor on January 26, 2022, 10:54:17 AMTry deleting and re-adding the Q&A
Ok. Remove Q&A and disable function. I will observe behavior.


Title: Re: Errors 'Trying to access array offset on value of type null' in Error log
Post by: MazziBig on January 27, 2022, 12:47:30 AM
Disаble future, but errors still exist. WTF? ??? What SQL table contains Q&A?

UPD.
Error log entry
Guest
144.76.23.196
b17bde36cbc17064af4f1175ab69b62d
https://fxxxxxxx.ru/index.php?/topic,220.225.html
/home/f/forumxxx/fxxxxxxxx/public_html/Sources/Subs-Editor.php (Строка 2263)
8: Trying to access array offset on value of type null
Url for topic contains "?" symbol. Is it right? May be it's hacking attempts?
Title: Re: Errors 'Trying to access array offset on value of type null' in Error log
Post by: shawnb61 on January 27, 2022, 01:34:25 AM
Do you have 'Search engine friendly urls' enabled? 

Under Admin | Features and Options | General?

If so, does the problem go away if it is disabled?
Title: Re: Errors 'Trying to access array offset on value of type null' in Error log
Post by: MazziBig on January 27, 2022, 02:17:14 AM
Quote from: shawnb61 on January 27, 2022, 01:34:25 AMDo you have 'Search engine friendly urls' enabled? 
Yes, it's enabled. Disable and will observe.

UPD. Don't helps. Errors still added. Page url in error contains "?/" together
Guest
144.76.23.200
43c8f5440a301012b8c540e6de2c0a46
https://forumxxxxxxx.ru/index.php?/topic,177.0.html
/home/f/forumxx/forumxxxxxxx/public_html/Sources/Subs-Editor.php (Строка 2263)
8: Trying to access array offset on value of type null
Title: Re: Errors 'Trying to access array offset on value of type null' in Error log
Post by: Kindred on January 27, 2022, 01:00:50 PM
https://forumxxxxxxx.ru/index.php?/topic,177.0.html

that URL indicates that you did NOT disable "SEF urls"
Title: Re: Errors 'Trying to access array offset on value of type null' in Error log
Post by: Doug Heffernan on January 27, 2022, 01:52:50 PM
What mods do you have installed?
Title: Re: Errors 'Trying to access array offset on value of type null' in Error log
Post by: shawnb61 on January 27, 2022, 06:41:30 PM
That code & location match vanilla code.  This might be a real bug...  Just haven't been able to reproduce it yet...
Title: Re: Errors 'Trying to access array offset on value of type null' in Error log
Post by: Oldiesmann on January 27, 2022, 11:10:58 PM
That error means $row['question'] isn't set for that question. Try this - it won't solve the problem but it will give us more information that can possibly help track down the issue.

Sources/Subs-Editor.php
Find
Code (Line 2260) Select
$row = &$modSettings['question_id_cache']['questions'][$q];
Add after that
if (empty($row['question']))
log_error(print_r($row, true));

That will log the contents of $row if there's no "question".
Title: Re: Errors 'Trying to access array offset on value of type null' in Error log
Post by: MazziBig on January 28, 2022, 12:23:19 AM
Quote from: Kindred on January 27, 2022, 01:00:50 PMthat URL indicates that you did NOT disable "SEF urls"
I don't understand why that url exist in log. But SEF is disabled
2022-01-28 08_07_04-Clipboard.png
But even more surprising the presence of different types of URL in the log
2022-01-28 08_14_05-IP Address - 144.76.23.210 — Firefox Nightly.png
Quote from: Doug Heffernan on January 27, 2022, 01:52:50 PMWhat mods do you have installed?
FA Board Icons 1.3
FancyBox 4 SMF 1.0
Fancy Features 1.9.3
Quick Spoiler 1.4
Likes aka Karma 0.3 
Quote from: Oldiesmann on January 27, 2022, 11:10:58 PMTry this
Ok
Title: Re: Errors 'Trying to access array offset on value of type null' in Error log
Post by: MazziBig on January 28, 2022, 03:15:30 AM
Translate for screen with errors from previous post
Сегодня - Today
Вчера - Yesterday
Гость - Guest
Title: Re: Errors 'Trying to access array offset on value of type null' in Error log
Post by: ozp on January 28, 2022, 08:34:31 AM
Only happens to guests? Could this be during registration? Or do you allow guests to post?
Title: Re: Errors 'Trying to access array offset on value of type null' in Error log
Post by: Oldiesmann on January 29, 2022, 02:35:21 AM
If you made the code change I suggested there should be additional errors with more information now.
Title: Re: Errors 'Trying to access array offset on value of type null' in Error log
Post by: MazziBig on January 31, 2022, 02:45:16 AM
Quote from: ozp on January 28, 2022, 08:34:31 AMOnly happens to guests?
not only for Guest
Quote from: Oldiesmann on January 29, 2022, 02:35:21 AMIf you made the code change I suggested there should be additional errors with more information now.
Since adding to the code log_error I got only one error. But in Message in log is emty
2022-01-31 10_38_13-Журнал ошибок — Firefox Nightly.png
Backtrace for error 94
Error
Type of error
General
Error message
8: Trying to access array offset on value of type null
File
/home/f/forumxx/forumxx/public_html/Sources/Subs-Editor.php
Line
2267
URL of page causing the error
https://forumxxx.ru/index.php?topic=256.msg1236056;boardseen
Backtrace information

    #0: smf_error_handler()
    Called from /home/f/forumxx/forumxx/public_html/Sources/Subs-Editor.php on line 2267
    #1: create_control_verification()
    Called from /home/f/forumbxxx/forumxxx/public_html/Sources/Display.php on line 351
    #2: Display()
    Called from unknown on line -1
    #3: call_user_func()
    Called from /home/f/forumxxx/forumxxx/public_html/index.php on line 187

for error 93
Error
Type of error
General
URL of page causing the error
https://forumxxx.ru/index.php?topic=256.msg1236056;boardseen
Backtrace information

    #0: create_control_verification()
    Called from /home/f/forumxxx/forumxxx/public_html/Sources/Display.php on line 351
    #1: Display()
    Called from unknown on line -1
    #2: call_user_func()
    Called from /home/f/forumxxx/forumxxx/public_html/index.php on line 187

Code (Sources/Subs-Editor.php) Select
2257:foreach ($questionIDs as $q)
2258: {
2259: // Bit of a shortcut this.
2260: $row = &$modSettings['question_id_cache']['questions'][$q];
2261: // [DEBUG]
2262: if (empty($row['question']))
2263: log_error(print_r($row, true));
2264:
2265: $thisVerification['questions'][] = array(
2266: 'id' => $q,
==>2267: 'q' => parse_bbc($row['question']),
2268: 'is_error' => !empty($incorrectQuestions) && in_array($q, $incorrectQuestions),
2269: // Remember a previous submission?
2270: 'a' => isset($_REQUEST[$verificationOptions['id'] . '_vv'], $_REQUEST[$verificationOptions['id'] . '_vv']['q'], $_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) ? $smcFunc['htmlspecialchars']($_REQUEST[$verificationOptions['id'] . '_vv']['q'][$q]) : '',