At release 8.1.6 the file UserServiceProvider.php was added, but it is a empty file. It throws a exception at DrupalKernel::discoverServiceProviders() (in line 568 from DrupalKernel.php).

The error is because that method calls class_exists, then composer autoload search class definition in file, but don't discovers.

CommentFileSizeAuthor
#9 2764699.patch601 bytescatch

Comments

lainosantos created an issue. See original summary.

lainosantos’s picture

Project: Core development » Drupal core
Version: » 8.1.6
Component: Code » base system
cilefen’s picture

cilefen’s picture

Did you delete core/ and vendor/ when you upgraded?

alexpott’s picture

What's interesting about this is why isn't DrupalCI failling over with the same fail. Or my own local dev environment - I have the same empty files.

alexpott’s picture

@ianosantos thanks for the bug report. Any additional information you could give on your environment / steps to reproduce would be fantastic.

alexpott’s picture

Steps I've taken to try to reproduce the bug:

  1. Cloned Drupal 8.1.5
  2. Run composer install
  3. Installed standard profile
  4. Logged in and check admin/reports/status and confirmed on 8.1.5
  5. Checked out Drupal 8.1.6
  6. Refreshed admin/reports/status
  7. Cleared caches

This error is not seen...

@ianosantos - just wondering - are you doing anything special with the autoloader?

lainosantos’s picture

@alexpott Yes, I do it.

I use the package drupal/core (https://packagist.org/packages/drupal/core) as a dependency, because i created a symfony blundle for use Drupal as CMS to my company's systems. Then, i do core update by 'composer update drupal/core'.

The problem is because I boot and handle DrupalKernel inside my bundle, and at that moment the symfony has added the \Symfony\Component\Debug\DebugClassLoader as class loader (decorates composer autolaod object). This auto load class throws a exception because the file don't have the class definition.

This error only occurs on smfony dev environment, whereas in prod symfony doesn't attach the debug auto loader.

But, this file without class definition violates the PSR-0 and PSR-4.

catch’s picture

Priority: Critical » Major
Status: Active » Needs review
StatusFileSize
new601 bytes

OK that's worth fixing, but doesn't meet our definition of critical bug. Could you try this patch?

alexpott’s picture

Status: Needs review » Needs work

I guess we need to do that for both core/modules/user/src/UserServiceProvider.php and core/modules/user/src/MigratePassword.php

alexpott’s picture

One thing of course that is now weird is that the UserServiceProvider does not implement ServiceProviderInterface ... fortunately this works because...

    foreach ($this->serviceProviders['app'] as $provider) {
      if ($provider instanceof ServiceProviderInterface) {
        $provider->register($container);
      }
    }

However the patch in #9 is changing the behaviour of D8 HEAD, as regardless of the autoloader, class_exists('\Drupal\User\UserServiceProvider') returns FALSE - and now with this patch it will return TRUE.

lainosantos’s picture

Status: Needs work » Fixed
lainosantos’s picture

Status: Fixed » Needs work
lainosantos’s picture

Thank you everyone, this patch fixes the problem.

@catch, excuse me. I really tought that composer autolaod broke on violation from PSR-0 or PSR-4, but it was symfony debug autoload.

@alexpott, it return true is the expected value, isn't is? The symfony debug autoload throws an error when the file don't declares the class, but not only symfony, others autoloaders may do this because this is in accordance with PSRs.

alexpott’s picture

@lainosantos

may do this because this is in accordance with PSRs.

I've read the PSRs - I'm not sure it is in accordance. This might be splitting hairs but the PSRs are about where a file containing a class in the file system should exist. As far as I can see there is nothing that says if the file exists it has to contain the class. In fact, the autoload standard says that autoloading should not throw errors or exceptions. So the symfony debug autoload is the one breaking the standard :)

lainosantos’s picture

@alexpott, you're right :), this isn't explicit rule, but is implicit that the class definition respects the filesystem.

Symfony throws only in dev, for debug purpose and prevent error.

I think that the user should delete the directories before update core, it's the rule while Drupal don't provides it automatically. And not keep file history in code.

lainosantos’s picture

This patch woks.

This issue may be fixed, until they solving drupal core update.

lainosantos’s picture

Status: Needs work » Patch (to be ported)
alexpott’s picture

Status: Patch (to be ported) » Needs review

@lainosantos did you mean to set this patch to "reviewed and tested by the community"?

lainosantos’s picture

@alexpott, excuse me. I thought "Patch (to be ported)" indecated that the patch works for me.

lainosantos’s picture

Hello everyone, This will be fixed in 8.1.9?

lainosantos’s picture

Please, fix this.

alexpott’s picture

@lainosantos if you provide evidence of testing and set the issue to "reviewed and tested by the community" then we can.

lainosantos’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Version: 8.1.6 » 8.1.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed bfd9b82 to 8.3.x and 482ae50 to 8.2.x and a55f7a2 to 8.1.x. Thanks!

  • alexpott committed bfd9b82 on 8.3.x
    Issue #2764699 by catch, lainosantos: class "Drupal\user\...

  • alexpott committed 482ae50 on 8.2.x
    Issue #2764699 by catch, lainosantos: class "Drupal\user\...

  • alexpott committed a55f7a2 on 8.1.x
    Issue #2764699 by catch, lainosantos: class "Drupal\user\...
alexpott’s picture

Priority: Major » Normal

This turned out not to be a major bug.

Status: Fixed » Closed (fixed)

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