Extension settings always reset?

May 2, 2008 at 5:16 PM
Hi all,
I found that the Extension manager can only save extension settings for a couple hours, I had saved the setting for the extension, and the settings are actually saved, I checked for extension.xml for the saved settings, they were ok, but after a couple hours, the settings are reset to default themselves. Is this a known bug of BlogEngine 1.3 ? Thanks.
Coordinator
May 2, 2008 at 5:52 PM
It is likely specific to extension you are using. It might reset to defaults responding to event in application instead of on initialization only.
May 2, 2008 at 8:28 PM


rtur wrote:
It is likely specific to extension you are using. It might reset to defaults responding to event in application instead of on initialization only.


The extension which I have set settings is CommentToolbar, here's its constructor with setting management:

Comment.Serving += new EventHandler<ServingEventArgs>(Post_CommentServing);
Post.Serving += new EventHandler<ServingEventArgs>(Post_PostServing);

ExtensionSettings settings = new ExtensionSettings("CommentToolbar");

settings.AddParameter("lblReply", "Label Reply button", 30);
settings.AddParameter("lblQuote", "Label Quote button", 30);
settings.AddParameter("tlbPosition", "Position (Top/Bottom)", 1, true);
settings.AddParameter("tlbType", "Type (Button/Link)", 1, true);
settings.AddParameter("tlbSeparator", "Character separator", 1, true);



settings.Help = "Add <b>CommentToolbar</b> at the end of every comment.<br /><br />";
settings.Help += "You can set label of buttons:<br /> leave the label <em>blank</em> to hide button<br /><br />";
settings.Help += "You can select to display links or buttons:<br /> B = buttons, L = Link<br /><br />";
settings.Help += "You can set toolbar position:<br /> T = Top, B = Bottom<br /><br />";
settings.Help += "You can set character separator:<br /> leave the label <em>blank</em> to not show";


settings.AddValues(new string[] { "Reply", "Quote", "B", "B", " | " });
settings.IsScalar = true;

ExtensionManager.ImportSettings(settings);
_settings = ExtensionManager.GetSettings("CommentToolbar");


The strange thing is it did saved and applied settings correctly, I used two different computers to open my blog to confirm setting changes already took effect. but after a couple hours, I visited my blog again (or I downloaded the extensions.xml by FTP) to check whether the setting still taking effect, I found that its settings were back to default (of course the content of extensions.xml was changed to default), and I hadn't logged in as admintrator again yet, so I don't think there could be a chance for it to change settings because only the Extension Manager saves settings and an extension only reads settings from ExtensionManager.
Coordinator
May 3, 2008 at 3:50 AM
I installed this extension on my test machine with BE 1.3.1. Extension looks ok to me and works fine so far. I'll let you know if I find something.
May 3, 2008 at 5:49 PM


rtur wrote:
I installed this extension on my test machine with BE 1.3.1. Extension looks ok to me and works fine so far. I'll let you know if I find something.


Have you changed the CommentToolbar's style from button to link and set custom button text?
Coordinator
May 3, 2008 at 6:24 PM

miller wrote:
Have you changed the CommentToolbar's style from button to link and set custom button text?

Yep, did so. Did couple IIS restarts, too - still works fine. Have you tried to customize BBCode settings to see if it will get lost?
May 4, 2008 at 3:43 PM


rtur wrote:

miller wrote:
Have you changed the CommentToolbar's style from button to link and set custom button text?

Yep, did so. Did couple IIS restarts, too - still works fine. Have you tried to customize BBCode settings to see if it will get lost?


Hi rtur,
Sorry for the delay, I was trying to reproduce the issue. It was hard to reproduce, but finally I made it and got more details on it. These are my steps:

I deleted CommentToolbar. Set something in BBCode settings, waited for about 3 hours, and got nothing rollback to default. Ok, it seemed failed.
I installed CommentToolbar again, set something in CommentToolbar, after about 2 hours, settings were still there. Seemed failed again. But, I didn't give up.
I started to submit some comments. after about 2 hours, settings were still there, sh*t....
"Maybe I need to change BBCode settings back?" I was thinking about that and was writing a "test post" on the blog and adding several comments to the "test post".
And then, I forgot to change BBCode settings back haha......about 1 hour later, yeah I saw the settings were all reset to default, including BBCode's.
I downloaded the extensions.xml and the "test post", compared to their last-modified-time, the extensions.xml's modified time was 8:09 (exactly about 1 hour after the last time I logged in), the "test post" was 6:59, yeah seemed it's just been reset. Of course I open the extension.xml and found everything including BBCode's and CommentToolbar's were all reset to default.

Maybe these steps can make sense to you, I'll try to find more details. Thanks.


Miller
May 5, 2008 at 6:48 AM
Weird, I tried to reproduce the issue again, but didn't see it again in a short time. So I set the settings then went to bed, after I woke up, I checked for the extension.xml and found it's restored again.
The modified time of extension.xml is 20:12, I login to blogengine to see the server time, it's 23:45 now, so it's benn modified when I was sleeping 3 hours ago.
Coordinator
May 5, 2008 at 3:05 PM
I wasn't able to re-create this, but I think I know what is going on. In 1.3, manager will reload defaults if extensions.xml gets corrupted. We changed it down the road to throw an error instead. What you need to do is go to ~/app_code/extensionmanager/manager.cs and change catch statement inside LoadFromStorage() method from:

catch (Exception)
{
// to avoid runtime error. In the
// worse case defaults will be loaded
}

to:

catch (Exception)
{
HttpContext.Current.Cache.Remove("Extensions");
throw;
}

Then, you'll get error and will be able to look at XML file and see what gone wrong.
May 5, 2008 at 4:13 PM
Edited May 5, 2008 at 4:30 PM


