Title: Fatal error in PostModel.php when post object is null
Last modified: May 14, 2026

---

# Fatal error in PostModel.php when post object is null

 *  [Chiharu Ebisugawa](https://wordpress.org/support/users/piyoko/)
 * (@piyoko)
 * [1 day, 12 hours ago](https://wordpress.org/support/topic/fatal-error-in-postmodel-php-when-post-object-is-null/)
 * Hello PublishPress Future team,
   A critical error related to manual workflow triggers
   occurred in the previous version.I am reporting this because updating the plugin
   to the latest version did not resolve the issue.
 * Error message：
 *     ```wp-block-code
       Warning: Attempt to read property "ID" on null in
       /wp-content/plugins/post-expirator/src/Modules/Workflows/Models/PostModel.php on line 124
   
       Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, false given in
       /wp-content/plugins/post-expirator/src/Modules/Workflows/Models/PostModel.php:125
       ```
   
 * The issue appears to occur inside:
 *     ```wp-block-code
       public function getManuallyEnabledWorkflows(): array
       {
           $selectedWorkflowIds = get_post_meta(
               $this->post->ID,
               self::META_KEY_WORKFLOW_MANUALLY_TRIGGERED,
               false
           );
   
           $selectedWorkflowIds = array_map('intval', $selectedWorkflowIds);
   
           return $selectedWorkflowIds;
       }
       ```
   
 * The following is a report of improvements made in ChatGPT.
 * The issue appears to occur inside:
 * It seems `$this->post` can become `null` under some conditions, possibly due 
   to:
    - orphaned postmeta records
    - deleted posts
    - deleted workflows
    - inconsistent workflow metadata after plugin updates
    - REST API preload during block editor initialization
 * In this case, the plugin attempts to access:
 *     ```wp-block-code
       $this->post->ID
       ```
   
 * without validating that `$this->post` is a valid `WP_Post` object.
 * Additionally, `get_post_meta()` may return a non-array value, which later causes:
 *     ```wp-block-code
       array_map(): Argument #2 ($array) must be of type array, false given
       ```
   
 * Suggested fix:
 *     ```wp-block-code
       public function getManuallyEnabledWorkflows(): array
       {
           if (!$this->post || !isset($this->post->ID)) {
               return [];
           }
   
           $selectedWorkflowIds = get_post_meta(
               $this->post->ID,
               self::META_KEY_WORKFLOW_MANUALLY_TRIGGERED,
               false
           );
   
           if (!is_array($selectedWorkflowIds)) {
               return [];
           }
   
           return array_map('intval', $selectedWorkflowIds);
       }
       ```
   
 * I believe adding these guards would prevent fatal crashes caused by inconsistent
   metadata or deleted content.
 * This concludes the answers obtained through ChatGPT.
 * Thank you for your work on the plugin.

Viewing 1 replies (of 1 total)

 *  Plugin Support [Riza Prihananto](https://wordpress.org/support/users/rizaprihananto/)
 * (@rizaprihananto)
 * [1 day, 2 hours ago](https://wordpress.org/support/topic/fatal-error-in-postmodel-php-when-post-object-is-null/#post-18907856)
 * Hi [@piyoko](https://wordpress.org/support/users/piyoko/) , 
   Thank you for addressing
   your concern regarding this. Let me share this to our developer for the insight.
   Your feedback means a lot to us. If you have another concern, feel free to reply
   to this message.

Viewing 1 replies (of 1 total)

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ffatal-error-in-postmodel-php-when-post-object-is-null%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/post-expirator/assets/icon-256x256.png?rev=3118683)
 * [Schedule Post Changes With PublishPress Future: Unpublish, Delete, Change Status, Trash, Change Categories](https://wordpress.org/plugins/post-expirator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-expirator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-expirator/)
 * [Active Topics](https://wordpress.org/support/plugin/post-expirator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-expirator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-expirator/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Riza Prihananto](https://wordpress.org/support/users/rizaprihananto/)
 * Last activity: [1 day, 2 hours ago](https://wordpress.org/support/topic/fatal-error-in-postmodel-php-when-post-object-is-null/#post-18907856)
 * Status: not resolved