Problem/Motivation

After analyzing a custom module via the web UI i get this output:
progress bar is shown

Steps to reproduce

Installed the dev version via composer require 'drupal/upgrade_status:3.x-dev@dev'.
Installed core dev via composer require --dev drupal/core-dev:8.9.14.
Go to the admin page, check a custom module, run scan.

Some context on the installed packages:

  • drupal/core: 8.9.14
  • drupal/core-dev: 8.9.14
  • phpstan/phpstan: 0.12.86
  • mglaman/phpstan-drupal: 0.12.9
  • phpstan/phpstan-deprecation-rules: 0.12.6
  • phpunit/phpunit: 7.5.20

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

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

bahuma20 created an issue. See original summary.

bahuma20’s picture

Issue summary: View changes

Added installed package versions

bahuma20’s picture

StatusFileSize
new159.91 KB

I've added the "--no-progress" flag to the command in DeprecationAnalyzer.php.
https://git.drupalcode.org/issue/upgrade_status-3213598/-/commit/2f60fb0...

The progress bar is now gone, but the outcome still shows "PHPStan failed":
phpstan failed

gábor hojtsy’s picture

Status: Active » Postponed (maintainer needs more info)

Hm, have not seen this before :/ Can you try https://github.com/mglaman/drupal-check on the same module to see if that worked? Thanks!

bahuma20’s picture

Status: Postponed (maintainer needs more info) » Active
StatusFileSize
new22.23 KB

I already did this.
drupal-check gave me this output:

status bar and no error message

A status bar and the "No errors" message.

I get the same output on every module. It's not a modules fault...

Maybe the phpstan released a new version that generates progress bars and different output that cannot be parsed by the upgrade_status module?

mglaman’s picture

Progress bars always print to stderr

            $postFileCallback = function (int $step) use($errorOutput, &$progressStarted, $allAnalysedFilesCount, $filesCount, &$fileOrder) : void {
                if (!$progressStarted) {
                    $errorOutput->getStyle()->progressStart($allAnalysedFilesCount);
                    $errorOutput->getStyle()->progressAdvance($allAnalysedFilesCount - $filesCount);
                    $progressStarted = \true;
                }
                $errorOutput->getStyle()->progressAdvance($step);

Based on the above output, though, the raw errors were returned due to an unexpected error. See https://git.drupalcode.org/project/upgrade_status/-/blob/8.x-3.x/src/Dep...

gábor hojtsy’s picture

Status: Active » Postponed (maintainer needs more info)

The screenshots look strange because if there is valid JSON returned, we take that as a valid return value. Visually looking it does not seem like what you got is invalid JSON?! Either way, if you still have sites to port, it would be great to try with 8.x-3.11 which changes how phpstan is executed.

kt2ssh’s picture

StatusFileSize
new155.17 KB

I got the same problem and found the unexpected <?php tag from phpstan result.

unexpected php onpen tag

fgm’s picture

Status: Postponed (maintainer needs more info) » Active

It looks like a similar problem I just met: I have a custom theme that extends a base theme but does not include a single line of PHP, so when running an upgrade_status 4.0 scan, I get this error

PHPStan command failed:
/opt/homebrew/Cellar/php@8.1/8.1.21/bin/php /Users/fgm/src/OSInet/org/riff/blog/./vendor/bin/phpstan analyse --memory-limit=1500M --error-format=json --configuration=/tmp/upgrade_status/deprecation_testing.neon /Users/fgm/src/OSInet/org/riff/blog/web/themes/osinet/riffblogt

Command output:
Empty.

Command error:
! [NOTE] No files found to analyse. [WARNING] This will cause a non-zero exit code in PHPStan 2.0.

Adding an almost empty (theme).theme file fixed the issue for me.

gábor hojtsy’s picture

Category: Bug report » Support request

That there was no file found to analyse sounds like a legitimate problem. At least it does not say everything was ok because there was nothing to check if it was ok. I guess for themes that could be a realistic scenario that no PHP file was found, but it would only be reasonable for modules very rarely. Should we have a special case for this situation? We would still need to somehow surface that there was no file scanned, but maybe a nicer error handler for this case?

fgm’s picture

I think one could imagine a module only consisting of libraries, so with a mymodule.libraries.yml and a bunch of CSS / JS files pointed by those, so no PHP code either.

That's probably not common but does not have to be an error. It's a bit similar to the "theme extends a base theme, only changing CSS / JS".

gábor hojtsy’s picture

Title: PHPStan failed without errors, progress bar shown » PHPStan failed with "No files found to analyse"

Let's focus this issue on the no files case then. The others don't seem to have more info on why they would happen.

gábor hojtsy’s picture

However how we represent this situation is a question. That no file was found could be an error or it could be a legitimate thing to ignore. So we should IMHO report it, but maybe not as a raw error, but more like a warning level? It would still show it as one problem to resolve though, so those that want to make that go away would "need to" add an empty module file or somesuch for the error to go away. We can maybe discourage that in the message?

tobby’s picture

FWIW, I'm having the same issue. I've got a module with only my_module.info.yml and my_module.libraries.yml files, so I get the "No files found to analyse" warning. I created a temporary my_module.module file, and I was able to validate that the module is indeed D10-ready.

I agree with Gábor -- maybe this "no file" issue can be a warning or even an info level. And place it in a "Compatible with next major Drupal core version (with caveats)" category instead of "Fix manually". My thinking is that a module with no executable code is technically compatible with Drupal 10...

sahilgidwani’s picture

Version: 8.x-3.x-dev » 4.0.0
Category: Support request » Bug report
Priority: Normal » Critical
StatusFileSize
new114.09 KB
new26.66 KB
new75.31 KB
  1. I am getting the error for PHP Stan command failed, as mentioned in the issue description, but not getting any error related to "No files found to analyse".
    PHP stan error
  2. When I debugged the analyze method of the DeprecationAnalyzer class, I found that the Process class is not returning output on line 373, and as a result, we are getting null in $json.
    json null error
  3. Further, the condition check implemented for checking any JSON errors is returning true, and it is showing errors, although the PHP stan command is being executed successfully without any errors.
    get output null error

Anyone can please look into this and implement a solution to resolve the issue mentioned above.