Unable to add page content

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
3/15/2008 7:40:49 PM
Gravatar
Total Posts 15

Re: Unable to add page content

Hi Joe,

Love the product by the way.  I got latest a couple of days ago and using my 'dev' installation (rather than the 'release' version that's working fine), I found the same issue (content publish dates out of step) when working with MSSQL (2005 Express).

I'm in Australia and found that the Publish begin dates were actually being set to 'now', when inserted, but the criteria on selection was obivously based on UTC date.  I realised that adding content through pagelayout.aspx calls mp_Modules_Insert (which in turn does an inline insert to mp_PageModules.

This second insert takes the 'created date' as the PublishBeginDate which is passed into the proc. 

The root of this call is in mojoportal.Business.Module.Create.  I simply changed the createdate from DateTime.Now to DateTime.UtcNow (line 356).  Everything started working for me then.  This may cause some other issues, but I'll keep this in my local version until I spot any strangeness!  I think other methods of adding content may work fine as they may use slightly different procs.

Cheers,

Matt 

 

3/16/2008 4:19:07 AM
ulu
Gravatar
Total Posts 22

Re: Unable to add page content

By the way, this bug was fixed some time ago, but it reappeared recently. About a month ago, I downloaded the trunk version, installed it, and the prefilled content was missing!

May I humbly suggest that it would be cool to move all date-time management functionality into a separate class..

 

ulu

3/16/2008 6:50:54 AM
Gravatar
Total Posts 18439

Re: Unable to add page content

Hi Matt,

Thanks for tracking it down, your change is correct and I will make the same one here.

 

Hi Ulu,

This is not a regression. This line of code was calling DateTime.Now but it should be and now is calling DateTime.UtcNow.

There is no way this line of code if it was somehow regressed (from working correctly before) could cause the probelm you describe of content disappearing after upgrade. This line of code only executes on creation of data so it can't affect existing data on an upgrade.

More likely this problem could be caused by the date time offset in Web.config was lost during upgrade. If you move any custom appSettings to user.config they will not be lost on upgrade.

Hope it helps,

Joe

12/9/2008 2:58:44 AM
Gravatar
Total Posts 4

Re: Unable to add page content

Hi Joe!

I've experienced same issues till found out my timezone was -4 instead of +3. By the way new two minor bugs were discovered in ContentManager (version 2.2.7.5 MSSQL).

The first one appears when content is already published and publication date is extracted from database and it is not adjusted from UTC to user's timezone. But when the user just saves publication settings this date is adjusted back to UTC as if it was user's local time. For me it works like substract 3 hours every time I save publication. But once someone has negative timezone offset acting this manner, the publication date will be increased by offset hours. So publication start date can even be in future for newly created content. The other side of the problem is publication end date which may be critical in some applications. And it is changed in the same manner.

The second bug: PageGuid of published content does not correspond to PageID in the mp_PageModules table. It seems like it is PageGuid of the first page of portal.

Regards,

Misha

12/9/2008 5:48:30 AM
Gravatar
Total Posts 18439

Re: Unable to add page content

Hi Misha,

Yes, the first problem is it used the default time zone because you had not specified yours. I should probably make a checklist of steps to do after installation to clarify this, I will try to get to that soon.

If the default is set correctly and the user time zone is set correctly it all works as it should and dates are stored as utc and adjusted to user time zone for authenticated users and preferred time zone for not authenticated. It can also be a problem if the db is on a different machine and the time is not in sync with the web server time.

Thanks for letting me know about the pageguid bug, I will look into it. Its not causing any functional bug, but it needs to be fixed.

Best,

Joe

12/18/2008 9:47:56 AM
Gravatar
Total Posts 4

Re: Unable to add page content

Hi Joe,

But there is an error with ContentManager. Let me point it out.

Suppose we create new content. Next, add it to some page with begin time 10 a.m. We see time is adjusted to utc in the publishing table when we press "save". A little bit confusing, but ok. Next, open the publishing record we just added and see the begin time is not 10a.m. It's 7 a.m. for me (UTC+3).

Exactly the same thing happens with end date.

Let's look into the code.

Dates in the grid are placed in the dpBeginDate and dpEndDate date picker controls. dpBeginDate is bound to PublishBeginDate column using GetBeginDate(Eval("PublishBeginDate")). GetBeginDate looks like this
protected String GetBeginDate(Object o)
{
if((o == null)||(o.ToString() == String.Empty))
{
return DateTime.UtcNow.AddHours(timeOffset).ToString();
}

return o.ToString();

}
This function adjusts time only for empty value. This happens when content has not been published yet.
dpEndDate is bound to PublishEndDate using Bind("PublishEndDate").
When RowUpdating event occurs, DatePickers simply take their values from dpBeginDate and dpEndDate.
Are date adjusted before binding occurs? I’ve traced calls down to SQL. The answer is: no.

The fix is straightforward. But I’m not sure wether DateTime.Parse works ok if some cultures are mixed. But culture combinations are not supposed to happen, do they?

ContentManager.aspx.cs starting from line 268:
protected String GetBeginDate(Object o)
{
DateTime dt;
if ((o == null) || (o.ToString() == String.Empty))
dt = DateTime.UtcNow;
else dt = DateTime.Parse(o.ToString());

return ((DateTime)dt).AddHours(timeOffset).ToString();
}

protected String GetEndDate(Object o)
{
if ((o == null) || (o.ToString() == String.Empty))
return o.ToString();
return DateTime.Parse((string)o).AddHours(timeOffset).ToString();
}

ContentManager.aspx starting from line 65:
<asp:TemplateField HeaderText="">
<ItemTemplate>
<%# GetBeginDate(Eval("PublishBeginDate"))%>
</ItemTemplate>
<EditItemTemplate>
<mp:DatePickerControl id="dpBeginDate" runat="server" Text='<%# GetBeginDate(Eval("PublishBeginDate")) %>' ShowTime="True"></mp:DatePickerControl>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<%# GetEndDate(Eval("PublishEndDate"))%>
</ItemTemplate>
<EditItemTemplate>
<mp:DatePickerControl id="dpEndDate" runat="server" Text='<%# GetEndDate(Eval("PublishEndDate")) %>' ShowTime="True"></mp:DatePickerControl>
</EditItemTemplate>
</asp:TemplateField>


Hope this helps mojoportal become little better. :)
Sincerely,
Misha
 

12/18/2008 3:44:10 PM
Gravatar
Total Posts 18439

Re: Unable to add page content

Hi Misha,

I agree with your diagnosis and the fix. Thanks for your help.

I made the same changes here with minor variation of using Convert.ToDateTime instead of casting.

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.