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) »
  • Joomla civicrm_post hook returns old value
Pages: [1]

Author Topic: Joomla civicrm_post hook returns old value  (Read 814 times)

Celos

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.1.x
  • CMS version: Joomla 2.5.x
  • MySQL version: 5.5.x
  • PHP version: 5.3.x
Joomla civicrm_post hook returns old value
June 29, 2012, 08:10:04 am
I'm trying to implement a hook that would trigger after an event has been saved. Since I don't want to recreate a whole bunch of code, I need to use the database entry rather than the referred object. However, when the hook is triggered, the Joomla database connector returns the old value instead of the newly set one. So if I change the name of the event from "foo" to "bar"

$db =& JFactory::getDBO();
$db->setQuery("SELECT ...");
$db->loadAssocList();

returns "foo". I've tested and the hook is triggering correctly (ie. the db has been updated) and doing it without the connector (mysql_connect etc) returns the expected result. This leads me to believe that there is some sort of caching going on. Is this the case? If so, is there a way to disable it?

The goal of this, by the way, is to immediately send out an updated ical feed.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Joomla civicrm_post hook returns old value
June 29, 2012, 08:48:44 am

there is no caching going on at the civicrm level with regard to insert/update

howeer since u r using two different mysql connectors (civi uses its own mysql connection), that might explain why u r seeing an older value?

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Celos

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.1.x
  • CMS version: Joomla 2.5.x
  • MySQL version: 5.5.x
  • PHP version: 5.3.x
Re: Joomla civicrm_post hook returns old value
June 29, 2012, 09:05:34 am
The thing is, I'm actually using the iCal feed provided by CiviEvent (which I assume is using the CiviCRM connector) and it's showing the old values.
Is there any reason why the feed wouldn't be updated as soon as the events are (caching there maybe)?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Joomla civicrm_post hook returns old value
June 29, 2012, 10:27:17 am

no pretty sure there is no caching in that layer either

not sure why/how u r seeing such things. can u try doing the same on demo. i.e. create an event and then retrieve the rss feed

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Celos

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.1.x
  • CMS version: Joomla 2.5.x
  • MySQL version: 5.5.x
  • PHP version: 5.3.x
Re: Joomla civicrm_post hook returns old value
June 30, 2012, 11:38:15 am
The feed shows fine if I check it manually after an update, so I can't really duplicate the issue on the demo. I modified a sample plugin to show the issue: it invokes the civicrm_post hook and when it's dealing with an event, it prints out the ical feed and dies. I uploaded it HERE.

edit: I updated the plugin, since I was lazy and didn't test it before uploading. Should work as intended now.
« Last Edit: July 02, 2012, 01:54:44 am by Celos »

Celos

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.1.x
  • CMS version: Joomla 2.5.x
  • MySQL version: 5.5.x
  • PHP version: 5.3.x
Re: Joomla civicrm_post hook returns old value
July 02, 2012, 07:10:53 am
Few more things:

It's not a race condition, as waiting or doing anything like that does not affect the issue.
Also,
Code: [Select]
file_get_contents(JURI::root().'index.php?option=com_civicrm&task=civicrm/event/ical&reset=1&list=1')provides old values, whereas
Code: [Select]
$x = new CRM_Event_Page_ICalendar();
$x->run();
provides correct ones.

edit: Forgot to mention, that I'm currently using civicrm_postProcess as a temporary fix, but I felt all dirty after I pushed that to a live website.
« Last Edit: July 02, 2012, 10:20:15 am by Celos »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Joomla civicrm_post hook returns old value

This forum was archived on 2017-11-26.