umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.46k stars 2.68k forks source link

Bug in creating content with user that has language ar-SA in Users Section at Umbraco Backoffice #7278

Closed bassemelkadeem closed 3 years ago

bassemelkadeem commented 4 years ago

The bug is that I have created a language file for (Arabic Saudi Arabia) inside the Umbraco-Config-Lang file with (ar-sa.xml) and modify xml file so it can point to Arabic Saudi Arabia and then go to Umbraco Backoffice and go to section for Users and change the language for the administrator user to Arabic Saudi Arabia then go to create content from Home document type it gives me an error and there is an error in browser console.

Umbraco version

I am seeing this issue on Umbraco version: 8.3.0

Reproduction

Bug summary

Can not create content if i changed language for administrator user to (Arabic Saudi Arabia)

Steps to reproduce

  1. I have created a language file for (Arabic Saudi Arabia) inside the Umbraco-Config-Lang file with (ar-sa.xml)
  2. Modify xml file so it can point to Arabic Saudi Arabia
  3. Go to Umbraco Backoffice and go to section for Users and change the language for the administrator user to Arabic Saudi Arabia
  4. Go to create content from Home document type it gives me an error and there is an error in browser console.

Expected result

The expected result is that I can create any content regardless of the language used

Actual result

it gives me and error in browser console with the following message:

