Closed
Bug 487059
Opened 16 years ago
Closed 14 years ago
clearUserPref shouldn't throw if a pref doesn't have a user value
Categories
(Core :: Preferences: Backend, defect)
Core
Preferences: Backend
Tracking
()
RESOLVED
FIXED
mozilla6
People
(Reporter: dao, Assigned: dao)
References
Details
(Keywords: dev-doc-complete, relnote)
Attachments
(1 file, 1 obsolete file)
21.55 KB,
patch
|
benjamin
:
review+
benjamin
:
superreview+
|
Details | Diff | Splinter Review |
The current behavior isn't documented and requires others to
1) make a fragile assumption about the pref's default value,
2) check prefHasUserValue first, or
3) use try-catch, which means a useful exception will be missed if the pref doesn't exist at all.
1) and 3) are harmful; 2) is OK but not widely used, and it shouldn't be necessary either.
Attachment #371260 -
Flags: superreview?(benjamin)
Attachment #371260 -
Flags: review?(benjamin)
Comment 1•16 years ago
|
||
Comment on attachment 371260 [details] [diff] [review]
patch
How is this better than never throwing at all? It seems odd to say that the presence or absence of a default pref would affect an API named "clearUserPref".
Assignee | ||
Comment 2•16 years ago
|
||
Either way is fine by me. I covered only one case, because that was the one I cared about, and I thought it would be a less controversial change.
For prefs that are expected to have a default value, that exception seemed useful to me, as it means something went wrong (e.g. mistyped pref name). For prefs that don't have a default value, it's pretty much useless. But one could argue that you shouldn't unconditionally call clearUserPref in that case.
Attachment #371910 -
Flags: superreview?(benjamin)
Attachment #371910 -
Flags: review?(benjamin)
Updated•16 years ago
|
Attachment #371910 -
Flags: superreview?(benjamin)
Attachment #371910 -
Flags: superreview+
Attachment #371910 -
Flags: review?(benjamin)
Attachment #371910 -
Flags: review+
Updated•16 years ago
|
Attachment #371260 -
Flags: superreview?(benjamin)
Attachment #371260 -
Flags: review?(benjamin)
Attachment #371260 -
Flags: review-
Assignee | ||
Updated•16 years ago
|
Keywords: checkin-needed
Assignee | ||
Comment 3•16 years ago
|
||
Status: NEW → RESOLVED
Closed: 16 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.2a1
Comment 4•15 years ago
|
||
Is there a reason this never landed on branch? I just got hit by this throwing on branch but not on trunk.
Comment 5•15 years ago
|
||
Nobody asked for it to land there. I do not think it should.
Comment 6•15 years ago
|
||
Indeed, it's an API change and it came late in the cycle, so it's not really suitable for the branch.
Comment 7•15 years ago
|
||
Verified fixed on trunk with Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2a1pre) Gecko/20090601 Minefield/3.6a1pre ID:20090601031227.
Status: RESOLVED → VERIFIED
Updated•15 years ago
|
Attachment #371260 -
Attachment is obsolete: true
Comment 8•15 years ago
|
||
The current behavior is documented:
https://developer.mozilla.org/en/Code_snippets/Preferences
Note that clearUserPref() will throw an exception unless the pref has a user value; you must test prefHasUserValue(pref) first, then clear the value with clearUserPref().
And this behavior has been around for many years.
Have you checked to verify this won't break any extensions? I know it broke mine.
Assignee | ||
Comment 9•15 years ago
|
||
(In reply to comment #8)
> The current behavior is documented:
>
> https://developer.mozilla.org/en/Code_snippets/Preferences
You're citing a sentence hidden deep on a code snippets page. I wouldn't call that documentation.
Assignee | ||
Comment 10•15 years ago
|
||
Also, that sentence was added after this patch landed...
Comment 11•15 years ago
|
||
As per the discussion in dev-planning (http://groups.google.com/group/mozilla.dev.platform/browse_thread/thread/c083cf990ff2f03f#) this change should be backed out immediately on mozilla-central, mozilla-1.9.2 and the mozilla-1.9.2 beta relbranch.
Comment 12•15 years ago
|
||
https://developer.mozilla.org/en/Code_snippets/Preferences page should be backed too, because it was modified 22:20, 27 Oct 2009.
Comment 13•15 years ago
|
||
We should do any work on bug 524995. Lets move it over there.
Comment 14•15 years ago
|
||
> The current behavior isn't documented
nsIPrefBranch.idl says:
218 * @return Other The preference does not exist or have a user set value.
as the last sentence of the comment for clearUserPref, and has done so since revision 1.16 (October 2001). How much more documented can you get?
Assignee | ||
Comment 15•15 years ago
|
||
That was half a year ago, but I think I was looking for "throws", so I was probably misreading the idl. Besides, while "The preference does not exist" is quite clear, I still find it questionable whether "have a user set value" here should mean the same as defined for prefHasUserValue, as this makes an explicitly set value matching the default value an exception case here. That's the most painful part that my first patch addressed specifically.
Comment 16•15 years ago
|
||
On the relbranch:
http://hg.mozilla.org/releases/mozilla-1.9.2/rev/3b49c063bb42
status1.9.2:
--- → beta1-fixed
Comment 17•15 years ago
|
||
(In reply to comment #16)
> On the relbranch:
> http://hg.mozilla.org/releases/mozilla-1.9.2/rev/3b49c063bb42
Wrong bug Shawn.
Comment 18•15 years ago
|
||
(In reply to comment #17)
> Wrong bug Shawn.
Good catch.
status1.9.2:
beta1-fixed → ---
Assignee | ||
Updated•15 years ago
|
Status: VERIFIED → REOPENED
Resolution: FIXED → ---
Updated•15 years ago
|
QA Contact: preferences → preferences-backend
Assignee | ||
Comment 19•14 years ago
|
||
Status: REOPENED → RESOLVED
Closed: 16 years ago → 14 years ago
Resolution: --- → FIXED
Target Milestone: mozilla1.9.2a1 → mozilla6
Comment 20•14 years ago
|
||
(In reply to comment #19)
> http://hg.mozilla.org/mozilla-central/rev/56d482ecbbc6
We decided to land this again? Is anybody planning on posting to the add-on compatibility blog about this?
Assignee | ||
Comment 21•14 years ago
|
||
I did, as this was only backed out because it landed in a beta phase. I can communicate the change, but I don't expect significant add-on breakage.
Comment 22•14 years ago
|
||
You have no way to predict add-on breakage.
This definitely needs to be communicated to the add-on team.
Assignee | ||
Comment 23•14 years ago
|
||
(In reply to comment #22)
> You have no way to predict add-on breakage.
I surely have. I searched through add-ons, now and in the past, and even without examining every occurrence (there are many of them), you get a good sense of how this is usually used in the wild. I know an add-on of yours was relying on the exception, but this is by no means the common case.
Updated•14 years ago
|
tracking-firefox6:
--- → +
Comment 24•14 years ago
|
||
(In reply to comment #23)
> I surely have. I searched through add-ons, now and in the past, and even
> without examining every occurrence (there are many of them), you get a good
> sense of how this is usually used in the wild. I know an add-on of yours was
> relying on the exception, but this is by no means the common case.
This only applies to add-ons hosted on AMO which are a fraction of all available add-ons. I will CC Jorge and Justin just to make sure we get the right message send out to all necessary channels.
Comment 25•14 years ago
|
||
Thank you for the ping. I'll make a note of this for the Firefox 6 upgrade cycle. I assume the milestone is correct and this won't make it to Firefox 5.
Updated•13 years ago
|
status-firefox6:
--- → fixed
Keywords: dev-doc-needed
Comment 26•13 years ago
|
||
Documentation updated:
https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIPrefBranch#clearUserPref()
And mentioned on Firefox 6 for developers.
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•