Problem/Motivation
On Drush 14, every Search API Drush command that logs a success message throws:
Log level "success" does not exist.
CommandHelper::logSuccess() calls $this->logger->success() when the logger implements Drush\Log\SuccessInterface. In Drush 14, DrushLoggerManager still implements that interface, but success() is deprecated and the underlying Drush\Log\Logger no longer defines a "success" level, so consolidation/log throws.
Impact:
drush search-api:indexthrows before the batch starts, so nothing gets indexed.search-api:reset-tracker,search-api:rebuild-tracker,search-api:clear,search-api:set-index-server,search-api:enableandsearch-api:disabledo the work for the first index, then throw. Remaining indexes are skipped and the command exits with an error.
Drush 14 conflicts with core < 11.3, so this affects Drupal 11.3+ and Drupal 12 sites running Drush 14. UI and cron indexing are not affected.
Reproduced on Drupal 12, PHP 8.5, Drush 14.x-dev.
Steps to reproduce
- Drupal 12 (or 11.3+) with Drush 14 (reproduced on 14.x-dev).
- Enable Search API with an index attached to a server.
- Create some content and run
drush search-api:index. - The command fails with
Log level "success" does not exist.
Proposed resolution
Log at "notice" instead. Drush displays "notice" at normal verbosity on Drush 12, 13 and 14, so the message stays visible without -v. Loggers that are not Drush are unchanged.
/**
* Logs a success message.
*
- * Needed because Drush has a custom "success" log level that is incompatible
- * with other loggers, but doesn't display "info" messages by default.
+ * Drush does not display "info" messages by default, so use "notice" for
+ * Drush loggers. (Drush 14 removed its custom "success" log level.)
*
* @param string $message
* The message to log.
*/
protected function logSuccess(string $message) {
if ($this->logger instanceof SuccessInterface) {
- $this->logger->success($message);
+ $this->logger->notice($message);
}
else {
$this->logger->info($message);
}
}
On Drush 12/13 the output label changes from [success] to [notice].
Remaining tasks
- Open an MR from the issue fork with the change above.
- Review and commit.
Issue fork search_api-3636570
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
metasimComment #4
metasimMR is up with the change from the issue summary.
The
phpunitjob fails onCache set skips aborted query(Error: Call to a member function getCacheMetadata() on null). This also fails on8.x-1.xat the same base commit (ac55c0b1, pipeline 1036742), so it is not caused by this change. phpcs, phpstan and the other validate jobs pass.