Looks like this is an issue again.
So I have a hook that adds an action to cn_post_process_update-entry
In the middle of the function it links to I have this code:
<
pre>public static function saveMarker( $entry, $update = false ) {
global $connections, $wp_rewrite, $wpdb;
$entryID = (int) $entry->getId();
$entry->set( $entryID );
echo "<pre>";
print_r( $_POST );
print_r( $connections->retrieve->entryCategories( $entryID ) );
var_dump($entry);
$categories = $entry->getCategory();
print_r($categories);
die();
...
}
The following is what I get. Note the Post info is different from what I get with all the rest. It was working, but now it’s showing the old category information again, unless I update the entry twice.
// _POST
Array
(
[cn-action] => update_entry
[update] => Update
[entry_category] => Array
(
[0] => 9 // Category set to 9 and 10
[1] => 10
)
...
// Output of entryCategories
Array
(
[0] => stdClass Object
(
[term_id] => 11 // still says 11, not 9 and 10
[name] => Markets
[term_taxonomy_id] => 11
[taxonomy] => category
...
)
)
object(cnEntry)#62 (52) {
["id":"cnEntry":private]=> int(3)
["categories":"cnEntry":private]=> array(1) {
[0]=> object(stdClass)#60 (9) {
["term_id"]=> string(2) "11"
["name"]=> string(7) "Markets"
...
// $entry->getCategory(); is the same as above.
I think I know the issue. Within the class.retrieve.php, the function entryCategories: you are checking for a cache of the sql to be run. It must have already run previously and then the record is updated. At the time of the hook, I’m now getting the cached results, not the new results. I think I can come up with a hack that should work in the meantime. But if anyone is using hooks, this will need to be addressed.
I’d suggest that when you store the results and the SQL, also include a list of tables. When an update occurs, scan the cached list for the tables that were affected and remove the cached results that used those tables. This would ensure that on an update, the code will always fetch fresh results instead of cached ones.