I am trying to: display a the number of child posts related to a parent post on the parent's single page
Link to a page where the issue can be seen: enlace oculto
I expected to see: wpv-found-count to display the number of filtered posts that exist
Instead, I got: It sometimes shows the correct number, but most of the time it shows zero.
I have a parent post type named "events" and a child post type named "event-intents". The purpose is to show an event and then show the number of people that have expressed interest in that event. To show their interest a user clicks a button and a child post is created to signify their intention.
On the event single page, I'm using a view with the filter:
Select posts in a Event Intentions relationship that are related to the Post where this View is shown.
[wpv-layout-start]
[wpv-items-found]
Intent Items Count Says: [wpv-items-count]<br/>
[wpv-conditional if="( '[wpv-found-count]' eq '0' )"]Intent Found Count says it's zero<br/>[/wpv-conditional]
<strong><i class="far fa-calendar-day"></i> [wpv-found-count] Going or Interested</strong>
<!-- wpv-loop-start -->
<wpv-loop>
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found][/wpv-no-items-found]
[wpv-layout-end]
It actually looks like it's working fine sometimes, but after a few refreshes, the numbers are wrong.
Hi, this type of behavior usually this indicates a server-side caching issue. Can you temporarily disable the two (edit - dropins, not mu-plugins) related to caching? You can log in with FTP and temporarily remove those files or rename them without a .php extension. Then test again and let me know the results.
in my wp-content folder I see advanced-cache.php and object-cache.php but I'm unable to rename or move them. I get a permission denied error.
I'm currently in (Pressable's) development mode which says it isn't doing any caching or using a CDN
Okay I see, in that case I don't see anything else obvious. If it's okay with you I will install the Duplicator plugin and create a clone of the site so I can run some additional tests offline and monitor code execution. Let me know and I'll get started.
Yes, that would be great.
The thing that really makes me scratch my head is that wpv-items-count is rock solid and wpv-found-count flakes out after a few page refreshes.
And that wpv-conditional if="( '[wpv-found-count]' eq '0' )" shows true AFTER wpv-items-found.
Okay here's where I'm at. I spent most of the morning trying to make a functional clone of this site, but ran into lots of problems along the way. I'm not sure if it's a file permissions issue, but Duplicator was unable to find the wp-config.php file in the normal location. (root directory of site). Also, plugins and themes files didn't copy over into the generated clone. I was able to get a sql dump file of the database, but the DB seems to include at least two sites (one set of tables has a 3b- prefix and the other does not?). Neither of those sites uses HTTPS in the site URL though, but I can see in your debug information that https prefix is included somewhere. Not exactly sure how that would be overridden
At any rate, given those missing pieces I was able to get a very basic version running with my own wp-config.php file. Then I installed the Toolset and Elementor plugins I already have access to, and switched to the default Twenty Nineteen theme for testing. Of course now in my local site the problem is not replicable (argh!). The numbers are consistent from page load to page load. So that leaves a few open possibilities:
- Theme or plugin conflict. Since I wasn't able to get the other plugins and theme files in my clone, I can't confirm or rule this possibility out. I would need access to those files to be able to definitely say one way or the other. If you want to zip up a copy of the wp-content/themes and wp-content/plugins directories, upload that to Drive or Dropbox, and provide me with a download link, I can get a more complete picture of this. I would rather not use FTP to try to transfer all these files from your live site...it would take hours and hours.
- Caching of some kind on the server. I don't know much about the development mode of Pressable, so I did a quick search and found this article: https://kb.pressable.com/article/developmentproduction-mode/
It mentions server caching but doesn't go into much technical detail. "When the caching is off, any style/theme/plugin changes will update automatically since every time someone visits your site, they get a fresh version from our local servers as caching is turned off." Okay so that's talking about file caching, but not more advanced caching like Memcached, and PHP object caching. These more advanced caching mechanisms on the server may still be running, it's not clear to me. You can certainly try purging the cache as shown in the article to see if that helps.
Also I found this article: https://kb.pressable.com/article/how-does-batcache-page-caching-work/
Batcache is active on the site now, to some level. If you check the source of the art in public spaces event page you can see a notice like this (search for "batcache" in the page source):
<!--
generated 4 seconds ago
generated in 1.066 seconds
served from batcache in 0.002 seconds
expires in 296 seconds
-->
So there seems to be caching of some level active on the site now. Somehow that caching system has generated a page load with found count = 0, and cached those results. Now for 296 seconds, anyone who hits the page will get a cached version. If for some reason two Users could have different results here, then this information may be invalid. It should not be cached in this manner if the results are variable per User somehow.
- Some other configuration issue in wp-config.php that I don't fully understand. I'll be glad to take a look at that file via FTP if you want to share that connection information, or you can make a copy of the file and remove your login credentials. Post that file to Drive / Dropbox or some other file sharing system. Share a download link here in the forum (all URLs are obscured here for your security) and I will take a look.
I followed the instructions here: enlace oculto
to disable the batcache for that specific page but still had the inconsistent results.
It seems to present the correct results when it's rendered fresh but incorrect on subsequent (cached?) page loads. Logical this is not.
I'm downloading my wp-content/themes and wp-content/plugins directories and will link to a zipped copy in the next message.
Also, would it be helpful if I created a staging version to mess with?
Link to plugins and theme zip
enlace oculto
I don't think a staging environment will help, because the issue is most likely memcached object caching holding on to some information. Can you purge the cache and shown here: https://kb.pressable.com/article/object-caching-with-memcached-at-pressable/
Then test again and let me know the results.
Screencast
enlace oculto
After clearing either or both caches, the first refresh shows the correct information, any further refreshes shows the found count as zero even though the loop finds posts
Okay thanks, I've asked my 2nd tier team to take a look at this ticket because I'm a bit out of my depth when it comes to memcached and other server-side caching mechanisms. I'll let you know what I find out.
I will reassign this ticket to Beda for further investigation.
Hi Darryl, I'll be with you tomorrow for this.
What we will need is either permission to work (and eventually break) the current site (which I assume is not within the possible approaches) or a staging site where this is replicated.
I tried locally with a memcached server and I had no issues with that ShortCode.
In fact, if that ShortCode breaks, a native WordPress query (items count) should break as well, because we use exactly that for the counter.
I would like to test on the site - if permitted - several scenarios inclusive a very "minima" View, not nested, because I suspect, the issue actually is due to the child/parent relationship and nested Views or Views displaying child data, rather than with memcache alone.
Please find the next reply private to submit eventual data to a staging site, or permission to work on the live site (which I do not suggest)
Duplicates on my local will probably not help as it is already confirmed to not happen locally, so fist I'd like to narrow down the issue in the site you have or eventual copy of - please let me know how we can proceed there.
Thanks!
How's that View inserted to the event?
There is no Content Template, no Layout or even Elementor edit that inserts the View.
Or, I should ask, how are all those views (around 5) inserted in the Events?
If you could share this, it would help me a lot.