When block caching is enabled every page ends up with the same ShareThis links because the default Drupal 7 block caching is DRUPAL_CACHE_PER_ROLE. This module needs DRUPAL_CACHE_PER_PAGE.
I used the following code to fix it on my site, but it should really be changed in the ShareThis module:
/**
* Implements hook_block_info_alter().
*/
function mymodule_block_info_alter(&$blocks, $theme, $code_blocks) {
// Change the caching mode for ShareThis blocks to be per page
if (!empty($blocks['sharethis'])) {
foreach ($blocks['sharethis'] as $delta => $block) {
$blocks['sharethis'][$delta]['cache'] = DRUPAL_CACHE_PER_PAGE;
}
}
}
Comments
Comment #1
ShareThis Support commentedHI,
Thank you for bringing this to our notice and for providing a solution.
I'll forward it to our dev team.
Regards,
Sharethis Support
Comment #3
poniesThis bug is still active in 2.5. Benshell's code works great. I'll try to roll it into a patch this week.
Comment #4
kublaken commentedDoesn't look like this has been patched yet. I had the same problem. ShareThis links were caching and generating the wrong links for users (anon and authenticated). Turning off block caching fixed the problem.
Comment #5
chakrapani commentedThanks benshell. The proposed solution work like charm :)
Surprised that this hasn't been addressed in the module yet. It would be great if someone can add a patch.
Comment #6
Gaofengzzz commentedThanks @benshell, i help create patch for dev version.
Comment #7
dydave commentedBetter set the status to needs review to trigger the Testbot and so that everyone could also work on reviewing the patch.
Watchout for patch file name, standard template could be found at: Making a Drupal patch with Git, in particular, see the details about patch file name:
Thanks in advance to everyone for the testing/reporting, reviewing and comments.
Cheers!
Comment #8
Gaofengzzz commentedThanks very much @benshell for your patch.
After more than two weeks, with no particular objections or further issues on this ticket, I went ahead and got it committed against the 7.x-2.x branch at 281f8b1.
Comment #9
Gaofengzzz commentedSorry, forget to change stauts
Comment #10
Gaofengzzz commented