Prime Notify

'Email on each new post' problem - Prime Notify

'Email on each new post' problem

by CarolC1 » Wed Mar 15, 2023 4:25 pm

We have had Prime Notify since 2013.

The 1.0.5 extension worked perfectly for 2 years. Then a month ago we began to have a posting-hang on replies, where you would post a reply and it took up to 5 minutes to submit.

I traced it to the Prime Notify extension. If it is disabled, replies submit normally. Enabled, they hang.

I further isolated it to one setting. If 'Email me on each new post' is set on User's choice, it hangs. If it is set on Yes or No, it submits normally.

Currently we are still using Prime Notify with 'Email me on each new post' set on Yes, so it will work without hanging. I would prefer to be able to have User's choice again.

No changes have been made to the extension or the board. This was out of the blue.

IT checked the logs and they don't see any error. They say they make changes to the server all the time, but if they were going to change anything big that would break an extension, they would let me know ahead of time.

I tried uninstalling (made sure it was gone from the database) and reinstalling, but that didn't help.

I can provide more detail (the long version) if you need it.

Thanks!
CarolC1
Registered User
Posts: 667
Joined: Sat Dec 02, 2006 4:26 pm

Re: 'Email on each new post' problem

by primehalo » Sat Apr 15, 2023 4:21 pm

It's strange that it would stop working out of the blue. If it was going to stop working, I'd think it would have been after a phpBB update. It's been a long time since I worked on this code. I looked over all the sections mentioning USER_CHOICE but don't see anything obvious that would cause an issue.
Ken F. Innes IV
My Extensions | My MODs | My Topics | My Site: Absolute Anime
Experience the wonder of Japanese Animation!
User avatar
primehalo
Former Team Member
Posts: 2992
Joined: Fri May 06, 2005 5:58 pm
Location: Redding, CA

Re: 'Email on each new post' problem

by primehalo » Sat Apr 15, 2023 4:34 pm

It could possibly be these lines in primehalo/primenotify/core/prime_notify.php:
#257: FROM ' . FORUMS_WATCH_TABLE . ' w, ' . USERS_TABLE . ' u
#265: FROM ' . TOPICS_WATCH_TABLE . ' w, ' . USERS_TABLE . ' u

Apparently this syntax is deprecated. The newer syntax is:
#257: FROM ' . FORUMS_WATCH_TABLE . ' w INNER JOIN ' . USERS_TABLE . ' u ON u.user_id = w.user_id
#265: FROM ' . TOPICS_WATCH_TABLE . ' w INNER JOIN ' . USERS_TABLE . ' u ON u.user_id = w.user_id

I really don't know if this is the cause or would make any difference at all.
Last edited by primehalo on Sun Apr 16, 2023 12:13 am
Ken F. Innes IV
My Extensions | My MODs | My Topics | My Site: Absolute Anime
Experience the wonder of Japanese Animation!
User avatar
primehalo
Former Team Member
Posts: 2992
Joined: Fri May 06, 2005 5:58 pm
Location: Redding, CA

Re: 'Email on each new post' problem

by CarolC1 » Sat Apr 15, 2023 6:57 pm

Hi! Thanks for your reply.

Tried it on the test board. Got an error.

Here is the file edit.

Code: Select all

