Skip to content

Commit

Permalink
Fixed bug where $feed['author'] and $item['author'] were not merged c…
Browse files Browse the repository at this point in the history
…orrectly if either was not an array
  • Loading branch information
jackjamieson2 committed Jun 19, 2019
1 parent ac81a94 commit 52d1714
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions includes/class-yarns-microsub-parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@ public static function clean_post( $item, $feed ) {
* @param array $feed_author
*/
public static function clean_author( $item, $feed ) {
// If author is just a string, replace it with an array
// see https://github.com/jackjamieson2/yarns-microsub-server/issues/75
if (! is_array($item['author'])) {
$item['author'] = array(
'type' => 'card',
'name' => $item['author'],
);
}

if (! is_array($feed['author'])) {
$feed['author'] = array(
'type' => 'card',
'name' => $feed['author'],
);
}


if ( isset ( $feed['author'] ) && isset ( $item['author'] ) ) {
$item['author'] = array_merge( $feed['author'], $item['author'] );
}
Expand All @@ -139,14 +156,7 @@ public static function clean_author( $item, $feed ) {
}


// If author is just a string, replace it with an array
// see https://github.com/jackjamieson2/yarns-microsub-server/issues/75
if (! is_array($item['author'])) {
$item['author'] = array(
'type' => 'card',
'name' => $item['author'],
);
}


return $item['author'];

Expand Down

0 comments on commit 52d1714

Please sign in to comment.