rtur wrote:
I wasn't able to re-create this, but I think I know what is going on. In 1.3, manager will reload defaults if extensions.xml gets corrupted. We changed it down the road to throw an error instead. What you need to do is go to ~/app_code/extensionmanager/manager.cs and change catch statement inside LoadFromStorage() method from:

catch (Exception)
{
// to avoid runtime error. In the
// worse case defaults will be loaded
}

to:

catch (Exception)
{
HttpContext.Current.Cache.Remove("Extensions");
throw;
}

Then, you'll get error and will be able to look at XML file and see what gone wrong.


Thanks, I think this is not enough, I'm also hard to re-create the error, I saw it today only once, so I may miss the error.
Can you post a piece of code to save the error message into a text file in App_Data? So that I will see the error message even I'm sleeping. :-p

Sorry I couldn't find the LoadFromStorage() method in manager.cs...where is it?

PS: I found a method LoadFromXML(), maybe you meant this one, I'll try.
May 5, 2008 at 4:48 PM
This happens quite often on my sites that are running BlogEngine.NET too. In the hosting environment, the settings are configured correctly, but overnight when the blog is not getting hit, the application is unloading. When BlogEngine.NET reloads, it has been resetting the extension settings.

The workaround that I've been using is that I've been giving ASP.NET read-only access to the extensions configuration file, and only changing the file permissions while I'm editing the extension settings. It's not an ideal workaround, but it's prevented the problem from continuing.
Coordinator
May 5, 2008 at 6:18 PM

PS: I found a method LoadFromXML(), maybe you meant this one, I'll try.

Yes, that's the one - sorry for confusion, it got renamed later. You can log error like so:

catch (Exception e)
{
string logFile = HostingEnvironment.MapPath(BlogSettings.Instance.StorageLocation + "log.txt");
File.WriteAllText(logFile, e.Message);
}

But it is not a lot of use, it probably will complain the XML is not properly formatted. It won't change though - you'll can open it up and see where exactly it's broken.
May 6, 2008 at 6:21 AM
Edited May 6, 2008 at 7:14 AM


rtur wrote:

PS: I found a method LoadFromXML(), maybe you meant this one, I'll try.

Yes, that's the one - sorry for confusion, it got renamed later. You can log error like so:

catch (Exception e)
{
string logFile = HostingEnvironment.MapPath(BlogSettings.Instance.StorageLocation + "log.txt");
File.WriteAllText(logFile, e.Message);
}

But it is not a lot of use, it probably will complain the XML is not properly formatted. It won't change though - you'll can open it up and see where exactly it's broken.


Before you post the saving code, I've changed manager.cs to throw exceptions, and after one night slept, I open up my blog but see no exception thrown by the blog, but it's not normal because it ignored loading the CommentToolbar, the Reply & Quote buttons which added by CommentToolbar are disappeared now. I've checked extensions.xml but it is not corrupted, CommentToolbar and other extension settings are all there.

PS: I've just checked for BBCode, it's not loaded eighter, maybe I'd better hold the state of the blog to let you check wich it?

PS2: I was wrong, extension.xml IS corrupted, I've just added the saving code and immediately see the log.txt, and it says:

There is an error in XML document (174, 32).

Do you know what I see? The "</ManagedExtension>" of the last one extension is missed. Ok, the problem here is clear now. hehe...

PS3: Not just "</ManagedExtension>" missed, at least not only one missed, the last block of extensions.xml is here:

<ManagedExtension Name="Thumbnailer">
<Version>0.1</Version>
<Description>Creates thumbnail images for blog posts and pages while the content is beeing saved</Description>
<Author><a href="http://blog.data-worx.de">René Kuss</a></Author>
<AdminPage />
<Enabled>true</Enabled>
<Settings>
<Help>Creates thumbnail images in blog posts and pages.<br/><br/>Nore information and help can be found <a href="http://blog.data-worx.de/page/Extension-Thumbnailer.aspx" target="_blank">here</a>.</Help>
<Delimiter>44</Delimiter>


and then it's EOF.
At least, it missed </Settings> and </ManagedExtension>.

PS4: I compared extensions.xml to the backup version, and found there're more. I made a screenshot here, you can take a look. http://miller.rotatingscrew.com/corrupted.png

PS5: (Ok, I need to add PS5 now) I've just logged in as administrator, and at the same time the content of extensions.xml is reset to default automatically.
May 7, 2008 at 4:05 PM
Not that this helps but I am getting a similar thing happening using Blog Engine 1.3 and the Social Bookmarking extension 1.0.

I thought it was when I browsed my site using my Sony PSP with Javascript turned off. Unfortunately it has reset to default values several times today using Firefox 2.0.

Maybe other extension are affected.

May 8, 2008 at 5:29 AM
Yes, this happens to me as well with the silverlight extension activated...very strange, and very interested in a resolution... Definitely concerned about adding any further extension until this problem is resolved...
May 16, 2008 at 12:05 PM
Seems this question has been forgotten?
Coordinator
May 17, 2008 at 2:53 AM


miller wrote:
Seems this question has been forgotten?

From your example, it looks like it bombs trying to serialize settings to XML. Serializer will never tell where exactly it chocked, just throw generic error. It might be some odd character it can't handle - hard to say. I was never able to re-create this error, it just works for me no matter what I try with ~20 extensions installed. It will be easier to isolate in 1.4 as every extension will write in its own file, but right now we need to find a way to re-create error to fix it.
May 7, 2012 at 6:57 PM

Hi, i am getting same issue with BE 2.6, for recaptha and snapshot and google async extenstions,

 

Please let me know if there was any resolutions to that, i got some good information i will try but will appriciated reply.

 

Thanks

-Samar

http://www.gosam.info