I tried to disable WP Object Caching during Runtime using
wp_using_ext_object_cache(false);
Unfortunately it still does not update, e.g. user meta data, from the DB. So when I change a value directly in PHPMYAdmin, I would expect this to be read DIRECTLY out of the DB freshly.
Does wp_using_ext_object_cache not change/work during runtime?
I think I just found the solution after having searched hours and hours before actually posting.
# Disable WP Obj Caching ...
wp_using_ext_object_cache(false);
wp_cache_flush();
wp_cache_init();
Seems to really cleaning/resetting the WP_Object Object behind it -> So all subsequent calls will directly read from DB!
Related
I'm building an application in which translation strings are loaded from messages.en.yml and parsed into an editable form for the user. When the form is submitted it will write all the data to messages.en.yml, this way the user has full control over i18n strings.
This is working like a charm in dev environment, but in prod the .yml file is cached. I'd like to clear the frontend/config cache when changes are made so that changes are visible.
Believe it or not, but Google does not give any viable results as to how to clear the cache programmatically. I don't want to delete all of the cache, as doing this will log the user out. Any clues?
It's not the prettiest solution, but this is what I've used to bust my cache. Calling this after writing the new contents to the file using the Symfony\Component\Yaml\Dumper:
// Bust cache
$fs->remove(sprintf('%s/translations/catalogue.%s.php', $this->kernel->getCacheDir(), $this->getLocale()));
I have a simple string that I would like to save for later use on an ASP.NET server. It is an authorization string for a web service. It mostly stays the same, but may expire every few months. It will be saved programmatically from a code-behind file. Is there a simple place I can save it?
Initial thoughts are:
File - seems reasonable
Database - we don't have one setup and it seems like a lot of overhead to hold a string
Session - this would be too short lived
Config file - Based on answer from MK_Dev this would require a web app restart. No go then.
Somewhere else that I don't know about, but would be perfect?
Another possibility is to create a custom registry key. Here is an article with some code examples: Manipulating and Editing Registry with .NET.
If you don't mind restarting the app when the value changes, then config file is the way to go. If you need it to be fully dynamic, you can add a config table to the database and update it when changes.
How about server side cache?
Check this out: http://msdn.microsoft.com/en-us/library/18c1wd61%28v=vs.71%29.aspx
If the string remains static for the most part, I would store it in Cache with an expiration and/or dependency. If you go the dependency route, you can use a file or store the string in the database, and it will update automatically if and when it's changed.
See this article for details: Caching Application Data
How about System.Environment variables?
System.Environment.SetEnvironmentVariable("mystring","asdf");
System.Environment.GetEnvironmentVariable("mystring");
I'm using asp.net 4.0 (Web Forms website) and I've implemented a custom disk based output provider which works fine in caching the pages on my site. The problem I'm getting however is that I cannot find a way to remove a specific page from the cache and I suspect it's a problem with Url Rewriting.
For example, if I have a page called test.aspx, I can easily remove it from the cache using:
HttpResponse.RemoveOutputCacheItem("/test.aspx");
This does not work for a page that is output cached through id though eg http://www.example.com/page/1 is rewritten as http://www.example.com/myfolder/Page.aspx?id=1
I can see the cached version of the page but I cannot remove it from the disk cache as I need an absolute virtual path for RemoveOutputCacheItem to work. I've tried the following:
HttpResponse.RemoveOutputCacheItem("/myfolder/Page.aspx?id=1");
HttpResponse.RemoveOutputCacheItem("/myfolder/page/1");
And a lot of other variations but nothing seems to work.
The cached key for the url does not match the stored key a2_myfolder_page.aspxHQNidV1FCDE when trying to use RemoveOutputCacheItem.
Is there any solution for that? Or another way to get specific cached pages evicted? Thanks
Have you tried using the VaryByParam or VaryByCustom, and use "id" as your custom identifier: http://msdn.microsoft.com/en-us/library/ms153453.aspx
The issue: a content editor saves a new content item and gets a 404 on the proper-looking url for the new object. If they then refresh, the item is there, perfectly normal.
This happens for multiple Archetypes-based content types, and we've seen it on at least two different sites. We've seen it on Plone 3.x and 4.0.3. Here's what these sites have in common:
HAProxy load balancing (with and without session affinity)
Multiple ZEO clients
Using either ZODB 3.9.7 or 3.8.4
The issue happens only some of the time, maybe for 1 out of 4 content items
Has anyone seen anything like this?
I do not have an answer for you; this should not really happen. I certainly have not seen this.
You'll need to gather more information to troubleshoot this, and that perhaps requires interactive access to experts, and SO is not the place for such troubleshooting.
All I can do is advice that you gather as much information as possible, including a full trail of the user interaction from the various logs, including HAProxy and the ZEO server.
It may require additional instrumentation at the server level (when the NotFound error occurs, dump additional information about what is present, etc).
Some recomendations/questions:
Verfy that the content object was, indeed, created.
Check that the content views are correct (the ones that are declared in profiles/default/types/yourtype.xml).
Does it happen when adding content directly to plone instance (Without caching and load balancing?
Does it happen when adding content to direct plone instance with load balancing, but without caching? ---> And so on ...?
Maybe not an elegant one, but you might try inserting print statements or pdb breakpoints in the code so you can track whenever a content object was, indeed, created. Do this only as a desperate method of "instrumentation".
Yes. we have recently started seeing the same issue. We have almost the same setup. Haproxy (no session affinity).
I'm wondering since the pattern seems to be haproxy... perhaps its an issue with a request being redistributed after a timeout?
Updated:
We had this issue. It happens when you have a redirect back to the changed object after a save. This is because the 2nd request hits another zeo client which doesn't realise it's out of date.
The only solution we found was a to add temporary session affinity in haproxy (20s) during any POST. Not ideal but does work. I was just searching for a better solution which is why I found this old post.
For some reason I can no longer post a comment as an Anonymous user in my Drupal installation. I haven't tried in a while, so I'm not quite sure when this functionality was broken.
I have Services installed, and I can post anonymous comments using comment.save. I have altered the Input Formats if that could break something.
I have enabled both post comments and access comments on the anonymous user. The comments does not show up in the database. In fact, the native Drupal function comment_save isn't called when I try to comment as Anonymous (I check this by adding print_r($edit);die(); at the top of the comment_save function in comment.module. Also I read something that not having a User with the UID 0 would break the Anonymous commenting, this user exists (obviously, since commenting through Services works)
I have tried out the AntiSpam module, and posted a comment as Anonymous that would get caught(and did) in the spamfilter, but this module is now disabled.
I'm really running out of ideas here, does anyone have any other suggestions on what to do? In the meanwhile I'm going to attempt to backtrack the code to figure out why comment_save() isn't being called.
Edit: Anonymous users also don't have to submit email and such to post, if that matters in any way.
By what you say, I suspect the problem is with some contributed code hooking on the comment form and modifying it in a way that makes it fail submission. This can be caused by a number of causes: a jQuery that adds fields to the form without regenerating the form-id on the server, an added or cusomised field that changes the callback to submit the form, etc...
I cannot know it for sure, but here's what I would do if I were you, in order to check what's up with your installation:
Make sure you disinstalled (and not only disabled) the modules you tried and don't use anymore. Modules should never touch core tables, but who knows... It does not cost anything and it actually frees some of your DB.
Try disabling all contrib modules and see if you can comment that way. If this is the case, activate the contrib modules one at a time until you find out which one is the culprit. Chances are you will already find a patch/workaround in the issue queue for that module on http://drupal.org. If you don't find a fix, I would investigate (xdebug or manual tracking) the code, and I would pay special attention to all implementations of hook_form_alter() and hook_form_FORM_ID_alter().
If even disabling all contrib modules doesn't help (which I would be very astonished of), try updating the core with a fresh installation if you consider as a possibility that your cat walked on the keyboard while you had a core file opened, or you live with Gordon Brown's family.
Failing that, the only alternatives coming to my mind are much more esoteric, such DB failure, a greasemonkey script on your browser interfering with commenting and similar unlikely possibilities.
HTH!
I solved this once by resetting the permissions table (http://drupal.org/node/64114), but I would do a proper backup and keep the permissions page open in a tab, just in case.