← All changes
|
modules/global-classes/global-classes-relations.php
+10
-8
4.1.0-dev3
→
4.2.4
View file →
| @@ -343,15 +343,9 @@ | ||
| 343 | 343 | private function get_document_for_post( int $post_id ): ?Document { |
| 344 | 344 | $documents = Plugin::$instance->documents; |
| 345 | 345 | |
| 346 | 346 | if ( ! $this->is_preview() ) { |
| 347 | - $document = $documents->get( $post_id ); | |
| 348 | - | |
| 349 | - if ( ! $document ) { | |
| 350 | - return null; | |
| 351 | - } | |
| 352 | - | |
| 353 | - return $document ?? null; | |
| 347 | + return $this->get_document_or_null( $documents->get( $post_id ) ); | |
| 354 | 348 | } |
| 355 | 349 | |
| 356 | 350 | $document = $documents->get_doc_or_auto_save( $post_id, get_current_user_id() ); |
| 357 | 351 | |
| @@ -358,7 +352,15 @@ | ||
| 358 | 352 | if ( ! $document ) { |
| 359 | 353 | $document = $documents->get( $post_id ); |
| 360 | 354 | } |
| 361 | 355 | |
| 362 | - return $document ?? null; | |
| 356 | + return $this->get_document_or_null( $document ); | |
| 357 | + } | |
| 358 | + | |
| 359 | + private function get_document_or_null( $document ): ?Document { | |
| 360 | + if ( empty( $document ) ) { | |
| 361 | + return null; | |
| 362 | + } | |
| 363 | + | |
| 364 | + return $document; | |
| 363 | 365 | } |
| 364 | 366 | } |