[3.0] Save the notification preference the member asked for - #9477
Open
albertlast wants to merge 1 commit into
Open
[3.0] Save the notification preference the member asked for#9477albertlast wants to merge 1 commit into
albertlast wants to merge 1 commit into
Conversation
Three things stopped a topic or board notification from being set. Db::insert() wants a list of rows, and changePref() handed it a single one, so turning notification on for a topic answered "Invalid data structure sent to the database" and logged a critical error. sa=off maps to mode -1, which is MODE_NO_ALERT, and setAlertPref() has no case for it. $alert_pref is a typed property with no default, so reading it threw - the unsubscribe link at the foot of every notification email was a fatal error, on topics and on boards. 2.1's -1 is what 3.0 calls MODE_NO_EMAIL, so point sa=off at that constant and the link means what it says again. Any other value of mode did the same thing, since mode comes from the query string. Give the switch a default, and give MODE_NO_ALERT the handling its name describes. Signed-off-by: Mathias Papenbrock <mathiaspapealbert@hotmail.com> Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Topic and board notifications do not work on
release-3.0. Three separate faults, all on the same path.1.
NotifyTopic::changePref()passes a single row where a list is required.Db::insert()needs$datato be an array of rows; with$backward_compatibilityoff (the default) anything else isInvalid data structure sent to the database.and acriticalrow in the error log.Notify::changeBoardTopicPref()a few lines away wraps its row correctly - this one does not.2.
sa=offpicks a mode nothing handles.saToMode()mapsoffto-1, and-1isMODE_NO_ALERT, for whichsetAlertPref()has nocase.$alert_prefis a typed property with no default, so the next line to read it throws:That is the UNSUBSCRIBELINK at the foot of every notification email (
Tasks/CreatePost_Notify.php), and the No link on the notification confirmation page, for both topics and boards.In 2.1 the value
-1meant "turn off email notifications while leaving the alert pref unchanged" - which 3.0 renamed toMODE_NO_EMAIL(-2) when it split the constant in two, without updatingsaToMode(). Pointingsa=offatMODE_NO_EMAILrestores 2.1's behaviour exactly.3. Any unknown mode did the same.
$this->modeis(int) $_GET['mode'], so?mode=99was also a fatal. The switch now has adefault, andMODE_NO_ALERTgets the handling its name describes - the mirror of theMODE_NO_EMAILcase.How to test
Before: 500 on all three, with the errors above in
smf_log_errors. After: all redirect, the log stays empty, andsmf_user_alerts_prefsshowsboard_notify_1going 3 → 1 onsa=off- email bit cleared, alert bit kept, as in 2.1.Issues References (Fixes|Related|Closes)
Found while sweeping the topic display for the #7933 split.