• We are having issues with these warnings for months. How can I resolve this?

    PHP Warning: Attempt to read property “post_modified_gmt” on null

    PHP Warning: Attempt to read property “post_date” on null in

    PHP Warning: Attempt to read property “post_date_gmt” on null

    …/public_html/wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-product-categories-controller.php o

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 23 total)
  • Plugin Support Frank Remmy (woo-hc)

    (@frankremmy)

    Hi @kirstinv,

    Sorry to hear this has been going on for months — let’s get it sorted!

    These warnings are coming from WooCommerce’s REST API product categories controller, which tries to read the modification date of the most recent post in each category. When a product category has no products assigned to it, that query returns null and PHP 8.x throws these warnings rather than handling it silently.

    Have you noticed any functionality issues alongside these warnings, or are they just appearing in the logs?

    A few things to try:

    • Go to Products → Categories and look for any categories with 0 products. Either assign products to them or delete them if they’re no longer needed.
    • Go to WooCommerce → Status → Tools and run “Verify base database tables” and “Update database”. This can fix any missing or corrupted term/post associations.
    • Could you paste your system report at https://pastebin.com and share the link? Go to WooCommerce → Status → Get system report. That will help us confirm whether there’s also a known bug in your specific version that’s already been patched.

    Looking forward to your response!

    Thread Starter kirstinv

    (@kirstinv)

    Hi Frank,

    Thank you for your quick response:)
    I did the first two steps but the php warnings are still showing.

    Can I paste the system report also here?

    Thread Starter kirstinv

    (@kirstinv)

    I forget to mention that we haven’t duplicated products into Dutch therefor all product categories in the second language are empty.. Does that matter?

    Plugin Support shahzeen(woo-hc)

    (@shahzeenfarooq)

    Hi there!

    Thank you for the update. The System Status Report contains a large amount of information, and forum moderators may remove messages that include too much content directly in the thread.

    That is why we recommend sharing the System Status Report using Pastebin and then providing the generated link here.

    I forget to mention that we haven’t duplicated products into Dutch therefor all product categories in the second language are empty.. Does that matter?

    Yes, that could definitely be related.

    If the Dutch product categories exist but do not contain any translated or assigned products, WooCommerce or a related multilingual plugin may still attempt to access linked product data through the REST API, which can sometimes result in warnings like the ones you shared when the expected post object is missing or empty.

    To help confirm this, could you please let us know:

    • Which multilingual plugin you are using (for example WPML, Polylang, etc.)
    • Whether the warnings stop if the second language is temporarily disabled
    • Whether all WooCommerce-related plugins are fully updated

    You could also try creating or syncing a few translated products in Dutch and then check if the warnings continue appearing afterward.

    Thread Starter kirstinv

    (@kirstinv)

    Hi,

    Hereby the status report https://pastebin.com/gyPFybL0

    We use WPML. I deactivated all plugins related but the PHP Warnings still show up. All plugins are updated. So it is not solved yet, please advise.

    Are these huge amounts of php warnings also the cause that in Directadmin my Resource usages always says that we have reached the limit?

    Plugin Support shahzeen(woo-hc)

    (@shahzeenfarooq)

    Hi there!

    Thank you for the update. I have checked the system status report and everything is appearing fine on my end.

    I have tried to replicate the issue, but I’m not able to reproduce it. To assist you further, could you please confirm if there are any specific steps required to trigger this error? For example, have you noticed whether it happens when visiting the product category page, editing a product, or performing any other specific action?

    You can create the staging site using your hosting provider’s built-in staging tool (if available), or you can use the following plugin:
    https://ww.wp.xz.cn/plugins/wp-staging/

    Once done, please head over to WooCommerce → Status → Tools and do the following:

    • WooCommerce transients – Clear
    • Expired transients – Clear
    • Clear template cache – Clear
    • Capabilities – Reset Capabilities
    • Regenerate product lookup tables

    Once done try to replicate the issue again and see if you still face the same issue.

    Are these huge amounts of php warnings also the cause that in Directadmin my Resource usages always says that we have reached the limit?

    Yes, a large volume of repeated PHP warnings can contribute to high server resource usage, especially if they are being generated continuously in the background.

    Also, could you please confirm whether these warnings are appearing directly in the WordPress dashboard/front-end, or are they only appearing in the PHP error logs?

    Thread Starter kirstinv

    (@kirstinv)

    https://web0088.zxcs.nl:2222/CMD_SHOW_LOG?domain=hetfaireoosten.nl&type=error&lines=100

    I don’t know exactly what triggers it but after some minutes it shows up in DirectAdmin Web Error Logs. See the link provided. I started investigating it since we received a lot of “error establishing a database connection”.

    All the above mentioned steps I did already but doesn’t solve the issue either.

    Plugin Support Frank Remmy (woo-hc)

    (@frankremmy)

    Hi @kirstinv,

    Thanks for the update!

    While we’re unable to view the DirectAdmin login, I see what you mean.

    Yes, the volume of PHP warnings is very likely contributing to your resource limit issues and the database connection errors. They’re all connected.

    Based on everything shared, the root cause is that WooCommerce’s REST API product categories controller is trying to read the modification date of the most recent post in each category. Your empty Dutch product categories (products not yet translated to Dutch) have no posts assigned, so that query returns null and PHP throws the warning. Multiply this across potentially hundreds of API calls and it explains the resource exhaustion.

    The most direct fix is to either:

    Option 1: Assign at least one product to each Dutch category. Even a placeholder product in each Dutch category would give the query something to return, stopping the warnings immediately.

    Option 2: If you don’t need the Dutch category structure yet, removing the empty Dutch categories from WPML’s translation would stop the REST API from querying them.

    Given that this is causing database connection errors and resource exhaustion, we’d recommend treating this as urgent and trying Option 1 or 2 as the quickest path to resolution.

    Let us know how it goes!

    Thread Starter kirstinv

    (@kirstinv)

    Thanks for your quick reply. But as I mentioned it doesn’t seem related to the second language since as I wrote when all WPML plugins are deactivated the issue still appears.

    I also also did read related topics as this one https://ww.wp.xz.cn/support/topic/php-warnings-related-to-woocommerce-rest-api-in-error-log/. They mention a work around for this php waring “I’ve added additional conditional statments into my custom code, and the warrnings are gone.” Can you maybe advise how to do this?

    Plugin Support LovingBro (woo-hc)

    (@lovingbro)

    Hi @kirstinv,

    I understand why that caught your attention, and thanks for sharing the related thread as well.

    In the topic you mentioned, the warnings were ultimately caused by custom code running on the site. The user later confirmed that after adding additional conditional checks into that custom code, the warnings stopped appearing.

    At the moment, we cannot confirm that the same applies to your site without first checking whether there are any active customizations interacting with WooCommerce REST API endpoints or product category queries.

    Could you please let us know if you currently have any custom code active on the site, for example:
    – Custom snippets added via Code Snippets plugin
    – Custom functions added in functions.php
    – Theme customizations
    – Custom WooCommerce REST API integrations
    – Third party scripts or plugins that modify product/category queries

    If possible, please share the relevant custom code snippets using https://pastebin.com, https://quickforget.com, or https://gist.github.com so we can review whether additional conditional checks may be needed there as well.

    Thread Starter kirstinv

    (@kirstinv)

    Ok yes of course:)

    I only found this one below in the functions.php which might could be relevant. But I don’t think so since this code has been for years already.


    add_action(‘woocommerce_archive_description’, ‘custom_archive_description’, 2 );
    function custom_archive_description(){
    if( is_product_category() ) :
    remove_action(‘woocommerce_archive_description’, ‘woocommerce_taxonomy_archive_description’, 10 );
    add_action( ‘woocommerce_after_main_content’, ‘woocommerce_taxonomy_archive_description’, 5 );
    endif;
    }

    Could it otherwise have something to do when cleaning up the database maybe some post data/terms/taxonomy terms accidentally deleted?

    Thread Starter kirstinv

    (@kirstinv)

    I might used these below but I’m not sure since it’s been a long time now that we’re having the issue. I have no clue if this could be related..

    SELECT * FROM wp_postmeta WHERE meta_value=” OR meta_value IS NULL

    DELETE FROM wp_postmeta WHERE meta_value=” OR meta_value IS NULL

    SELECT * FROM wp_postmeta WHERE meta_value REGEXP ‘^[0]$’;

    DELETE FROM wp_postmeta WHERE meta_value REGEXP ‘^[0]$’;

    Plugin Support shahzeen(woo-hc)

    (@shahzeenfarooq)

    Hi there!

    Thank you for update. You have done some excellent troubleshooting here. You are completely right to doubt the functions.php snippet that code simply hooks into frontend display actions and wouldn’t cause these REST API null errors.

    Your suspicion about past database cleanup queries is highly likely to be the root cause. Here is exactly what is happening and how we can fix it.

    The WooCommerce REST API controller is trying to fetch a product category, but when it looks up the associated database records to check its modification dates (post_modified_gmt), it is encountering a null object instead of a valid post or term relationship.

    When you ran the query to delete meta_value REGEXP '^[0]$', you likely inadvertently stripped out critical relationship mappings or orphaned specific attachment/thumbnail IDs that WooCommerce relies on when compiling category data for the REST API.

    Here are a few ways you can write this, depending on how formal you want to be.

    Could you please go to WooCommerce > Status > Tools and run the following options
    1. Recount terms
    2. Verify base database tables

    If you still face the same issue, please go to your WordPress Dashboard > Products > Categories and check if any categories are missing thumbnails. If they are, please add thumbnails to them and see if that fixes the issue.

    Let us know what you find.

    Thread Starter kirstinv

    (@kirstinv)

    Thank you for your explanation. To be honest I tried all tools already several times in the past few months. Even cleaned up any plug-in which isn’t necessary to keep the site running..

    We never had any images added to subcategories and no thumbnails to the parent categories and never had issues before (I started cleaning up the database:)

    Is it really important that there are thumbnails attached to all product categories?

    Plugin Support shahzeen(woo-hc)

    (@shahzeenfarooq)

    Hi there!

    Thank you for confirming that! You are completely right: by default, it is absolutely not necessary to have thumbnails attached to your categories or subcategories. If you prefer not to use images for them, you don’t need to add them.

    The only reason this is causing an error now is that the database cleanup query left behind “ghost” references. WooCommerce still thinks an image should be there, but the actual image record is missing.

    Since the basic tools didn’t clear those deep database references, let’s try a clean re-installation to see if it flushes out the broken code links. Please try these steps on your staging site first to protect your live data:

    1. Deactivate Other Plugins: Temporarily deactivate all plugins except for WooCommerce to rule out any lingering plugin caching.
    2. Reinstall WooCommerce: Go to Plugins > Installed Plugins, deactivate WooCommerce, and delete it. Then, go to Add New and reinstall a fresh copy of WooCommerce. (Don’t worry, deleting the plugin folder does not delete your products or orders, as those are stored safely in a separate part of your database).
    3. Check the Logs: After reinstalling, check if the warnings still generate when you navigate the dashboard or trigger your syncs.

    If you have already tried a fresh reinstall on your staging site and the issue still persists, please let me know. I will escalate this issue internally for a deeper look.

Viewing 15 replies - 1 through 15 (of 23 total)

You must be logged in to reply to this topic.