I am programmatically saving a package and I can't get the newly created ID in a proper way, although I could use some technique to get last inserted id from the db, this is hardly the best way of doing so, so attached is a patch that accepts the package by reference and adds the id if it's an insert.

It also removes the casting to object inside the function and casts it before running it only in the single place where the variable is an array.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hanoii’s picture

Status: Active » Needs review
FileSize
806 bytes
hanoii’s picture

FileSize
1.08 KB

Attached a wrong patch.

The last submitted patch, 1: 2455137-1-allow-format-top-level.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 2: 2456033-1-package-save-by-reference.patch, failed testing.

hanoii’s picture

I think the tests are failing for some other reason to be honest.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: 2456033-1-package-save-by-reference.patch, failed testing.

hanoii’s picture

strange, I tried running this test locally, and it passed

TR’s picture

Status: Needs work » Needs review

I think there might have been a change in core, I haven't had time to track that down yet. Regardless, the failure of the Cart Links test has nothing to do with this patch.

TR’s picture

Cart Lists tests are running green again, so I triggered a retest for this patch. Let's see what happens.

hanoii’s picture

FileSize
1.08 KB

Re-rolling