Back to Community

Fixing Common PHP Notices and Warnings in Yoast Duplicate Post

39 threads Sep 10, 2025 PluginYoast duplicate post

Content

If you've enabled WordPress debugging, you might have noticed PHP notices or warnings related to the Yoast Duplicate Post plugin. These messages, while often not breaking your site, can clutter your debug logs and indicate underlying code issues. Based on community reports, here are the most common ones and how to address them.

Common Error: "Trying to get property of non-object"

This is one of the most frequently reported issues. You'll typically see it in your debug log referencing lines 123 and 149 in the duplicate-post-common.php file.

Notice: Trying to get property 'post_type' of non-object in .../duplicate-post/duplicate-post-common.php on line 123
Notice: Trying to get property 'post_type' of non-object in .../duplicate-post/duplicate-post-common.php on line 149

Why This Happens

This error occurs when the plugin tries to check if a post type is enabled for duplication, but the $post variable it's checking is either not defined or is not a valid post object. This can happen on certain admin pages that aren't related to posts (like settings pages for other plugins) or if a post ID in a URL parameter is invalid.

How to Fix It

The Yoast Duplicate Post team has acknowledged this issue. A permanent fix involves adding a conditional check to ensure the $post variable exists and is an object before trying to access its post_type property. This fix has been implemented in newer versions of the plugin.

Solution: Update the Plugin
The first and simplest step is to ensure you are running the latest version of Yoast Duplicate Post. The development team has addressed this specific notice in subsequent updates. Updating often resolves the issue immediately.

Other Common PHP Messages and Fixes

1. Strict Standards Warning (Assignment by Reference)

Strict Standards: Only variables should be assigned by reference in .../duplicate-post/duplicate-post-common.php on line 31

Cause: This is a code style warning triggered by PHP 5.4 and above, related to how a variable is assigned.
Fix: This was fixed in a plugin update. The line was changed from something like if ( !$post = &get_post( $id ) ) to if ( !$post = get_post( $id ) ). Updating the plugin resolves this.

2. Undefined Property Warning ($dp-rewrite-republish)

PHP Warning: Undefined property: stdClass::$dp-rewrite-republish in .../class-wp-posts-list-table.php on line 309

Cause: This can sometimes indicate a conflict with another plugin, such as the Groups plugin.
Fix: Check for plugin conflicts by deactivating other plugins one by one to identify the culprit. Also, ensure Duplicate Post is updated, as the team has released patches for similar issues in the past.

3. Fatal Error: in_array() Argument Must Be Array

PHP Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, bool given in .../admin-functions.php:149

Cause: A function tries to use the result of get_option() as an array, but the option sometimes returns false instead.
Fix: The code should be modified to provide a default array value if the option returns false. This was addressed in a plugin update.

General Troubleshooting Steps

  1. Update Everything: Always ensure you are using the latest version of WordPress, the Yoast Duplicate Post plugin, and your theme. Many of these notices are patched in subsequent releases.
  2. Check for Conflicts: Temporarily switch to a default WordPress theme (like Twenty Twenty-Four) and disable all other plugins. If the notices disappear, reactivate your themes and plugins one by one to find the source of the conflict.
  3. Review Your Debug Log: The specific file and line number in the error message are your best clues for finding a solution or checking if it has been patched.

Most of these warnings are minor code issues that don't affect functionality but are best practice to fix. The Yoast Duplicate Post team has historically been responsive to these community-reported bugs and often includes fixes in regular updates.

Related Support Threads Support