Score:1

Error: Call to undefined function drush_shift()

us flag

We recently moved to Drupal 9.3.0 with a composer file layout and Drush 11.0. We make use of Drush Scripts to execute website functions from Crontab. One specific case is sending a newsletter email early each morning.

I receiving the subject error from a Drush Script that has been running for years. The script is executed by moving into the webroot directory of the website and running drush scr email_script.php arg1 arg2. The first thing the Drush Script does is pull the arguments from the command line using drush_shift() but this function is not defined. I'm not sure how to proceed in debugging this.

cn flag
You probably don't need to debug anything, the function was deprecated and removed which is why your script can't use it. It's used to get command line arguments so you can refactor your scripts to use `\Drush::input()` or `$_SERVER['argv']` instead
Score:2
us flag

drush_shift() has been deprecated and removed per @Clive -- Thanks!

In my case I changed:

$arg1 = drush_shift();
$arg2 = drush_shift();

to

$arg1 = $_SERVER['argv'][3];
$arg2 = $_SERVER['argv'][4];
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.