Adding some debug in the MemoryLimitPolicyCommands.php to print the command name when the command-event hook is triggered, it seems some commands are not triggering.

$ drush cget memory_limit_policy.settings
string(10) "cget"
header: true
$ drush cr
[success] Cache rebuild complete.

After more research, it appears the commands exposed by Drush in src/Commands are not triggering the hook. The contrib commands and the commands exposed by Drush in src/Drupal/Commands are properly triggering the hook.

An issue has been created in Drush issue queue.

Comments

vbouchet created an issue. See original summary.

vbouchet’s picture

As per https://github.com/drush-ops/drush/issues/5133, we can't really do anything here. Our file will never be loaded early enough for the alteration to apply. Need to document the limitation.

  • vbouchet committed 0bde673 on 8.x-1.x
    Issue #3276442: Drush constraint is not working for some commands
    
vbouchet’s picture

Status: Active » Closed (works as designed)

I added a message about the limitation in the config form of the Drush constraint plugin.

The workaround for these commands it probably to fallback to the usual way of altering memory limit via settings.php

if (PHP_SAPI === 'cli') {
  ini_set('memory_limit', '512M');
}