From 2e44146b34d23f1b1a1ff7b74dad1572af4ebdd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Erkkil=C3=A4?= Date: Tue, 24 Sep 2024 16:08:52 +0300 Subject: [PATCH] empty check --- CHANGELOG.md | 3 +++ src/API.php | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e49b50..61ccfba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed +- Fixes a problem during indexing missing posts when custom posts are not actually posts. + ## [2.0.11] - 2024-09-06 ### Fixed diff --git a/src/API.php b/src/API.php index 4581485..67c1d7b 100644 --- a/src/API.php +++ b/src/API.php @@ -20,7 +20,13 @@ function get_post( $post_id ) { $index = Settings::get( 'posts_index' ); - $doc_id = PostIndex::get_document_id( \get_post( $post_id ), $post_id ); + $post = \get_post( $post_id ); + + if ( empty( $post ) ) { + return null; + } + + $doc_id = PostIndex::get_document_id( $post, $post_id ); $result = $client->raw_command( 'HGETALL', [ $index . ':' . $doc_id ] );