$sql = 'SELECT w.user_id as user_id
					FROM ' . FORUMS_WATCH_TABLE . ' w, INNER JOIN ' . USERS_TABLE . ' u on u.user_id = w.user_id
					WHERE w.forum_id = ' . (int) $post['forum_id'] . '
						AND (w.notify_status = ' . NOTIFY_YES . ' OR (u.user_id = w.user_id AND u.user_primenotify_always_send = ' . self::ENABLED . '))
						AND w.user_id <> ' . (int) $post['poster_id'];
			}
			else
			{
				$sql = 'SELECT w.user_id as user_id
					FROM ' . TOPICS_WATCH_TABLE . ' w, INNER JOIN ' . USERS_TABLE . ' u u.user_id = w.user_id
					WHERE w.topic_id = ' . (int) $post['topic_id'] . '
Here is the error when I tried to reply with the setting ticked on User's Choice.

Code: Select all

General Error
SQL ERROR [ mysqli ]

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INNER JOIN ####_users u on u.user_id = w.user_id WHERE w.forum_id = 1 ...' at line 2 [1064]

SQL

SELECT w.user_id as user_id FROM ####_forums_watch w, INNER JOIN ####_users u on u.user_id = w.user_id WHERE w.forum_id = 1 AND (w.notify_status = 0 OR (u.user_id = w.user_id AND u.user_primenotify_always_send = 1)) AND w.user_id <> ####

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 1023
CALL: trigger_error()

FILE: [ROOT]/phpbb/db/driver/mysqli.php
LINE: 195
CALL: phpbb\db\driver\driver->sql_error()

FILE: [ROOT]/phpbb/db/driver/factory.php
LINE: 345
CALL: phpbb\db\driver\mysqli->sql_query()

FILE: [ROOT]/ext/primehalo/primenotify/notification/type/topic.php
LINE: 61
CALL: phpbb\db\driver\factory->sql_query()

FILE: [ROOT]/phpbb/notification/manager.php
LINE: 273
CALL: primehalo\primenotify\notification\type\topic->find_users_for_notification()

FILE: [ROOT]/phpbb/notification/manager.php
LINE: 266
CALL: phpbb\notification\manager->add_notifications()

FILE: [ROOT]/includes/functions_posting.php
LINE: 2392
CALL: phpbb\notification\manager->add_notifications()

FILE: [ROOT]/posting.php
LINE: 1504
CALL: submit_post()
[EDIT: REMOVED TABLE PREFIX, USER_ID]
CarolC1
Registered User
Posts: 667
Joined: Sat Dec 02, 2006 4:26 pm

Re: 'Email on each new post' problem

by primehalo » Sat Apr 15, 2023 9:45 pm

Sorry, I accidentally left the comma in there. I edited the post to remove it.
Ken F. Innes IV
My Extensions | My MODs | My Topics | My Site: Absolute Anime
Experience the wonder of Japanese Animation!
User avatar
primehalo
Former Team Member
Posts: 2992
Joined: Fri May 06, 2005 5:58 pm
Location: Redding, CA

Re: 'Email on each new post' problem

by CarolC1 » Sun Apr 16, 2023 12:03 am

Thanks!

Got an error again, with the corrected file on the server and the cache purged, setting ticked to User's Choice.

Corrected file

Code: Select all

$sql = 'SELECT w.user_id as user_id
					FROM ' . FORUMS_WATCH_TABLE . ' w INNER JOIN ' . USERS_TABLE . ' u on u.user_id = w.user_id
					WHERE w.forum_id = ' . (int) $post['forum_id'] . '
						AND (w.notify_status = ' . NOTIFY_YES . ' OR (u.user_id = w.user_id AND u.user_primenotify_always_send = ' . self::ENABLED . '))
						AND w.user_id <> ' . (int) $post['poster_id'];
			}
			else
			{
				$sql = 'SELECT w.user_id as user_id
					FROM ' . TOPICS_WATCH_TABLE . ' w INNER JOIN ' . USERS_TABLE . ' u u.user_id = w.user_id

					WHERE w.topic_id = ' . (int) $post['topic_id'] . '
						AND (w.notify_status = ' . NOTIFY_YES . ' OR (u.user_id = w.user_id AND u.user_primenotify_always_send = ' . self::ENABLED . '))
Error

Code: Select all

General Error

SQL ERROR [ mysqli ]

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'u.user_id = w.user_id WHERE w.topic_id = 20890 AND (w.notify_stat...' at line 2 [1064]

SQL

SELECT w.user_id as user_id FROM ####_topics_watch w INNER JOIN ####_users u u.user_id = w.user_id WHERE w.topic_id = 20890 AND (w.notify_status = 0 OR (u.user_id = w.user_id AND u.user_primenotify_always_send = 1)) AND w.user_id <> ####

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 1023
CALL: trigger_error()

FILE: [ROOT]/phpbb/db/driver/mysqli.php
LINE: 195
CALL: phpbb\db\driver\driver->sql_error()

FILE: [ROOT]/phpbb/db/driver/factory.php
LINE: 345
CALL: phpbb\db\driver\mysqli->sql_query()

FILE: [ROOT]/ext/primehalo/primenotify/notification/type/post.php
LINE: 61
CALL: phpbb\db\driver\factory->sql_query()

FILE: [ROOT]/phpbb/notification/manager.php
LINE: 273
CALL: primehalo\primenotify\notification\type\post->find_users_for_notification()

FILE: [ROOT]/phpbb/notification/manager.php
LINE: 266
CALL: phpbb\notification\manager->add_notifications()

FILE: [ROOT]/includes/functions_posting.php
LINE: 2400
CALL: phpbb\notification\manager->add_notifications()

FILE: [ROOT]/posting.php
LINE: 1504
CALL: submit_post()
CarolC1
Registered User
Posts: 667
Joined: Sat Dec 02, 2006 4:26 pm

Re: 'Email on each new post' problem

by primehalo » Sun Apr 16, 2023 12:17 am

There was a missing 'ON'. I have fixed it again
Ken F. Innes IV
My Extensions | My MODs | My Topics | My Site: Absolute Anime
Experience the wonder of Japanese Animation!
User avatar
primehalo
Former Team Member
Posts: 2992
Joined: Fri May 06, 2005 5:58 pm
Location: Redding, CA

Re: 'Email on each new post' problem

by CarolC1 » Sun Apr 16, 2023 12:38 am

Thank you! I think that fixed it. It's submitting normally now. Will try it on the live board, but everything looks good.

Thank you so very much! :D
CarolC1
Registered User
Posts: 667
Joined: Sat Dec 02, 2006 4:26 pm