• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed notice deleting

R

ragtek

Guest
#1
The notice specific dismissed notices aren't deleted from the dismissed notices table when the admin deletes a notice.


fix


change postdelete method from XenForo_DataWriter_Notice to
PHP:
protected function _postDelete()
{
$this->_db->delete('xf_notice_dismissed', 'notice_id = ' . $this->get('notice_id'));
$this->_rebuildNoticeCache();
}
 

Chris D

XenForo developer
Staff member
#3
ragtek, this works great.

Would you be happy for me to include your fix in my Notifications add-on?

PHP:
protected function _postDelete()
{
$this->_db->delete('xf_notification_dismissed', 'notification_id = ' . $this->get('notification_id'));
$this->_rebuildNotificationCache();
}
 

Jake Bunce

XenForo moderator
Staff member
#4
Problem confirmed and code fix confirmed. Though technically you should quote the id:

Code:
	/**
	 * Post-delete handling.
	 */
	protected function _postDelete()
	{
		$this->_db->delete('xf_notice_dismissed', 'notice_id = ' . $this->_db->quote($this->get('notice_id')));
		$this->_rebuildNoticeCache();
	}
 

Jake Bunce

XenForo moderator
Staff member
#6
get() gets the value. quote() prepares the value for insertion in a query. That includes quoting and escaping string data types. The notice_id is an integer so it's not strictly necessary to quote, but it's a good convention that you should always follow.