In hook_init() the module calls the below function which does a variable_set for the blazy library installation status.

function lazy_is_library_installed() {
  $blazy = libraries_detect('blazy');
  variable_set('lazy_library_installed', $blazy['installed']);

  return $blazy['installed'];
}

variable_set writes data into the 'variable' table, and clears the entire variable cache on every page request.

At the very least, there should be a check to see if the current value of the variable matches the blazy library status, avoiding the need for a variable update.

CommentFileSizeAuthor
#2 variable_set-3035906-2.patch531 bytesgianani
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gianani created an issue. See original summary.

gianani’s picture

FileSize
531 bytes

The below patch only updates the variable if its value has changed.

nikolas.tatianenko’s picture

Issue tags: +epam-contrib-2019.03
IreneV’s picture

Status: Active » Reviewed & tested by the community

Reviewed and tested - works OK!

ram4nd’s picture

Issue tags: -epam-contrib-2019.03

  • osman committed d507081 on 7.x-1.x
    Issue #3035906 by gianani: Remove/reduce variable_set usage in hook_init
    
osman’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the patch.

Status: Fixed » Closed (fixed)

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