PressForward is a free plugin that provides an editorial workflow for content aggregation and curation within the WordPress dashboard. It is designed for bloggers and editorial teams who wish to collect, discuss, and share content from a variety of sources on the open web.
GNU Affero General Public License v3.0
120
stars
22
forks
source link
Logic error causes some registered post meta not to be carried through transition steps #1128
The $level_check variable is overwritten each time we loop through the level property of the registered meta. So, for example, if level is [ 'post', 'feed' ], and you're looking at a meta key that is registered only for 'post', $level_check will be true the first time through the loop (which is correct) but false the second and last time. A given meta should be included if it matches any of the post types registered in the 'level' property, not just the last one. We need a break statement.
If, for a given meta item, the $level_check item is true, we return out of the function. This means that any other metas that are later in the registration list are not processed. Instead, we should continue.
When transitioning a nomination to a post,
Controllers\PF_Advancement::transition()
callsControllers\Metas->transition_post_meta()
. Since https://github.com/PressForward/pressforward/commit/3a1505edeb0e1d397d22c6a3b9a8f8eea33e876c, this method has had logic in place to prevent unneeded metadata from being copied over during the transition. See #798. But that logic, and the current descendant of that logic https://github.com/PressForward/pressforward/blob/0f8b03bc7c5a7d9d9ab9200fe2daa7c172cd40ca/Controllers/Metas.php#L99, has several errors in it:$level_check
variable is overwritten each time we loop through thelevel
property of the registered meta. So, for example, iflevel
is[ 'post', 'feed' ]
, and you're looking at a meta key that is registered only for'post'
,$level_check
will betrue
the first time through the loop (which is correct) butfalse
the second and last time. A given meta should be included if it matches any of the post types registered in the'level'
property, not just the last one. We need abreak
statement.$level_check
item is true, wereturn
out of the function. This means that any other metas that are later in the registration list are not processed. Instead, we shouldcontinue
.