3

I'm seeing the following error when I enable xhprof in Drupal 8 either via Drush or via Composer.

Class 'Drupal\xhprof\RequestMatcher\XHProfRequestMatcher' not found in /var/www/mysite/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 272

I had xhprof working for a day or so, and randomly started seeing this issue. This feels very much like a Symfony/Composer autoloader issue to me, but I'm struggling with a technique or strategy for fixing or troubleshooting this.

The Call Stack feels pretty useless in this context.

xhprof missing class issue

I'm looking for any fix to this issue specifically, but I'm also looking for some technique or strategy for troubleshooting the missing class fatal error. The missing class error seems to keep cropping up for me with Drupal 8. I've tried to trace through the object hierarchy via xdebug, but Drupal 8 and Symfony, have a very abstracted object hierarchy. This makes it nearly impossible to be able to logically backtrack from where the error is thrown.

Why is the class not found, even though the class is definitely here: docroot/modules/contrib/xhprof/src/RequestMatcher/XHProfRequestMatcher.php?

Update:

After trying everything I could think of, I decided to just try and rebuild my VM with:

vagrant reload --provision

Sure enough, the fatal error went away. Is there some cache somewhere that drush or Drupal Console wouldn't have access to? Maybe it has something to do with the RAM or OPCACHE as @cilefen mentioned?

Note that I do not have memcache or redis running on this VM. Per a conversation on the Drupal-VM issue queue I may have been able to solve the problem by restarting PHP or just doing a reload without having to do a --provision.

closed as off-topic by Shawn Conn, Adrian Cid Almaguer, Krishna Mohan, Pierre.Vriens, kenorb Aug 10 '16 at 16:53

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question was caused by a problem that can no longer be reproduced, was solved by a cache clear, or was a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers." – Shawn Conn, Adrian Cid Almaguer, Krishna Mohan, Pierre.Vriens, kenorb
If this question can be reworded to fit the rules in the help center, please edit the question.

  • You may have run out of RAM or memory in you opcache. – cilefen Aug 9 '16 at 17:19
  • I'm still very much interested in why the vagrant reload --provision would have fixed the problem. Clearly there is some caching going on that was not getting reset but what and why and how to approach this problem in the future? Restarting php or reloading the virtual machine feels like a very blunt instrument here. – Justin Levi Winter Aug 10 '16 at 17:48
2

The backtrace what you see could be improved by adding the following settings in your xdebug.ini file:

; Data
xdebug.default_enable = 1           ; bool: The stacktraces will be shown by default on an error event.
xdebug.collect_vars = 1             ; bool: Gather information about which variables are used in a certain scope.
xdebug.show_local_vars=1            ; int: Generate stack dumps in error situations.
xdebug.collect_assignments=1        ; bool: Controls whether Xdebug should add variable assignments to function traces.
xdebug.collect_params=4             ; int1-4: Collect the parameters passed to functions when a function call is recorded.
xdebug.collect_return=1             ; bool: Write the return value of function calls to the trace files.
xdebug.var_display_max_children=256 ; int: Amount of array children and object's properties are shown.
xdebug.var_display_max_data=1024    ; int: Max string length that is shown when variables are displayed.
xdebug.var_display_max_depth=5      ; int: How many nested levels of array/object elements are displayed.
xdebug.show_mem_delta=0             ; int: Show the difference in memory usage between function calls.
xdebug.show_exception_trace=0       ; bool: Show a stack trace whenever an exception is raised.
xdebug.max_nesting_level=200        ; int: Controls the protection mechanism for infinite recursion protection.

This will give you more meaningful data.

Basically you're missing a class, so you should try to clear you caches and rebuild your registry. Also restart memcached/redis if it's in use.

  • These xdebug config settings would affect the fatal php error stacktrace? – Justin Levi Winter Aug 10 '16 at 17:35
  • 1
    @JustinLeviWinter Yes, they'll show you all the variables being passed to the functions and all local variables. All ??? that you've now would be properly populated. – kenorb Aug 10 '16 at 17:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.