CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Managed entities not refreshed on cache clear
Pages: [1]

Author Topic: Managed entities not refreshed on cache clear  (Read 593 times)

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Managed entities not refreshed on cache clear
March 21, 2014, 02:33:31 am
Hey all,

According to the documentation the hook_civicrm_managed should be called whenever the cache is cleared, resulting in updating the entities.
However whenever I clear my cache on a local civicrm 4.3.5 installation nothing really seems to happend. It looks like that this hook is only called whenever an extension is installed.

Tim Otten has written a blog (https://civicrm.org/blogs/totten/api-and-art-installation) where he states
Quote
...The solution is hook_civicrm_managed. Whenever the CiviCRM cache is cleared, CiviCRM will invoke the hook and perform reconciliation:..

And in the hook documentation on the wiki (http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_managed)
Quote
This hook allows a module to declare a list of 'managed' entities using the CiviCRM API - a managed entity will be automatically inserted, updated, deactivated, and deleted in tandem with enabling, disabling, and uninstalling the module. The hook is called periodically during cache-clear operations.

What is periodically???? Is that some kind of randomness?
Developer at Edeveloper / CiviCoop

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Managed entities not refreshed on cache clear
March 21, 2014, 01:44:32 pm
A potential ambiguity -- Drupal has a cache layer, and Civi has a cache layer, and (based on some grepping) I don't think there's any integration between them. So to be more specific, any of these should flush the Civi cache:

CLI: drush cvapi system.flush
Web: /civicrm/menu/rebuild
Web: /civicrm/clearcache
PHP: civicrm_api('System', 'flush', array();
PHP: CRM_Core_Invoke::rebuildMenuAndCaches(...);

"Periodically" is basically (a) any of the above plus (b) upgrades and (c) any lifecycle events for modules/extensions (install/disable/uninstall/enable). The latter should be pretty solid for native modules/extensions; for CMS-specific modules/extensions, it's been tested manually (from time to time) but there's no automated testing.

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: Managed entities not refreshed on cache clear
March 23, 2014, 11:10:04 am
Tim,

Thanks for your answer. I have only tested the web and those doesn't seem to trigger the hook_civicrm_managed. So this looks like a bug in civicrm. Do you agree?
Developer at Edeveloper / CiviCoop

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Managed entities not refreshed on cache clear
March 24, 2014, 02:51:20 pm
It might help to know a little bit more about the situation -- for example, are you implementing hook_civicrm_managed directly or using civix's *.mgd.php variation? if you have a link to the code in question, that would be great.

When I try to clear using /civicrm/clearcache, it works -- like in this experiment:

1. Install Civi+CiviHR (b/c CiviHR relies on hook_managed to register reports)
2. Navigate to /civicrm/report/template/list?reset=1
3. Edit the descriptive text for the ReportTemplate in HRAbsence.mgd.php ( eg https://github.com/civicrm/civihr/blob/master/hrreport/CRM/HRReport/Form/Activity/HRAbsence.mgd.php )
4. Run /civicrm/clearcache
5. Reload /civicrm/report/template/list?reset=1 and observe that the description has changed.

Is it possible that there's some other problem at play? Maybe a problem with the specific API entity or use-case?

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: Managed entities not refreshed on cache clear
March 25, 2014, 01:12:35 am
Hey Tim,

I am using the civix .mgd option but I noticed that in a clear cache the civix function for managed entities isn't called.
My code is on github https://github.com/CiviCooP/org.civicoop.dgw.mutatieproces

Good to know that it should work :-) on a clear cache. I have to deep into it and find out what really causes the problem, the civi version is btw 4.3.5
Developer at Edeveloper / CiviCoop

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Managed entities not refreshed on cache clear

This forum was archived on 2017-11-26.