If you enable drupal's core feature block caching, socialshareprivacy isn't working anymore. After clearing the cache the share icons occur only once on the first page loaded and never again. That's because the block content gets cached and the dynamic adding of javascript to the footer never happens again. A quick patch is to set the block to BLOCK_NO_CACHE.
I attached a quick fix patch.

BTW the implementaion of hook_block is not as it should be. The options 'configure' and 'save' should not return an empty block array. I adjusted that in my patch as well.

Now I will start thinking about a better implementation of the socialprivacyshare block, because executing all the logic and adding the javascript to the footer dynamically is also incompatible with page caching and therefor not suitable for high traffic sites.

Comments

mkalkbrenner’s picture

Title: Implementation of hook_block is incompatible with block caching » incompatible with page and block caching
Assigned: Unassigned » mkalkbrenner
StatusFileSize
new6.6 KB

I distributed the functionality from hook_block to hook_init, hook_nodeapi, hook_block and hook_footer.
Now socialshareprivacy is compatible with block and page caching!

BTW are you accepting new co-maintainers? I'm interested in tuning the d7 version as well, working on i18n and adding some more configuration options.

mkalkbrenner’s picture

Added another minor improvement:
don't add socialshareprivacy to nodes in print mode, during indexing, ...

erikwegner’s picture

Hi Markus, thanks for your contribution. If you are interested in being a maintainer, you are welcome. I would like you to ask ytsurk, the current maintainer for the d7 branch, if it is ok for him, too.

mkalkbrenner’s picture

Status: Needs review » Fixed
mkalkbrenner’s picture

Version: 6.x-1.x-dev » 7.x-1.4
Assigned: mkalkbrenner » Unassigned
Status: Fixed » Patch (to be ported)
ytsurk’s picture

Assigned: Unassigned » ytsurk
Status: Patch (to be ported) » Closed (fixed)

maintainers are always wellcome :D

the block is non caching now .,
i always had BLOCK_NO_CACHE, but this was a d6 constant .., DRUPAL_NO_CACHE is d7 ..
regarding the js aggregation i did no enhanced test so far, but have it running on a site with page cache & js aggragation on.

yan’s picture

Thanks, this drove me crazy! I thought it was the js compression, but it seems the block cache caused it.

#1462742: Not working with js compression turned on