Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Commit

Permalink
fix(transients): never expire them and set hit or miss when id is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
DAreRodz committed Nov 14, 2018
1 parent d7a3e8f commit b4095f2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions wp-pwa.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ function get_attachment_id( $url ) {
}
}

set_transient( $transient_name, $attachment_id, DAY_IN_SECONDS );
set_transient( $transient_name, $attachment_id, 0 ); // never expires
$this->update_image_id_transient_keys( $transient_name );
}

Expand Down Expand Up @@ -333,9 +333,9 @@ function add_image_ids($data, $post_type, $request) {
$result = $this->get_attachment_id($image->src);
$id = $result['id'];
$miss = $result['miss'];
$image->setAttribute('data-attachment-id-source', 'wp-query-transient-' . ($miss ? 'miss' : 'hit'));
if ($id !== 0) {
$image->setAttribute('data-attachment-id', $id);
$image->setAttribute('data-attachment-id-source', 'wp-query-transient-' . ($miss ? 'miss' : 'hit'));
$imgIds[] = intval($id);
}
}
Expand All @@ -357,9 +357,9 @@ function add_image_ids($data, $post_type, $request) {
'embeddable' => true,
)
));
$html = $dom->save();
if ($html) $data->data['content']['rendered'] = $html;
}
$html = $dom->save();
if ($html) $data->data['content']['rendered'] = $html;
$data->data['content_media'] = $imgIds;
return $data;
}
Expand Down

0 comments on commit b4095f2

Please sign in to comment.