You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When accessing a TimberPost's property directly, the return value is an array instead of the actual value for that meta field key:
post.some_custom_field // Should print out the raw `meta_value`
Actual behavior
But if for some reason that meta_key has a duplicate in the database, where post_id & meta_key are the same, the following happens:
post.some_custom_field // Returns an array of the raw field values
Steps to reproduce behavior
This issue is made visible quite easily by using the Wordpress Importer. Where even if I export posts using the tool, and import them into the same site, the Wordpress Importer will create duplicate rows in the wp_postmeta table, if the post already existed.
I understand that in some scenarios it would be helpful to save multiple rows of the same post_id + meta_key combination (revisions come to mind). But I don't see why would it ever be useful to spit out array into our template.
The issue goes away if you call post.get_field('some_custom_field'), but sometimes I don't want to get the formatting that get_field provides and I may just want to access the raw value of the field.
I think an ideal scenario would be that, if there are multiple possible values for a given post_id + meta_key combo, then simply assign the latest one of post.some_custom_field when calling TimberPost.
Running WP 4.7.5, PHP 5.6 & Timber 1.3.2
Installed the plugin by downloading from WP.org and replacing it on my file system.
The text was updated successfully, but these errors were encountered:
@felipearosemena does this bug still exists? I use WP importer quite often and saw this kind of behavior (thought - I always used php 7 and always used timber from composer).
Expected behavior
When accessing a TimberPost's property directly, the return value is an array instead of the actual value for that meta field key:
Actual behavior
But if for some reason that
meta_key
has a duplicate in the database, wherepost_id
&meta_key
are the same, the following happens:Steps to reproduce behavior
This issue is made visible quite easily by using the Wordpress Importer. Where even if I export posts using the tool, and import them into the same site, the Wordpress Importer will create duplicate rows in the
wp_postmeta
table, if the post already existed.I understand that in some scenarios it would be helpful to save multiple rows of the same
post_id
+meta_key
combination (revisions come to mind). But I don't see why would it ever be useful to spit outarray
into our template.The issue goes away if you call
post.get_field('some_custom_field')
, but sometimes I don't want to get the formatting thatget_field
provides and I may just want to access the raw value of the field.I think an ideal scenario would be that, if there are multiple possible values for a given
post_id
+meta_key
combo, then simply assign the latest one ofpost.some_custom_field
when callingTimberPost
.Running
WP 4.7.5
,PHP 5.6
&Timber 1.3.2
Installed the plugin by downloading from WP.org and replacing it on my file system.
The text was updated successfully, but these errors were encountered: