I've found that in acl_save_form() function the insert query will be executed multiple times in foreach loop. It is better to build the query in the loop and than execute it only once.

I've created a simple patch, which simply moves the query execution outside of the loop.

Please review.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pc-wurm created an issue. See original summary.

Elin Yordanov’s picture

Sorry for the first patch, it is not correct, please ignore it. I was too much in a hurry.

New patch is attached. Please review.

P.S.: Although the patch was not correct, it passed the tests, that means the tests are not complete.

salvis’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev

Thank you for posting the issue and the patches, pc-wurm! No problem with posting them incrementally.

P.S.: Although the patch was not correct, it passed the tests, that means the tests are not complete.

That's true. Actually, we have no tests at all for the embeddable form. That's why I hesitate to apply patches to code that has been working for years unless it can be shown that there's a problem with it...

I didn't know that db_insert() supported inserting multiple records at once, but your second patch certainly makes sense. Does it make a noticeable difference? Any reviewers/testers out there?

Would you like to contribute some tests for the embeddable form?

D7 is now legacy, and all fixes/patches need to go to D8 first (unless they don't apply), before they can be committed to D7.

Elin Yordanov’s picture

I'd like to contribute writing some tests, but it is not really my strength, sorry.

Elin Yordanov’s picture

Here's the patch re-rolled for 8.x-1.x-dev.

Please review.

Status: Needs review » Needs work

The last submitted patch, 5: acl-save-form-insert-query-optimization-2650302-5.patch, failed testing.

Elin Yordanov’s picture

Sorry, I forgot to split fields() and values() for the query. Attached is a new patch.

Please review.

Status: Needs review » Needs work

The last submitted patch, 7: acl-save-form-insert-query-optimization-2650302-7.patch, failed testing.

salvis’s picture

Status: Needs work » Postponed

  • salvis committed 46905ff on 8.x-1.x
    Issue #2650302 by pc-wurm: acl_save_form() insert query optimization.
    
salvis’s picture

Version: 8.x-1.x-dev » 7.x-1.x-dev
Status: Postponed » Patch (to be ported)

The D8 failure is in the branch. I pushed the patch, thank you, Елин Й.!
(I'm sorry, I haven't been able to insert your name into my editor.)

Now to D7...

salvis’s picture

Status: Patch (to be ported) » Reviewed & tested by the community

#2 will work just fine.

gisle’s picture

Assigned: Elin Yordanov » Unassigned

Patch still need to be pushed to the repo. This must be done by a maintainer, not the author Elin Yordanov.

  • salvis committed 05af5fd on 7.x-1.x
    Issue #2650302 by Elin Yordanov: acl_save_form() insert query...
salvis’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, gisle, I confused myself...

And thank you for the patch, Elin Yordanov!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.