Fixed notice deleting

  • Thread starter Thread starter ragtek
  • Start date Start date
R

ragtek

Guest
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();
}
 
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();
}
 
Problem confirmed and code fix confirmed. Though technically you should quote the id:

Rich (BB code):
	/**
	 * Post-delete handling.
	 */
	protected function _postDelete()
	{
		$this->_db->delete('xf_notice_dismissed', 'notice_id = ' . $this->_db->quote($this->get('notice_id')));
		$this->_rebuildNoticeCache();
	}
 
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.
 
Top Bottom