Problem/Motivation

Unable to execute drush aa in Drupal 10.3.6.

Drush version : 13.3.0.0

Steps to reproduce

Execute drush aa and the output generates the following:

Error: Call to undefined method Symfony\Component\Console\Helper\FormatterHelper::strlenWithoutDecoration() in Drupal\site_audit\Renderer\Console->centerText() (line 94 of modules/contrib/site_audit/src/Renderer/Console.php)

Proposed resolution

Make sure strlenWithoutDecoration() is defined or use an alternate method.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork site_audit-3481856

Command icon 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

uberhacker created an issue. See original summary.

uberhacker’s picture

Issue summary: View changes
uberhacker’s picture

Issue summary: View changes
ushma’s picture

Assigned: Unassigned » ushma

ushma’s picture

StatusFileSize
new1.28 KB

I have created an MR to replace the deprecated method with removeDecoration(). Attached the patch for the same. Please review.

ushma’s picture

Assigned: ushma » Unassigned
Status: Active » Needs review
ushma’s picture

StatusFileSize
new859 bytes

By mistake uploaded wrong patch above. Please find below the correct patch for the issue.

uberhacker’s picture

StatusFileSize
new3.45 KB

Thank you for the patch https://www.drupal.org/u/ushma. Unfortunately, #8 didn't work for me. I have attached another patch that works for Drupal 10.4.5 and Drush 13.4.0.0.

camerongreen’s picture

Just testing out this module.

Running the first command on https://www.drupal.org/project/site_audit says "Command ac is not defined":
drush ac --html --detail > ~/Desktop/report.html

First command in Readme.md "drush site_audit:audit" or any of the Examples from drush audit -h such as "drush audit watchdog" returns an error 'The "report" argument does not exist'.

If I try "drush audit:list" to find a valid report I get the error listed in this issue.

I like the concept for a module, but seems unusable.

romainj’s picture

Patch #9 works for me. Thanks

mattyb’s picture

Thanks UberHacker Patch #9 worked for me using Drupal: 10.3.13, PHP 8.3

the_g_bomb’s picture

Status: Needs review » Reviewed & tested by the community

I have applied this patch as a part of a patch cocktail to get site_audit working locally.

I can confirm this patch resolves the issue we were experiencing.

### Environment:
- Drupal 10.4.8
- Site Audit: 4.0.x-dev

### Error Before Patch:

[error] Error: Call to undefined method Symfony\Component\Console\Helper\FormatterHelper::strlenWithoutDecoration() in Drupal\site_audit\Renderer\Console->centerText() (line 95 of /var/www/html/web/modules/contrib/site_audit/src/Renderer/Console.php)

### After Applying Patch:
The error is resolved. The patch correctly updates the code to use `Helper::removeDecoration()` instead of the deprecated `FormatterHelper::strlenWithoutDecoration()` method. This ensures compatibility with current versions of Symfony Console component.

froboy’s picture

I applied the patch from #9 and ran into another error:

TypeError: Symfony\Component\Console\Output\Output::writeln(): Argument #1 ($messages) must be of type Traversable|array|string, null given, called in /var/www/html/src/Renderer/Console.php on line 268 in /var/www/html/vendor/symfony/console/Output/Output.php on line 103 #0 /var/www/html/src/Renderer/Console.php(268): Symfony\Component\Console\Output\Output->writeln()

The TypeError happens because Symfony\Component\Console\Helper\Table::render() returns void, and the code passed that into writeln().

I fixed both occurrences in src/Renderer/Console.php:
src/Renderer/Console.php:195
src/Renderer/Console.php:268

  • froboy committed bebed441 on 4.x
    [#3481856] Fix "Call to undefined method" on drush aa
    
froboy’s picture

Thanks all. Merged to 4.x. Release pending.

froboy’s picture

Version: 4.1.1 » 4.1.2
Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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