News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Undefined array key every day

Started by TheBom, February 14, 2024, 05:02:34 AM

Previous topic - Next topic

TheBom

Every day we get 4 errors in ScheduledTasks.php
It happens on line 1413 & 1416

Undefined array key with a number after it.

What is it and what can i do about this?

Deaks

we need more information, such as what mods you have installed?
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

TheBom

Quote from: Deaks on February 14, 2024, 05:49:41 AMwe need more information, such as what mods you have installed?

No mods

Its referring to these 2 if lines, yes we use paid subscriptions but why is it giving these errors on it every night

if ($notifyPrefs[$row['id_member']] & 0x02)
sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2);

if ($notifyPrefs[$row['id_member']] & 0x01)
{
$alert_rows[] = array(
'alert_time' => time(),
'id_member' => $row['id_member'],
'id_member_started' => $row['id_member'],
'member_name' => $row['member_name'],
'content_type' => 'paidsubs',
'content_id' => $row['id_sublog'],
'content_action' => 'expiring',
'is_read' => 0,
'extra' => $smcFunc['json_encode'](array(
'subscription_name' => $row['name'],
'end_time' => $row['end_time'],
)),
);
updateMemberData($row['id_member'], array('alerts' => '+'));
}
   }

Kindred

What are the ACTUAL,  FULL error messages?
Сл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."

Diego Andrés

I'll take a guess since you're not posting enough information about your error.
Is this your issue?

SMF Tricks - Free & Premium Responsive Themes for SMF.

TheBom

Well, i just found a setting to show more info.
Currently this is the only info i got

 https://www.******/forum/cron.php
 /home/*********/domains/******/public_html/forum/Sources/ScheduledTasks.php (Regel 1416)  Backtrace informatie

Fouttype: Cron
FoutmeldingSelecteer
2: Undefined array key 1485

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."

Arantor

And if you click on the 'backtrace information' button?
Holder of controversial views, all of which my own.

TheBom

Quote from: Arantor on February 15, 2024, 03:33:03 PMAnd if you click on the 'backtrace information' button?

Then i got this:
#0: smf_error_handler()
Aangeroepen van /home/****/domains/****/public_html/forum/Sources/ScheduledTasks.php op regel 1416
#1: scheduled_paid_subscriptions()
Aangeroepen van /home/****/domains/****/public_html/forum/Sources/ScheduledTasks.php op regel 116
#2: AutoTask()
Aangeroepen van /home/****/domains/****/public_html/forum/Sources/Load.php op regel 2638
#3: loadTheme()
Aangeroepen van /home/****/domains/****/public_html/forum/Sources/Load.php op regel 1340
#4: loadBoard()
Aangeroepen van /home/****/domains/****/public_html/forum/index.php op regel 217
#5: smf_main()
Aangeroepen van /home/****/domains/****/public_html/forum/index.php op regel 184

And the URL causing the problem seems for the same day this
https://****/forum/index.php?topic=80350.0
But yesterday it was
https://www.****/forum/index.phphttps://www.****/forum/cron.php
and the day before that its 3-4 times
https://www.****/forum/index.php?topic=109984.msg251301

Arantor

It's a bug. Somehow you have people who have paid subscriptions but no preferences set up for paid subscriptions to be told about them.

I'll try to give you some better debug notes later (am at work, using an iPad, writing code is hard)
Holder of controversial views, all of which my own.

Arantor

In ScheduledTasks.php, find that troublesome code on the line indicated.

This adds a new bit above the first if statement you found, and will solve the problem (I added the first if block for reference how it should look)

if (!isset($notifyPrefs[$row['id_member']]))
continue;

if ($notifyPrefs[$row['id_member']] & 0x02)
sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2);
Holder of controversial views, all of which my own.

Doug Heffernan

I've moved this to the Bug Reports board to bring it to the attention of our developers.

TheBom

Quote from: Arantor on February 19, 2024, 01:00:41 PMIn ScheduledTasks.php, find that troublesome code on the line indicated.

This adds a new bit above the first if statement you found, and will solve the problem (I added the first if block for reference how it should look)

if (!isset($notifyPrefs[$row['id_member']]))
continue;

if ($notifyPrefs[$row['id_member']] & 0x02)
sendmail($row['email_address'], $emaildata['subject'], $emaildata['body'], null, 'paid_sub_remind', $emaildata['is_html'], 2);

Thank you sir!

I have updated the code and will let you know if the error persists tomorrow.

But i'm wondering in the first place
A) why did this happen
B) shouldn't we fix the main cause instead of working on error hiding
C) What is the downside?

Arantor

A) Somehow you got users who have subscriptions but no preferences for those subscriptions.
B) It's a data error not a code error.
C) I don't see one.
Holder of controversial views, all of which my own.

TheBom

Quote from: Arantor on February 20, 2024, 03:30:58 AMA) Somehow you got users who have subscriptions but no preferences for those subscriptions.
B) It's a data error not a code error.
C) I don't see one.
Okay, but how did they do A in the first place? Isn't that the main bug that the data of B is missing?

Arantor

*shrug* I could see a failure state if the people in question took out subscriptions but never went to the notification settings page.

The reality is that, honestly, I don't care to investigate it that hard. I already regret how much time I sank into 2.1 as it was.

All my code change did was say "if there's no notification settings for this user, skip them". A sensible precaution in all cases, frankly.
Holder of controversial views, all of which my own.

Steve

DO NOT pm me for support!

Max22

Just for the record, there is a related issue about ScheduledTasks: #7784

Advertisement: