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

Fixed notice deleting

Discussion in 'Resolved Bug Reports' started by ragtek, Jul 21, 2012.

  1. ragtek

    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();
    }
     
    Chris D and Shelley like this.
  2. ragtek

    ragtek Guest

    If anybody wants to install an addon to fix it before it's included in xenforo core:

    (this is a quick fix, which DOESN'T delete the dismisses for ALREADY deleted notices)
     

    Attached Files:

    Adam Howard, Chris D, Deebs and 2 others like this.
  3. Chris D

    Chris D XenForo Developer Staff Member

    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();
    }
     
    simbolo, Adam Howard and Shelley like this.
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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();
    	}
    
     
  5. Chris D

    Chris D XenForo Developer Staff Member

    Noob question... What's the difference between $this->get and $this->_db->quote?
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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.
     
    Jeremy, BamaStangGuy and Chris D like this.
  7. Mike

    Mike XenForo Developer Staff Member

    Fixed.
     
    Slavik likes this.

Share This Page