Title: AMP PHP error
Last modified: December 22, 2022

---

# AMP PHP error

 *  [ecronik](https://wordpress.org/support/users/ecronik/)
 * (@ecronik)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/amp-php-error/)
 * Hi Marko,
 * I hope you’re doing well! I’ve found this in my debug.log –
 * `PHP Notice: Function amp_is_available was called **incorrectly**. amp_is_available()(
   or amp_is_request(), formerly is_amp_endpoint()) was called too early and so 
   it will not work properly. WordPress is currently doing the w3tc_footer_comment
   hook. Calling this function before the wp action means it will not have access
   to WP_Query and the queried object to determine if it is an AMP response, thus
   neither the amp_skip_post() filter nor the AMP enabled toggle will be considered.
   It appears the plugin with slug w3-total-cache is responsible; please contact
   the author. Please see [Debugging in WordPress](https://wordpress.org/support/article/debugging-in-wordpress/)
   for more information. (This message was added in version 2.0.0.) in x/wp-includes/
   functions.php on line 5833`
 * WP 6.0.3, PHP 8.0.26, official AMP plugin (using ?amp=1), W3TC AMP extension (
   query string, postfix “amp”)
 * Did add amp as accepted query string on the site, as you adviced [here](https://wordpress.org/support/topic/amp-parameter/#post-16122785).
 * Thanks for your help,
 * eC
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Famp-php-error%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

1 [2](https://wordpress.org/support/topic/amp-php-error/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/amp-php-error/page/2/?output_format=md)

 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/amp-php-error/#post-16313333)
 * Hello [@ecronik](https://wordpress.org/support/users/ecronik/)
 * Thank you for reaching out!
   TBH, this is the first time I am seeing this PHP 
   Notice. Not sure what’s not working there, however, w3tc_footer_comment is called
   to check if ( $this->is_amp_endpoint()If you check the source of your amp page:
 *     ```wp-block-code
       <!--
       Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/
   
       Object Caching 195/257 objects using disk
       Page Caching using disk: enhanced 
       Database Caching 16/55 queries in 0.012 seconds using disk (Request-wide modification query)
       AMP page, minification is limited
   
       Served from: yourgames.tv @ 2022-12-22 15:03:02 by W3 Total Cache
       -->
       ```
   
 * I’ve bolded the **AMP page, minification is limited**
   Can you please share when
   you have started to see this PHP notice and are there any issues with serving
   the AMP pages or using the MAP with W3TC?
 * Thanks!
 *  Thread Starter [ecronik](https://wordpress.org/support/users/ecronik/)
 * (@ecronik)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/amp-php-error/#post-16313583)
 * Hey [@vmarko](https://wordpress.org/support/users/vmarko/) ,
 * no issues with serving/using the AMP, but will keep an eye on it, thanks!
 * One additional question: Did a load-test on the site, and this PHP warning occurred:
 * `[22-Dec-2022 13:22:54 UTC] PHP Warning: filesize(): stat failed for x/wp-content/
   cache/db/singletables/e8a/15f/e8a15f713be1e24682a7013b86519d27.php in x/wp-content/
   plugins/w3-total-cache/Cache_File.php on line 159`
 * What’s happening there? Would also be great, if you could edit the sitename out
   of your previous reply.
 * Thanks and happy holidays!
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/amp-php-error/#post-16313797)
 * Hey [@ecronik](https://wordpress.org/support/users/ecronik/)
 * Thank you for your feedback. I am unable to edit out the site name unfortunately
   since you replied to the forum post. I’ll check with the moderators. I am sorry
   I thought it was ok since you shared your website URL in the initial post.
   As
   for the warning, this suggests that the file is not there or has old data. Try
   manually deleting the wp-content/cache/db/singletables/ folderAs I can see you
   have Database Cache enabled and using the Disk caching method for this.I would
   advise reconsidering this and using Memory based caching solution for DB caching,
   like Redis or Memcached. using disk-database caching (on shared hosting) can 
   make your site slower. This is so because getting data from the database can 
   be faster than getting cached data from the disk.Thanks!
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [3 years, 5 months ago](https://wordpress.org/support/topic/amp-php-error/#post-16313801)
 * Moderator note:
 * I’m sorry but no. Unless it is an extreme case, posts and replies are not edited
   here.
 * Forum topics will only be edited or deleted if they represent a valid legal, 
   security, or safety concern.
 * See [https://wordpress.org/support/forum-user-guide/faq/#will-you-delete-my-post-once-the-problem-is-solved](https://wordpress.org/support/forum-user-guide/faq/#will-you-delete-my-post-once-the-problem-is-solved)
   and [https://wordpress.org/about/privacy/](https://wordpress.org/about/privacy/)
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/amp-php-error/#post-16313812)
 * Hello [@sterndata](https://wordpress.org/support/users/sterndata/) 
   Thank you
   for the info on this.
 *  Thread Starter [ecronik](https://wordpress.org/support/users/ecronik/)
 * (@ecronik)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/amp-php-error/#post-16313862)
 * Hm, I’m on shared and only have Disk available; everything else is greyed out
   [@vmarko](https://wordpress.org/support/users/vmarko/) – so you would advise 
   in this case to turn off DB caching? Using Object Caching too. Or is it another
   activated option somewhere that prevents me from choosing something else than
   Disk?
 * I’ve shared the URL with the post, but as far as I know it’s only visible for
   logged in users (so it’s not going into SE-index), right?
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/amp-php-error/#post-16313938)
 * Hello [@ecronik](https://wordpress.org/support/users/ecronik/)
 * Yes, if you are on a shared hosting then the memory-based caching is most likely
   unavailable to you. In order to be able to use Redis or memcached, you need to
   install phpRedis or phpmemcached module on yoru server, so that W3 Total Cache
   is able to use it and recognize it.
 * For both DB caching and Object Caching, it’s best not to use it on Disk when 
   on a shared server. Object Caching you can keep enabled as it’s more efficient,
   however you should disable Database Caching.
 * Yes, your URL is only visible to logged-in users. The one I shared is formatted
   so there should be no problems.
 * Thanks!
 *  Thread Starter [ecronik](https://wordpress.org/support/users/ecronik/)
 * (@ecronik)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/amp-php-error/#post-16315902)
 * Hi [@vmarko](https://wordpress.org/support/users/vmarko/) – just letting you 
   know that the PHP notices keep coming back. But unfortunately can’t tell what
   actions are causing it.
 * Thanks
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/amp-php-error/#post-16316779)
 * Hello [@ecronik](https://wordpress.org/support/users/ecronik/)
 * Thank you for your feedback.
 * Are you referring to the PHP Notices related to the AMP?
   Can you please share
   them and again are you experiencing the problem serving amp pages?
 * Thanks!
 *  Thread Starter [ecronik](https://wordpress.org/support/users/ecronik/)
 * (@ecronik)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/amp-php-error/#post-16322546)
 * Hi [@vmarko](https://wordpress.org/support/users/vmarko/)
 * I hope you had great Christmas holidays! I was referring to the PHP notices and
   thought you wanted me to let you know when they keep occurring, but I misunderstood
   your reply. Unfortunately, I can’t say for sure when the notice first appeared.
   However, AMP’s functionality still doesn’t seem to be affected.
 * Thanks
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/amp-php-error/#post-16330945)
 * Hey [@ecronik](https://wordpress.org/support/users/ecronik/)
 * Sorry for the late reply, I was trying to replicate this and figure it out.
   As
   I’ve stated in the first reply, this is related to the W3TC html snippet. You
   can safely ignore this notice, however, we’ll check more and investigate this
   to make sure AMP notice does not show up anymore in the future.
 * Thanks!
 *  Thread Starter [ecronik](https://wordpress.org/support/users/ecronik/)
 * (@ecronik)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/amp-php-error/#post-16381011)
 * Hi [@vmarko](https://wordpress.org/support/users/vmarko/)
 * I hope you are doing well! In addition to the PHP notice about AMP, there is 
   a new warning in the logs now, that happens every couple of minutes:
 * `[17-Jan-2023 09:08:02 UTC] PHP Warning: Trying to access array offset on value
   of type null in /www/htdocs/xxx/domain.com/wp-content/plugins/w3-total-cache/
   Util_AttachToActions.php on line 79`
 * The site (you can find the link in my initial post) runs w/ W3TC v2.2.11
 * Another thing I could need your help with is about the AJAX functions (load more
   posts) of the site within articles and also on the home page, for example. After
   a while, it doesn’t work anymore, and the loader spins until infinity; the console
   shows this:
 * `jquery.min.js?ver=3.6.0:2
   POST https://domain.com/wp-admin/admin-ajax.php?td_theme_name
   =Newspaper&v=12.2 403send @ jquery.min.js?ver=3.6.0:2ajax @ jquery.min.js?ver
   =3.6.0:2tdAjaxDoBlockRequest @ tagdiv_theme.min.js?ver=12.2:281(anonymous) @ 
   tagdiv_theme.min.js?ver=12.2:272dispatch @ jquery.min.js?ver=3.6.0:2v.handle 
   @ jquery.min.js?ver=3.6.0:2c @ rocket-loader.min.js:1
 * I guess that’s an issue with a Nonce, but I can’t find any solution to it yet.
   Keeping the HTML/XML TTL under 2h seems to work so far, but not sure if that 
   was really the fix. Do you maybe have another idea to be able to have a longer
   TTL? If not, do you see any problems in setting the HTML/XML TTL to 115 minutes?
   Cron runs every 5 Mins, and garbage collection every hour. CSS/JS and Media TTL
   is a year.
 * Thank you,
 * eC
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/amp-php-error/#post-16381985)
 * Hello [@ecronik](https://wordpress.org/support/users/ecronik/) 
   Thank you for
   your feedback. I’ve had a chat with the devs and as for the AMP notice, you can
   ignore this as it’s only being used to call w3tc_footer_comment and as you can
   see it is working as expected.Regarding the Util_AttachToActions.php we are aware
   of this and this will be fixed in the next release.As a temporary fix please 
   comment out line 33 of Util_AttachToActions.php
 * `//add_action( ‘wp_set_comment_status’, array( $o, ‘on_comment_status’ ), 0, 
   2 );`
 * The HTML&XML TTL is how long the page will stay cached in the browser. And yes,
   there might be a problem with nonce so therefore lowering the TTL for HTML and
   XML is the best solution and it will not impact the corn or the Garbage collection
   interval.
    I can see that you are also using a rocket loader so this can also
   potentially cause a problem with jquery.min.jsThanks!
 *  Thread Starter [ecronik](https://wordpress.org/support/users/ecronik/)
 * (@ecronik)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/amp-php-error/#post-16382054)
 * Hey [@vmarko](https://wordpress.org/support/users/vmarko/)
 * Thanks for your quick response! I would like to double-check this again: You 
   don’t see a possible problem when having HTML/XML TTL set to 115 minutes, cron
   set to 5 minutes, and garbage collection set to 60 minutes? I’m just trying to
   avoid a possible mismatch between the timings, as it could happen with preloading.
 * Thanks,
 * eC
 *  Thread Starter [ecronik](https://wordpress.org/support/users/ecronik/)
 * (@ecronik)
 * [3 years, 4 months ago](https://wordpress.org/support/topic/amp-php-error/page/2/#post-16384809)
 * Hi [@vmarko](https://wordpress.org/support/users/vmarko/)
 * commenting out line 33 of Util_AttachToActions.php did unfortunately not prevent
   the PHP warnings.
 * Thanks,
 * eC

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

1 [2](https://wordpress.org/support/topic/amp-php-error/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/amp-php-error/page/2/?output_format=md)

The topic ‘AMP PHP error’ is closed to new replies.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

 * 18 replies
 * 3 participants
 * Last reply from: [ecronik](https://wordpress.org/support/users/ecronik/)
 * Last activity: [3 years, 3 months ago](https://wordpress.org/support/topic/amp-php-error/page/2/#post-16458376)
 * Status: not resolved