{"action":"created","issue":{"url":"https://api.github.com/repos/wp-e-commerce/WP-e-Commerce/issues/1918","labels_url":"https://api.github.com/repos/wp-e-commerce/WP-e-Commerce/issues/1918/labels{/name}","comments_url":"https://api.github.com/repos/wp-e-commerce/WP-e-Commerce/issues/1918/comments","events_url":"https://api.github.com/repos/wp-e-commerce/WP-e-Commerce/issues/1918/events","html_url":"https://github.com/wp-e-commerce/WP-e-Commerce/issues/1918","id":90053800,"number":1918,"title":"Cached meta needs invalidating when changed.","user":{"login":"benhuson","id":765285,"avatar_url":"https://avatars.githubusercontent.com/u/765285?v=3","gravatar_id":"","url":"https://api.github.com/users/benhuson","html_url":"https://github.com/benhuson","followers_url":"https://api.github.com/users/benhuson/followers","following_url":"https://api.github.com/users/benhuson/following{/other_user}","gists_url":"https://api.github.com/users/benhuson/gists{/gist_id}","starred_url":"https://api.github.com/users/benhuson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benhuson/subscriptions","organizations_url":"https://api.github.com/users/benhuson/orgs","repos_url":"https://api.github.com/users/benhuson/repos","events_url":"https://api.github.com/users/benhuson/events{/privacy}","received_events_url":"https://api.github.com/users/benhuson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"benhuson","id":765285,"avatar_url":"https://avatars.githubusercontent.com/u/765285?v=3","gravatar_id":"","url":"https://api.github.com/users/benhuson","html_url":"https://github.com/benhuson","followers_url":"https://api.github.com/users/benhuson/followers","following_url":"https://api.github.com/users/benhuson/following{/other_user}","gists_url":"https://api.github.com/users/benhuson/gists{/gist_id}","starred_url":"https://api.github.com/users/benhuson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benhuson/subscriptions","organizations_url":"https://api.github.com/users/benhuson/orgs","repos_url":"https://api.github.com/users/benhuson/repos","events_url":"https://api.github.com/users/benhuson/events{/privacy}","received_events_url":"https://api.github.com/users/benhuson/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/wp-e-commerce/WP-e-Commerce/milestones/7","html_url":"https://github.com/wp-e-commerce/WP-e-Commerce/milestones/4.0","labels_url":"https://api.github.com/repos/wp-e-commerce/WP-e-Commerce/milestones/7/labels","id":234069,"number":7,"title":"4.0","description":"Primary focus for this release:\r\n\r\n## Major\r\n##### (Headline changes that would be sad to punt.)\r\n* Integrate new theme engine (#848, #1600, #1263)\r\n* Add Package/Grouped Product Type (#386)\r\n* Make Store Reports and extensible API (#462)\r\n* Recurring Sales API (#83)\r\n\r\n## Minor\r\n##### (General improvements, completed iterations on prior enhancements, etc.  Avoid punting if possible)\r\n* Improved Stock Level handling (#720)\r\n* Add an upgraded_from option (#1569)\r\n\r\n## Iterative\r\n##### (Feature-as-plugins, minor enhancements.  happy to punt.)\r\n* Stats-API improvements (#739)\r\n* REST API (#406)","creator":{"login":"JustinSainton","id":1168754,"avatar_url":"https://avatars.githubusercontent.com/u/1168754?v=3","gravatar_id":"","url":"https://api.github.com/users/JustinSainton","html_url":"https://github.com/JustinSainton","followers_url":"https://api.github.com/users/JustinSainton/followers","following_url":"https://api.github.com/users/JustinSainton/following{/other_user}","gists_url":"https://api.github.com/users/JustinSainton/gists{/gist_id}","starred_url":"https://api.github.com/users/JustinSainton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JustinSainton/subscriptions","organizations_url":"https://api.github.com/users/JustinSainton/orgs","repos_url":"https://api.github.com/users/JustinSainton/repos","events_url":"https://api.github.com/users/JustinSainton/events{/privacy}","received_events_url":"https://api.github.com/users/JustinSainton/received_events","type":"User","site_admin":false},"open_issues":25,"closed_issues":73,"state":"open","created_at":"2012-12-22T23:13:36Z","updated_at":"2015-06-23T06:32:49Z","due_on":"2014-12-29T08:00:00Z","closed_at":null},"comments":2,"created_at":"2015-06-22T09:34:18Z","updated_at":"2015-06-23T06:48:58Z","closed_at":null,"body":"Just need to re-check the implications of #1389 and #1894\r\n\r\nNeed to check that when category and country/region meta is changed we invalid the cache.\r\n\r\nHopefully these will be using some sort of wpsc_update_meta function/API where we can add in functionality to delete meta cache.\r\n\r\nIf not, we need to add one."},"comment":{"url":"https://api.github.com/repos/wp-e-commerce/WP-e-Commerce/issues/comments/114380277","html_url":"https://github.com/wp-e-commerce/WP-e-Commerce/issues/1918#issuecomment-114380277","issue_url":"https://api.github.com/repos/wp-e-commerce/WP-e-Commerce/issues/1918","id":114380277,"user":{"login":"benhuson","id":765285,"avatar_url":"https://avatars.githubusercontent.com/u/765285?v=3","gravatar_id":"","url":"https://api.github.com/users/benhuson","html_url":"https://github.com/benhuson","followers_url":"https://api.github.com/users/benhuson/followers","following_url":"https://api.github.com/users/benhuson/following{/other_user}","gists_url":"https://api.github.com/users/benhuson/gists{/gist_id}","starred_url":"https://api.github.com/users/benhuson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benhuson/subscriptions","organizations_url":"https://api.github.com/users/benhuson/orgs","repos_url":"https://api.github.com/users/benhuson/repos","events_url":"https://api.github.com/users/benhuson/events{/privacy}","received_events_url":"https://api.github.com/users/benhuson/received_events","type":"User","site_admin":false},"created_at":"2015-06-23T06:48:58Z","updated_at":"2015-06-23T06:48:58Z","body":"The issue is that when using get_terms() you can specify a fields argument to just return certain term fields. The default is to return term objects but if you specify anything other than 'all' then an array of values will be returned instead.\r\n\r\nI was assuming $terms were always term objects when going through that filter but that's not the case.\r\n\r\n@JustinSainton Your commit fixes the issue but actually bypasses the caching functionality which helps reduce the amount of DB requests.\r\n\r\nThe `wpsc_update_meta_cache( 'wpsc_category', $term_ids )` needs to happen before looping through the terms as this updates the meta cache (pre-fetches the meta in bulk and caches it) meaning that the subsequent calls to `wpsc_get_meta()` in the loop do not hit the database.\r\n\r\nIn my PR above I check that the fields arg is either not set or is set to 'all' before doing anything.\r\n\r\nIn my testing displaying 10 products on the product admin screen with 24 categories, the above code saves 20 DB queries."}}