share_get_popups() returns multiple copies of data

joachim - January 22, 2009 - 15:39
Project:Share
Version:5.x-2.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:greenSkin
Status:active
Description

I'm calling share_get_popups('node', $vars['node']->type) in my template.php, and the data returned appears to have the same share repeated 3 times.

Surely this can't be right?

Array
(
    [0] => stdClass Object
        (
            [share_id] => 5
            [module] => share
            [label] => Share popup
            [node_types] => a:0:{}
            [category_terms] => a:0:{}
            [where] => node
            [view] => 1
            [status] => 1
            [weight] => -4
        )

    [1] => stdClass Object
        (
            [share_id] => 5
            [module] => share
            [label] => Share popup
            [node_types] => a:0:{}
            [category_terms] => a:0:{}
            [where] => node
            [view] => 1
            [status] => 1
            [weight] => -4
        )

    [2] => stdClass Object
        (
            [share_id] => 5
            [module] => share
            [label] => Share popup
            [node_types] => a:0:{}
            [category_terms] => a:0:{}
            [where] => node
            [view] => 1
            [status] => 1
            [weight] => -4
        )

)

I've stared at this for a bit and I'm sure it's the same stuff 3 times!

Is this line right?

    $shares[$id][] = $share;

Also, you're not making any use of your $shares being static.

#1

greenSkin - March 23, 2009 - 17:33
Version:5.x-2.0-alpha9» 5.x-2.x-dev
Priority:normal» critical
Assigned to:Anonymous» greenSkin

This issue is caused by my inadvertently not utilizing that static cache. Each time share_get_popups is called with the same criteria, it adds each popup again. With utilizing the static cache, this will not be a problem.

 
 

Drupal is a registered trademark of Dries Buytaert.