Possibly unhandled rejection: {"errorMsg": "Failed to retrieve data for empty content item type home", "data": {"Message": "An error has occurred.", "ExceptionMessage": "The 'ObjectContent`1' type failed to serialize the response body for content type 'application / json; charset = utf-8'. "," ExceptionType ":" System.InvalidOperationException "," StackTrace ": null," InnerException ": {" Message ":" An error has occurred. "," ExceptionMessage ":" The specified time is not supported in this calendar. It must be between 04/30/1900 00:00:00 (AD date) and 11/16/2077 23:59:59 (date AD), fully. \ R \ n Parameter name: time "," ExceptionType ":" System.ArgumentOutOfRangeException "," StackTrace ":" At System.Globalization.UmAlQuraCalendar.CheckTicksRange (Int64 ticks) \ r \ n At System.Globalization .UmAlQuraCalendar.GetDatePart (DateTime time, Int32 part) \ r \ n at System.Globalization.UmAlQuraCalendar.GetYear (DateTime time) \ r \ n at System.Dat eTimeFormat.FormatCustomized (DateTime dateTime, String format, DateTimeFormatInfo dtfi, TimeSpan offset) \ r \ n at System.DateTimeFormat.Format (DateTime dateTime, String format, DateTimeFormatInfo dtfi, TimeSpan offset) \ r \ n at System.D DateTime dateTime, String format, DateTimeFormatInfo dtfi) \ r \ nWhen Newtonsoft.Json.Converters.IsoDateTimeConverter.WriteJson (JsonWriter writer, Object value, JsonSerializer serializer) in //Src/Newtonsoft.Json/Converters 83 \ r \ nAt Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable (JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty) in //Sriter/NewtonSternal.JPG

Screenshot for problem

1 2 3 4 5 6 7

nul800sebastiaan commented 4 years ago

I can reproduce this, to test, I copied en_us.xml and renamed it to ar-sa.xml, then I changed line 2 to: <language alias="ar_sa" intName="Arabic (SA)" localName="Arabic (SA)" lcid="" culture="ar-SA">

Here's the full error I get:

An error occured
The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'.

Exception Details
System.InvalidOperationException: The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'.
Stacktrace
Inner Exception
System.ArgumentOutOfRangeException: Specified time is not supported in this calendar. It should be between 04/30/1900 00:00:00 (Gregorian date) and 11/16/2077 23:59:59 (Gregorian date), inclusive. Parameter name: time
at System.Globalization.UmAlQuraCalendar.CheckTicksRange(Int64 ticks)
   at System.Globalization.UmAlQuraCalendar.GetDatePart(DateTime time, Int32 part)
   at System.Globalization.UmAlQuraCalendar.GetYear(DateTime time)
   at System.DateTimeFormat.FormatCustomized(DateTime dateTime, String format, DateTimeFormatInfo dtfi, TimeSpan offset)
   at System.DateTimeFormat.Format(DateTime dateTime, String format, DateTimeFormatInfo dtfi, TimeSpan offset)
   at System.DateTimeFormat.Format(DateTime dateTime, String format, DateTimeFormatInfo dtfi)
   at Newtonsoft.Json.Converters.IsoDateTimeConverter.WriteJson(JsonWriter writer, Object value, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable(JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
   at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)
   at System.Net.Http.Formatting.JsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)
   at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Umbraco.Web.WebApi.AngularJsonMediaTypeFormatter.<WriteToStreamAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.WebHost.HttpControllerHandler.<WriteBufferedResponseContentAsync>d__22.MoveNext()

I'm afraid I am not sure what to do with this, it seems like Newtonsoft.Json doesn't know how to handle UmAlQuraCalendar maybe? Not sure.

The only thing I can think of at the moment is to do your translations in the English xml file instead, so most things are translated but the date/time format will be in an English format.

steroberts89 commented 4 years ago

My guess is either the create date or modified date is set to 01/01/0001 00:00:00, and that date cannot be represented in an UmAlQuraCalendar when newtonsoft tries to serialize it.

System.ArgumentOutOfRangeException: Specified time is not supported in this calendar. It should be between 04/30/1900 00:00:00 (Gregorian date) and 11/16/2077 23:59:59 (Gregorian date), inclusive. Parameter name: time

https://stackoverflow.com/a/26889493

stevemegson commented 4 years ago

I think the problem is when we create an IsoDateTimeConverter here. Without a culture specified, it defaults to the current culture. Then, as @steroberts89 says, it can't serialize DateTime.MinValue. Even given a recent date to serialize, the client will interpret the string as a Gregorian date and further hilarity ensues.

I think that just needs to become

r.SerializerSettings.Converters.Add(
new IsoDateTimeConverter
{
   DateTimeFormat = _format,
   Culture = CultureInfo.InvariantCulture
});
umbrabot commented 3 years ago

Hiya @bassemelkadeem,

Just wanted to let you know that we noticed that this issue got a bit stale and might not be relevant any more.

We will close this issue for now but we're happy to open it up again if you think it's still relevant (for example: it's a feature request that's not yet implemented, or it's a bug that's not yet been fixed).

To open it this issue up again, you can write @umbrabot still relevant in a new comment as the first line. It would be super helpful for us if on the next line you could let us know why you think it's still relevant.

For example:

@umbrabot still relevant This bug can still be reproduced in version x.y.z

This will reopen the issue in the next few hours.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

monais commented 3 years ago

Hi @bassemelkadeem,

I have multi language website and i am facing an issue with Arabic language website. By default my website is in English (en-US) and i've created Arabic language from Settings > Languages; it created a copy of the whole template. I've filled arabic contents and added domain name from Home node Culture and Hostnames, English website is working fine but when i click on arabic website, it shows 404 error.

Please assist.

Thanks Mona

bassemelkadeem commented 3 years ago

Hi Mona, try to follow this documentation link: https://our.umbraco.com/Documentation/Fundamentals/Backoffice/Variants/

monais commented 3 years ago

Dear Bassem,

Thanks for the quick reply, i did followed all the steps mentioned in the link you provided. But i don't know why Arabic version is not working, redirecting to 404 page.

Plz assist.

bassemelkadeem commented 3 years ago

Kindly follow this steps i made this steps in all my websites and they work well or you can attach what you doing so i can help you

1 2 3 4 5

monais commented 3 years ago

Dear Bassem,

Please check the following screenshots FYI. Plz assist. Is there anything else to do ? 2 1 3 4

bassemelkadeem commented 3 years ago

Do you allow vary by culture for document type and fields that you need to be vary if it is still appear to you just communicate with me on LinkedIn

7 8 6

monais commented 3 years ago

Dear Bassem,

Yes I did.

On Mon, Jul 5, 2021 at 3:37 PM Bassem Elsaeed @.***> wrote:

Do you allow vary by culture for document type and fields that you need to be vary if it is still appear to you just communicate with me on LinkedIn

[image: 7] https://user-images.githubusercontent.com/13030178/124472345-ad7ea580-dda6-11eb-968e-bd2f2c474cfe.png [image: 8] https://user-images.githubusercontent.com/13030178/124472348-ae173c00-dda6-11eb-9934-5df6d306958c.png [image: 6] https://user-images.githubusercontent.com/13030178/124472342-ac4d7880-dda6-11eb-847f-ace83580f803.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/umbraco/Umbraco-CMS/issues/7278#issuecomment-874079625, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGXTUNV3UDWFC2QID7EWBBLTWGRPFANCNFSM4JVXGOFQ .

--

Best Regards, Khwaja Mohammad Monis Web & Graphic Designer +966-551448247

DISCLAIMER: Please be advised that the information contained herein is confidential and intended only for use by the individual stated above. If you are not the named recipient, you are hereby notified that any disclosure, distribution, dissemination or copying is prohibited. If the information has been directed to you in error, please contact the sender immediately. Whilst we believe that this email and any attachments are virus free, it is the responsibility of the recipient to ensure this and we do not accept any responsibility for loss or damage that may arise from the use of this email or its content.

monais commented 3 years ago

Dear Bassem,

Unable to message you on Linkedin as its asking for Premium membership which i don't have.

Please assist.