{"action":"created","issue":{"url":"https://api.github.com/repos/timber/timber/issues/1681","repository_url":"https://api.github.com/repos/timber/timber","labels_url":"https://api.github.com/repos/timber/timber/issues/1681/labels{/name}","comments_url":"https://api.github.com/repos/timber/timber/issues/1681/comments","events_url":"https://api.github.com/repos/timber/timber/issues/1681/events","html_url":"https://github.com/timber/timber/pull/1681","id":302033954,"number":1681,"title":"2.x Streamline method and filter names for getting meta data","user":{"login":"gchtr","id":2084481,"avatar_url":"https://avatars2.githubusercontent.com/u/2084481?v=4","gravatar_id":"","url":"https://api.github.com/users/gchtr","html_url":"https://github.com/gchtr","followers_url":"https://api.github.com/users/gchtr/followers","following_url":"https://api.github.com/users/gchtr/following{/other_user}","gists_url":"https://api.github.com/users/gchtr/gists{/gist_id}","starred_url":"https://api.github.com/users/gchtr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gchtr/subscriptions","organizations_url":"https://api.github.com/users/gchtr/orgs","repos_url":"https://api.github.com/users/gchtr/repos","events_url":"https://api.github.com/users/gchtr/events{/privacy}","received_events_url":"https://api.github.com/users/gchtr/received_events","type":"User","site_admin":false},"labels":[{"id":789213022,"url":"https://api.github.com/repos/timber/timber/labels/2.0","name":"2.0","color":"b7ff1c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-03T21:29:48Z","updated_at":"2018-03-05T02:56:05Z","closed_at":null,"author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/timber/timber/pulls/1681","html_url":"https://github.com/timber/timber/pull/1681","diff_url":"https://github.com/timber/timber/pull/1681.diff","patch_url":"https://github.com/timber/timber/pull/1681.patch"},"body":"**Ticket**: #1580, picking up on #1621\r\n\r\n## Issue\r\n\r\nStreamline filter and function names.\r\n\r\nConsider the following functions, which each have two newly added filters, adapted from their old (underscored) filter names:\r\n\r\n### Get all custom fields\r\n\r\n**Post::get_post_custom()**\r\n\r\n- `timber/post/pre_get_meta`\r\n- `timber/post/get_meta`\r\n\r\n**Term::get_term_meta**\r\n\r\n- `timber/term/meta`\r\n\r\n**User::get_custom()**\r\n\r\n- `timber/user/pre_get_meta`\r\n- `timber/user/get_meta`\r\n\r\n**Comment::get_meta_fields()**\r\n\r\n- `timber/comment/pre_get_meta_fields`\r\n- `timber/comment/get_meta_fields`\r\n\r\n### Get value for one custom field\r\n\r\n**Post::get_field()**\r\n\r\n- `timber/post/pre_get_meta_field`\r\n- `timber/post/get_meta_field`\r\n\r\n**Term::meta()**\r\n\r\n- `timber/term/meta/field`\r\n\r\n**User::meta()**\r\n\r\n- `timber/user/pre_get_meta_field`\r\n- `timber/user/get_meta_field`\r\n\r\n**Comment::get_meta_field()**\r\n\r\n- `timber/comment/pre_get_meta_field`\r\n- `timber/comment/get_meta_field`\r\n\r\n### What could be improved\r\n\r\n1. The functions practically all do the same, but they are called differently. We should streamline these. And, in addition, `Post::meta()` currently calls `Post::get_field()`. But couldn’t it be the other way around, that `get_field()` is an alias of `meta()`?\r\n2. The filter names are not streamlined as well. I think they should match the function names.\r\n\r\n## Solution\r\n\r\n### Streamline method names to get all custom field values\r\n\r\n- `Post::get_meta_values()`\r\n    - `timber/post/pre_get_meta_values`\r\n    - `timber/post/get_meta_values`\r\n- `Term::get_meta_values()`\r\n    - `timber/term/get_meta_values`\r\n- `User::get_meta_values()`\r\n    - `timber/user/pre_get_meta_values`\r\n    - `timber/user/get_meta_values`\r\n- `Comment::get_meta_values()`\r\n    - `timber/comment/pre_get_meta_values`\r\n    - `timber/comment/get_meta_values`\r\n\r\n### Streamline method names to get value for one custom field:\r\n\r\n- `Post::meta()`\r\n    - `timber/post/pre_meta`\r\n    - `timber/post/meta`\r\n- `Term::meta()`\r\n    - `timber/term/meta`\r\n- `User::meta()`\r\n    - `timber/user/pre_meta`\r\n    - `timber/user/meta`\r\n- `Comment::meta()`\r\n    - `timber/comment/pre_meta`\r\n    - `timber/comment/meta`\r\n\r\n### Deprecate namespaced filters\r\n\r\nWhere a a namespaced filter was already used (introduced in 0.21.x), I deprecated these as well.\r\n\r\n- `timber/term/meta` in `Term::get_meta_values`\r\n- `timber/term/meta/field` in `Term::meta`\r\n\r\nThe filter `timber/term/meta` in `Timber::get_meta_values` was removed instead of being deprecated through `apply_filters_deprecated`, because there’s now a filter `timber/term/meta` in `Timber::meta()`. This might lead to weird behavior where `timber/term/meta` is still used in a theme.\r\n\r\n### Improve DocBlocks\r\n\r\n- Added summary, description and descriptions for parameter and return values for the `meta()` methods.\r\n\r\n### Deprecation warnings\r\n\r\nAdded calls to `Helper::deprecated()` in the following deprecated methods:\r\n\r\n- `Post::get_field()`\r\n- `Term::get_meta_field()`\r\n- `User::get_meta_field()`\r\n- `User::get_meta()`\r\n- `Comment::get_meta_field()`\r\n\r\n## Testing\r\n\r\n- I updated tests where they were failing.\r\n- There’s an error in `TestTimberPost::testPostMetaMetaException`, but I’m not really sure what the test is supposed to be doing.\r\n- Do we need to write new tests for something that’s changed here?\r\n"},"comment":{"url":"https://api.github.com/repos/timber/timber/issues/comments/370296093","html_url":"https://github.com/timber/timber/pull/1681#issuecomment-370296093","issue_url":"https://api.github.com/repos/timber/timber/issues/1681","id":370296093,"user":{"login":"jarednova","id":1298086,"avatar_url":"https://avatars1.githubusercontent.com/u/1298086?v=4","gravatar_id":"","url":"https://api.github.com/users/jarednova","html_url":"https://github.com/jarednova","followers_url":"https://api.github.com/users/jarednova/followers","following_url":"https://api.github.com/users/jarednova/following{/other_user}","gists_url":"https://api.github.com/users/jarednova/gists{/gist_id}","starred_url":"https://api.github.com/users/jarednova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jarednova/subscriptions","organizations_url":"https://api.github.com/users/jarednova/orgs","repos_url":"https://api.github.com/users/jarednova/repos","events_url":"https://api.github.com/users/jarednova/events{/privacy}","received_events_url":"https://api.github.com/users/jarednova/received_events","type":"User","site_admin":false},"created_at":"2018-03-05T02:56:05Z","updated_at":"2018-03-05T02:56:05Z","author_association":"OWNER","body":"@gchtr thanks for the fixes and write-up. The reason for that one weird failing test is for when someone has done something silly like name a custom field (the key that gets stored in the `wp_postmeta` table) as simply \"meta\" — how to best make it \"fail gracefully\"?\r\n\r\nThis extra catch/test provides the expected behavior ...\r\n\r\n```\r\nFoo {{ post.meta }} // Foo\r\nupdate_post_meta($post_id, 'meta', 'bar');\r\nFoo {{ post.meta }} // Foo bar\r\n```\r\n\r\n... but I can also imagine how a \"loud failure\" would be more helpful here (and also avoid unforeseen consequences and extra cruft in the codebase). \r\n\r\nI'm honestly torn on how to best handle. Do you have an impulse one way or the other (and do I make sense here)"}}
{"actor":{"display_login":"jarednova"}}