Trash link is a 404 on install because no entity types are enabled

Created on 25 February 2025, 15 days ago

Problem/Motivation

The Trash link throws a 404 post install because there are no entity types enabled.

Steps to reproduce

  1. Install Drupal CMS
  2. Visit the Trash page /admin/content/trash
  3. See you get a 404
  4. Go to /admin/config/content/trash, see that there are no entity types enabled
  5. Enable content
  6. Go to /admin/content/trash and see that it now works

Proposed resolution

  1. Enable node entities by default in Trash config
  2. Add a test for this
πŸ› Bug report
Status

Active

Component

Base Recipe

Created by

πŸ‡¦πŸ‡ΊAustralia pameeela

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @pameeela
  • πŸ‡¦πŸ‡ΊAustralia pameeela

    Looks like this was introduced by πŸ› Fatal when entity type doesn't exist (anymore) Active but this should be handled since node is installed?

  • First commit to issue fork.
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    I started on this, but guess what...Trash breaks the moderated_content view, it turns out, with the following backtrace:

     The website encountered an unexpected error. Try again later.<br><br><em class="placeholder">TypeError</em>: strpos(): Argument #1 ($haystack) must be of type string, Drupal\Core\Database\Query\Condition given in <em class="placeholder">strpos()</em> (line <em class="placeholder">141</em> of <em class="placeholder">modules/contrib/trash/src/ViewsQueryAlter.php</em>).
    Drupal\trash\ViewsQueryAlter-&gt;alterQueryForEntityType() (Line: 101)
    Drupal\trash\ViewsQueryAlter-&gt;alterQuery() (Line: 169)
    trash_views_query_alter()
    call_user_func_array() (Line: 355)
    Drupal\Core\Extension\ModuleHandler-&gt;Drupal\Core\Extension\{closure}() (Line: 307)
    Drupal\Core\Extension\ModuleHandler-&gt;invokeAllWith() (Line: 354)
    Drupal\Core\Extension\ModuleHandler-&gt;invokeAll() (Line: 1473)
    Drupal\views\Plugin\views\query\Sql-&gt;alter() (Line: 1376)
    Drupal\views\ViewExecutable-&gt;build() (Line: 393)
    Drupal\views\Plugin\views\display\PathPluginBase-&gt;execute() (Line: 198)
    Drupal\views\Plugin\views\display\Page-&gt;execute() (Line: 1690)
    Drupal\views\ViewExecutable-&gt;executeDisplay() (Line: 81)
    Drupal\views\Element\View::preRenderViewElement()
    call_user_func_array() (Line: 107)
    Drupal\Core\Render\Renderer-&gt;doTrustedCallback() (Line: 825)
    Drupal\Core\Render\Renderer-&gt;doCallback() (Line: 387)
    Drupal\Core\Render\Renderer-&gt;doRender() (Line: 203)
    Drupal\Core\Render\Renderer-&gt;render() (Line: 238)
    Drupal\Core\Render\MainContent\HtmlRenderer-&gt;Drupal\Core\Render\MainContent\{closure}() (Line: 593)
    Drupal\Core\Render\Renderer-&gt;executeInRenderContext() (Line: 231)
    Drupal\Core\Render\MainContent\HtmlRenderer-&gt;prepare() (Line: 128)
    Drupal\Core\Render\MainContent\HtmlRenderer-&gt;renderResponse() (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber-&gt;onViewRenderArray() (Line: 246)
    Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}() (Line: 206)
    Symfony\Component\EventDispatcher\EventDispatcher-&gt;callListeners() (Line: 56)
    Symfony\Component\EventDispatcher\EventDispatcher-&gt;dispatch() (Line: 188)
    Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel-&gt;handle() (Line: 37)
    Drupal\Core\Test\StackMiddleware\TestWaitTerminateMiddleware-&gt;handle() (Line: 53)
    Drupal\Core\StackMiddleware\Session-&gt;handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength-&gt;handle() (Line: 116)
    Drupal\page_cache\StackMiddleware\PageCache-&gt;pass() (Line: 90)
    Drupal\page_cache\StackMiddleware\PageCache-&gt;handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState-&gt;handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel-&gt;handle() (Line: 709)
    Drupal\Core\DrupalKernel-&gt;handle() (Line: 19)
    

    At least the tests catch this, but it means that we probably have to fix a bug in Trash before this can be committed.

  • Merge request !517Add test coverage β†’ (Merged) created by phenaproxima
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Turns out that bug is fixed in πŸ› TypeError: strpos(): Argument #1 ($haystack) must be of type string in line 141 of ViewsQueryAlter.php Active , I guess it just needs to be released?

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    No longer blocked; @amateescu rolled a new patch release of Trash which includes the necessary fix.

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts
  • Pipeline finished with Skipped
    15 days ago
    #433536
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Gave this a quick manual test and proved that /admin/content/trash is no longer a 404 in an install of Drupal CMS that has no content types apart from the basic page. So, merged into 1.x and cherry-picked to 1.0.x!

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

Production build 0.71.5 2024