Fix BaseResourceModel.save to not assume that options is non-null.

Review Request #13612 — Created March 5, 2024 and submitted

Information

Review Board
release-7.x

Reviewers

In the vast majority of cases, calling save() on a resource will
either include a caller-provided options object, or will get the
default value from being unspecified. The one case I've found where this
is not the case is Backbone.Collection.create(), which explicitly
calls save() on the object with a null options.

This change bullet-proofs that so we don't crash.

Saw that I could use code that called Collection.create without it
hitting an error.

Summary ID
Fix BaseResourceModel.save to not assume that options is non-null.
In the vast majority of cases, calling `save()` on a resource will either include a caller-provided `options` object, or will get the default value from being unspecified. The one case I've found where this is not the case is `Backbone.Collection.create()`, which explicitly calls `save()` on the object with a `null` options. This change bullet-proofs that so we don't crash. Testing Done: Saw that I could use code that called `Collection.create` without it hitting an error.
49d8aca06645b12c8a43654be84528aa096be03c
Description From Last Updated

You can do options ||= {}; Alternatively, if we only want to do this for null/undefined (rather than falsy values), …

chipx86chipx86
maubin
  1. Ship It!
  2. 
      
chipx86
  1. 
      
  2. Show all issues

    You can do options ||= {};

    Alternatively, if we only want to do this for null/undefined (rather than falsy values), ??= works.

  3. 
      
david
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-7.x (8d5c6c8)
Loading...