Errors 'Trying to access array offset on value of type null' in Error log

Started by MazziBig, January 26, 2022, 12:59:41 AM

Previous topic - Next topic

MazziBig

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:
You cannot view this attachment.
PHP 7.4.25
SMF 2.1 RC4

Kindred

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.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

MazziBig

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
You cannot view this attachment.
Tracelog
You cannot view this attachment.
Error in Error Log page
You cannot view this attachment.


Kindred

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?)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

Try deleting and re-adding the Q&A, it seems like it got corrupted somehow.

MazziBig

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 [nofollow]
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.



MazziBig

#6
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?

shawnb61

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?
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

MazziBig

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

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."


shawnb61

That code & location match vanilla code.  This might be a real bug...  Just haven't been able to reproduce it yet...
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Oldiesmann

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".
Michael Eshom
Christian Metal Fans

MazziBig

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
You cannot view this attachment.
But even more surprising the presence of different types of URL in the log
You cannot view this attachment.
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

MazziBig

Translate for screen with errors from previous post
Сегодня - Today
Вчера - Yesterday
Гость - Guest

ozp

Only happens to guests? Could this be during registration? Or do you allow guests to post?

Oldiesmann

If you made the code change I suggested there should be additional errors with more information now.
Michael Eshom
Christian Metal Fans

MazziBig

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
You cannot view this attachment.
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]) : '',

Advertisement: