Support » Plugin: Nginx Helper » Purge on publish sometimes runs twice

  • Plugin Contributor RavanH

    (@ravanh)


    Hi,

    Sometimes the update_post_status hook gets called twice (depending on other plugins using that hook) which will cause the cache purge process to run twice. See this for example from my dev site log, where there is a second loop “Purge post on transition post STATUS from publish to publish”:

    
    2019-02-28 02:30:49  | INFO | Purge post on transition post STATUS from draft to publish
    2019-02-28 02:30:49  | INFO | * * * * *
    2019-02-28 02:30:49  | INFO | * Blog :: dev.status301.net ( 1 ).
    2019-02-28 02:30:49  | INFO | * Custom post type 'post' :: Test ( 1662 ).
    2019-02-28 02:30:49  | INFO | * CPT 'post' ( 1662 ) published or edited and its status is published
    2019-02-28 02:30:49  | INFO | * * * * *
    2019-02-28 02:30:49  | INFO | Function purge_post BEGIN ===
    2019-02-28 02:30:49  | INFO | Purging homepage https://dev.status301.net/
    2019-02-28 02:30:49  | ERROR | - Cache Not Found | https://dev.status301.net/
    2019-02-28 02:30:49  | INFO | * * * * *
    2019-02-28 02:30:49  | INFO | Purging post ( id 1662, blog id 1 ) 
    2019-02-28 02:30:49  | ERROR | - Cache Not Found | https://dev.status301.net/2019/02/28/test/
    2019-02-28 02:30:49  | INFO | * * * * *
    2019-02-28 02:30:49  | ERROR | - Cache Not Found | nginx-cache:httpsGETdev.status301.net/sitemap.xml
    2019-02-28 02:30:49  | ERROR | - Wild Card Cache Not Found | nginx-cache:httpsGETdev.status301.net/sitemap*.xml
    2019-02-28 02:30:49  | INFO | Function purge_post END ^^^
    2019-02-28 02:30:51  | INFO | Purge post on transition post STATUS from publish to publish
    2019-02-28 02:30:51  | INFO | * * * * *
    2019-02-28 02:30:51  | INFO | * Blog :: dev.status301.net ( 1 ).
    2019-02-28 02:30:51  | INFO | * Custom post type 'post' :: Test ( 1662 ).
    2019-02-28 02:30:51  | INFO | * CPT 'post' ( 1662 ) published or edited and its status is published
    2019-02-28 02:30:51  | INFO | * * * * *
    2019-02-28 02:30:51  | INFO | Function purge_post BEGIN ===
    2019-02-28 02:30:51  | INFO | Purging homepage https://dev.status301.net/
    2019-02-28 02:30:51  | ERROR | - Cache Not Found | https://dev.status301.net/
    2019-02-28 02:30:51  | INFO | * * * * *
    2019-02-28 02:30:51  | INFO | Purging post ( id 1662, blog id 1 ) 
    2019-02-28 02:30:51  | ERROR | - Cache Not Found | https://dev.status301.net/2019/02/28/test/
    2019-02-28 02:30:51  | INFO | * * * * *
    2019-02-28 02:30:51  | ERROR | - Cache Not Found | nginx-cache:httpsGETdev.status301.net/sitemap.xml
    2019-02-28 02:30:51  | ERROR | - Wild Card Cache Not Found | nginx-cache:httpsGETdev.status301.net/sitemap*.xml
    2019-02-28 02:30:51  | INFO | Function purge_post END ^^^
    

    This may be prevented by a simple check for $old_status === $new_status

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.