Closed Bug 979262 Opened 10 years ago Closed 10 years ago

Store large integer values as strings (you cannot set the XXX pref to the number YYY, as number pref values must be in the signed 32-bit integer range -(2^31-1) to 2^31-1)

Categories

(Calendar :: Internal Components, defect, P1)

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: aryx, Assigned: Fallen)

Details

Attachments

(1 file, 1 obsolete file)

With the latest sources, I saw the following error message when running mozmill tests:

TEST-START | c:\Mozilla\Coding\Code\comm-central\objdir-thunderbird-central\mozilla\_tests\mozmill\stage\testLocalICS.js | testLocalICS
...
setFieldValue: aElement.removeAttribute couldn't remove disabled from null e: TypeError: aElement is null
...
Error: [calICSCalendar] Backup failed, no calendarmanager:[Exception... "you cannot set the calendar.registry.63cd6ba6-89a2-4d79-bfdd-f703b0b9549a.uniquenum pref to the number 1393937451510, as number pref values must be in the signed 32-bit integer range -(2^31-1) to 2^31-1.  To store numbers outside that range, store them as strings.'you cannot set the calendar.registry.63cd6ba6-89a2-4d79-bfdd-f703b0b9549a.uniquenum pref to the number 1393937451510, as number pref values must be in the signed 32-bit integer range -(2^31-1) to 2^31-1.  To store numbers outside that range, store them as strings.' when calling method: [calICalendarManager::setCalendarPref_]"  nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)"  location: "JS frame :: resource://calendar/modules/calProviderUtils.jsm :: cPB_setProperty :: line 796"  data: no]

Seems like the switch to Preferences.jsm (bug 923026) uncovered this type of issue.
As noted on IRC, this problem seems to have been there all along, but made visible with Preferences.jsm. We have a few other calendar properties that use date values.

Possible solutions:

* A wrapper around Preferences.jsm that saves larger integers as a tagged string pref and (de)serializes correctly (con: yet another wrapper function)
* The same, but only in the setProperty part of the calendar manager that saves the prefs (con: might be more places this could fail)


Archaeopteryx, do you want to create the patch for this?
Severity: normal → major
Priority: -- → P2
Attached patch Fix - v1 (obsolete) β€” β€” Splinter Review
This should take care. I've decided not to migrate the preferences from the ics provider, since they will be recreated if unset anwyay.
Assignee: nobody → philipp
Status: NEW → ASSIGNED
Attachment #8389369 - Flags: review?(archaeopteryx)
Priority: P2 → P1
Comment on attachment 8389369 [details] [diff] [review]
Fix - v1

Review of attachment 8389369 [details] [diff] [review]:
-----------------------------------------------------------------

::: calendar/base/src/calCalendarManager.js
@@ +752,5 @@
>          cal.ASSERT(name && name.length > 0, "Pref Name must be non-empty!");
>  
>          let branch = (getPrefBranchFor(calendar.id) + name);
> +
> +        if (typeof value == "number" && (value > MAX_INT || value < MIN_INT || value % 1 != 0)) {

You could use for the latter part: !Number.isInteger(value)
I know it's longer, but boolean.
Attachment #8389369 - Flags: review?(archaeopteryx) → review+
Attached patch Fix - v2 β€” β€” Splinter Review
Tree is closed, here is the patch for checkin.
Attachment #8389369 - Attachment is obsolete: true
Attachment #8391953 - Flags: review+
https://hg.mozilla.org/comm-central/rev/92a0bdf9c37f
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → 3.2
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: