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

postSave Resource discussion thread id is zero

CrispinP

Well-known member
#1
Hi folks,

I have an add-on which extends data writer. The hint used is "XenResource_DataWriter_Update"

In my _postSave function I can see the resource_id when a resource is added but the discussion_thread_id is always zero.

My code:
Code:
    $f = $this->getModelFromCache('XenResource_Model_Resource');
     print_r($f->getResourceById($this->get('resource_id')));
     die("dead");
Here is what I get when I get a resource in the function:
Code:
(
    [resource_id] => 312
    [title] => sdf
    [tag_line] => asdfasf
    [user_id] => 1
    [username] => Crispin
    [resource_state] => visible
    [resource_date] => 1469051740
    [resource_category_id] => 6
    [current_version_id] => 0
    [description_update_id] => 0
    [discussion_thread_id] => 0
    [external_url] => 
    [is_fileless] => 0
    [external_purchase_url] => 
    [price] => 0.00
    [currency] => 
    [download_count] => 0
    [rating_count] => 0
    [rating_sum] => 0
    [rating_avg] => 0
    [rating_weighted] => 3
    [update_count] => 0
    [review_count] => 0
    [last_update] => 1469051740
    [alt_support_url] => 
    [had_first_visible] => 1
    [custom_resource_fields] => a:0:{}
    [prefix_id] => 0
    [icon_date] => 0
    [tags] => a:0:{}
)
If I hardcode a previously saved id, 300, I do get the value back.

Why is it not available the way I am doing it? I'm really confused. :(


TIA
Crispin
 

CrispinP

Well-known member
#3
Doh - should have said - yes, it is. The thread is created, I can see like normal. Just the id is not updated in the array.

I've done some more digging.

In XenResource DataWriter there is a function called _insertDiscussionThread. It is this which sets the thread id after creating the thread. This is called by the _postSave function in datawriter.

If I put a debug print in there and a debug print at the bottom of my _postSave function I can see that my _postSave function is called before the the real one. This is why it's not populated.

My function looks like this:
Code:
class Crispin_Bla_DataWriter_DataWriter extends XFCP_Crispin_Bla_DataWriter_DataWriter
{
    public function _postSave()
    {       
        // call parent
        parent::_postSave();
...
    }
}
Am I simply just calling it wrong?
 

Liam W

Well-known member
#4
I'm assuming you're doing parent::_postSave() before your code?

If you are, that's a strange one, and I'm not 100% sure what would cause it...

Liam
 

CrispinP

Well-known member
#5
Yup. Parent save is the first line of my function.

Is my function actually overriding the real postsave? I don't think it is. They appear to be running sequential.