Title: Defensive Programming
Last modified: March 13, 2021

---

# Defensive Programming

 *  Resolved [rolfhuiber](https://wordpress.org/support/users/rolfhuiber/)
 * (@rolfhuiber)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/defensive-programming/)
 * We are running WordPress in debug mode, so when there are problems we can investigate
   easier.
 * Yoast is always producing a lot of entries in debug.log.
    With every Yoast release
   something different. Please use defensive programming technics.
 * Trying to get property ‘expiry_date’ of non-object in …/vendor/yoast/wordpress-
   seo/inc/class-addon-manager.php on line 337
    Trying to get property ‘product’
   Trying to get property ‘version’ Trying to get property ‘store_url’ Trying to
   get property ‘last_updated’ Trying to get property ‘product’ Trying to get property‘
   changelog’

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [Priscilla Chapman](https://wordpress.org/support/users/priscillamc/)
 * (@priscillamc)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/defensive-programming/#post-14178084)
 * Hi [@rolfhuiber](https://wordpress.org/support/users/rolfhuiber/),
 * Sorry to hear that you’re seeing an error related to Yoast SEO. We’re not receiving
   similar reports from other users, so we’d like to get more information about 
   your site.
 * Can you give us more details about how we can reproduce the problem?
 *  Thread Starter [rolfhuiber](https://wordpress.org/support/users/rolfhuiber/)
 * (@rolfhuiber)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/defensive-programming/#post-14178897)
 * Main is, that the error is produced in the Yoast code because it tries to access
   an object which does not exist. Defensive programming would check if the reference
   is a valid object before accessing it attributes/members. Yoast accesses an attribute
   from an non existing object, this generates a PHP error which this gets protocolized
   as we run WordPress in debug mode.
 * When the object is mastered in your own code, and you can be sure the object 
   exists, you might relax defensive programming.
 * When on the other hand objects are accessed from other plugins (maybe through
   callbacks from plugins) you have to check the validity of the references received.
   
   For example (as I do not know what Yoast tries to retrieve from the error messages),
   when some code accesses a WooCommerce order object, but billing is not provided,
   and would try to access the address of the billing structure which is non-existing(
   null) it will throw an error. That this billing object is non-existing is a decision
   from the plugin, the receiving code (Yoast) has to deal with such situations.
 * I might have reported this already earlier for Yoast or another plugin who generated
   a lot of errors, advises for turning of debug mode are not helpful.
 *  [Priscilla Chapman](https://wordpress.org/support/users/priscillamc/)
 * (@priscillamc)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/defensive-programming/#post-14179875)
 * Hi [@rolfhuiber](https://wordpress.org/support/users/rolfhuiber/),
 * Thanks for the response and for more details. We understand that you’re asking
   for a coding change that will prevent future errors related to missing billing
   objects.
 * This issue you raised isn’t something that we’re not able to resolve for you 
   on this support forum, so we recommend [creating a new feature request or bug report](https://github.com/Yoast/wordpress-seo/issues/new/choose)
   for our developers. This will allow you to discuss this directly with the development
   team and receive notifications about any changes.
 * We’re actively using bug tracking for Yoast SEO on our GitHub repository. You
   can choose to make a general coding practice feature request or provide the steps
   to reproduce a specific error in a bug report.
 * This does require a GitHub account to create a new issue. If you’d like us to
   create the issue for you, please let us know.
 *  Thread Starter [rolfhuiber](https://wordpress.org/support/users/rolfhuiber/)
 * (@rolfhuiber)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/defensive-programming/#post-14180285)
 * Hello Priscilla
    When it is the way to go, to inform your developers, please 
   create an issue. Rolf
 *  [Pcosta88](https://wordpress.org/support/users/pcosta88/)
 * (@pcosta88)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/defensive-programming/#post-14184157)
 * Hi Rolf,
 * To clarify regarding the issue you are having.
 * 1. Are all your non-Yoast plugins and themes also updated?
 * 2. Can you confirm you are using WordPress 5.7? You can check by clicking on 
   the W in the top left and selecting About. If you need to update, please check
   with your host provider. Please know that if you are using an older version of
   WordPress Core you may experience unexpected behavior with Yoast. This guide 
   explains more: https://yoast.com/why-we-dont-support-old-wordpress-versions/.
 * 3. We had another recent release. Can you confirm you are using the most recent
   Yoast SEO, v15.9.2? If you update, does the issue resolve?
 * 4. Finally we have seen some edge cases where an upgrade to a new version didn’t
   happen correctly and those notices were generated. If the plugin is updated please
   re-install a new version of the plugin and see if the issue resolves. You may
   need to use File Transfer Protocol (FTP) to install a new copy of the plugin 
   and overwrite all the data.
 * When you do that you are not expected to lose your SEO data or settings. Though
   we do suggest making a backup. Your host provider can help with this.
 * To learn more about how to re-install the plug using FTP please use this guide:
   [https://yoast.com/help/how-can-i-update-my-free-plugin/#ftp](https://yoast.com/help/how-can-i-update-my-free-plugin/#ftp)
 *  Thread Starter [rolfhuiber](https://wordpress.org/support/users/rolfhuiber/)
 * (@rolfhuiber)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/defensive-programming/#post-14210692)
 * From your answer I read, to solve the problem, is that the problem is caused 
   from WordPress and/or a plugin, and an update would maybe fix the issue.
 * Is it correct, when I conclude, that you are reading data, which is produced 
   by another source, into your plugin?
    Is it also true, that you don’t check the
   validity of the data read in to your plugin?
 *  [Priscilla Chapman](https://wordpress.org/support/users/priscillamc/)
 * (@priscillamc)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/defensive-programming/#post-14212317)
 * Hi [@rolfhuiber](https://wordpress.org/support/users/rolfhuiber/),
 * Since there has been a major version update after you reported the problem, we’d
   like to verify that the problem you’re seeing still exists.
 * Can you confirm that all your plugins and themes are updated and that the errors
   still appear if you reinstall the latest version of Yoast SEO?
 *  Thread Starter [rolfhuiber](https://wordpress.org/support/users/rolfhuiber/)
 * (@rolfhuiber)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/defensive-programming/#post-14275690)
 * Your update still produced errors.
    As you are only hoping other plugins or the
   core fixes something that it doesn’t generate failures in your plugin, I had 
   a look at your plugin and could fix the code to not produce errors anymore.
 * As you haven’t been very constructive in this issue and “defensive programming”
   is not part of your “programming vocabulary”, I do not expect any changes from
   you part, you can close the issue and mark it as “resolved”.
 *  Thread Starter [rolfhuiber](https://wordpress.org/support/users/rolfhuiber/)
 * (@rolfhuiber)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/defensive-programming/#post-14287255)
 * .

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Defensive Programming’ is closed to new replies.

 * ![](https://ps.w.org/wordpress-seo/assets/icon-256x256.gif?rev=3419908)
 * [Yoast SEO - Advanced SEO with real-time guidance and built-in AI](https://wordpress.org/plugins/wordpress-seo/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-seo/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-seo/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-seo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-seo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-seo/reviews/)

## Tags

 * [debugging](https://wordpress.org/support/topic-tag/debugging/)

 * 9 replies
 * 3 participants
 * Last reply from: [rolfhuiber](https://wordpress.org/support/users/rolfhuiber/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/defensive-programming/#post-14287255)
 * Status: resolved