
Problem/Motivation
Using Drupal 9.1.*
Error: Call to a member function getStorage() on null in Drupal\crypto_markets\Controller\CryptoMarketsController->content() (line 145 of /Users/netgeek/Sites/public/crypto/web/modules/custom/crypto_markets/src/Controller/CryptoMarketsController.php)
#0 [internal function]: Drupal\crypto_markets\Controller\CryptoMarketsController->content()
#1 /Users/netgeek/Sites/public/crypto/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#2 /Users/netgeek/Sites/public/crypto/web/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#3 /Users/netgeek/Sites/public/crypto/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#4 /Users/netgeek/Sites/public/crypto/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#5 /Users/netgeek/Sites/public/crypto/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#6 /Users/netgeek/Sites/public/crypto/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#7 /Users/netgeek/Sites/public/crypto/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#8 /Users/netgeek/Sites/public/crypto/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#9 /Users/netgeek/Sites/public/crypto/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#10 /Users/netgeek/Sites/public/crypto/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#11 /Users/netgeek/Sites/public/crypto/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#12 /Users/netgeek/Sites/public/crypto/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#13 /Users/netgeek/Sites/public/crypto/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /Users/netgeek/Sites/public/crypto/web/core/lib/Drupal/Core/DrupalKernel.php(706): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /Users/netgeek/Sites/public/crypto/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#16 {main}
.
Steps to reproduce
visit currencies/binance-coin/markets
Comments
Comment #2
netgeek123 CreditAttribution: netgeek123 commentedJust poking around trying to find an answer to this one I found this in Drupal issues;
https://www.drupal.org/project/drupal/issues/3080793
$storage = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId());
Is this the proper way to handle entityTypeManager?
Comment #3
netgeek123 CreditAttribution: netgeek123 commentedI have added a pattern under PathAuto (URL Alias) and I am now getting two separate errors.
currencies/[node:title]/markets
The original remains the same.
Second new error happening at the same time;
Comment #4
netgeek123 CreditAttribution: netgeek123 commentedComment #6
babusaheb.vikas CreditAttribution: babusaheb.vikas commentedHi netgeek123,
I have fixed above error in 8.x-5.2 version of crypto_distribution.
Since, you are already updated your Drupal to 9.1 so you need to replace only "CryptoMarketsController.php" file of crypto_markets module. You can also track new changes from https://git.drupalcode.org/project/crypto_distribution/commit/0b5f3c8
Comment #7
netgeek123 CreditAttribution: netgeek123 commentedFixed and works as expected.
Thanks!
Comment #8
babusaheb.vikas CreditAttribution: babusaheb.vikas commentedComment #9
babusaheb.vikas CreditAttribution: babusaheb.vikas commented