Category filters are not working for "Drupal Core" modules

Created on 1 August 2024, 3 months ago

Problem/Motivation

The category filter is not working for the Drupal core modules listing page on project browser in Drupal 11 and PHP 8.3

Attaching video for reference

Steps to reproduce

Platform requirement D11, PHP 8.3, Mysql 8

1. Install & enable project browser on a fresh D11 site.
2. Go to the project browser config page by visiting this path admin/config/development/project_browser & enable Drupal Core.
3. Save the configuration.
4. Go to /admin/modules/browse page.
5. Click on the Drupal Core tab.
6. Try to search by selecting any category from the filter categories.

Proposed resolution

๐Ÿ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia sourav_paul Kolkata

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

Comments & Activities

  • Issue created by @sourav_paul
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia prashant.c Dharamshala

    @Sourav_Paul

    The video is blurry, Could you please reattach it? Are you working on this I can see you have assigned it to yourself ?

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia prashant.c Dharamshala

    The "Filter Categories" UI has been improved and fixed in this https://www.drupal.org/project/project_browser/issues/3318817 ๐Ÿ“Œ Improve the categories filter type in context to the rest of the filter component ui Fixed and it is working properly.

    If you are checking on the cloned version of the module then pull the latest changes. In the released versions also it is working properly for me. Not able to reproduce.

  • Issue was unassigned.
  • Status changed to Closed: works as designed 3 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia prashant.c Dharamshala

    Marking this as closed. Feel free to reopen in case you still facing the issue.

  • Status changed to Active 3 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sourav_paul Kolkata

    @Prashant.c

    I retested it on Drupal 11.0.0-rc1 with Project Browser 2.0.0-alpha2.
    & yes filters are not working for "Drupal core" tab..

    Attaching screen recording link: https://www.awesomescreenshot.com/video/30323049?key=ccd0a70dfcc69d680b5...

    attaching site's composer.json for reference

    {
        "name": "drupal/recommended-project",
        "description": "Project template for Drupal projects with a relocated document root",
        "type": "project",
        "license": "GPL-2.0-or-later",
        "homepage": "https://www.drupal.org/project/drupal",
        "support": {
            "docs": "https://www.drupal.org/docs/user_guide/en/index.html",
            "chat": "https://www.drupal.org/node/314178"
        },
        "repositories": [
            {
                "type": "composer",
                "url": "https://packages.drupal.org/8"
            }
        ],
        "require": {
            "composer/installers": "^2.0",
            "drupal/admin_toolbar": "^3.5",
            "drupal/core-composer-scaffold": "^11",
            "drupal/core-project-message": "^11",
            "drupal/core-recommended": "^11",
            "drupal/project_browser": "^2.0@alpha",
            "drupal/upgrade_status": "^4.3",
            "drush/drush": "^13"
        },
        "conflict": {
            "drupal/drupal": "*"
        },
        "minimum-stability": "dev",
        "prefer-stable": true,
        "config": {
            "allow-plugins": {
                "composer/installers": true,
                "drupal/core-composer-scaffold": true,
                "drupal/core-project-message": true,
                "phpstan/extension-installer": true,
                "dealerdirect/phpcodesniffer-composer-installer": true,
                "php-http/discovery": true
            },
            "sort-packages": true
        },
        "extra": {
            "drupal-scaffold": {
                "locations": {
                    "web-root": "web/"
                }
            },
            "installer-paths": {
                "web/core": [
                    "type:drupal-core"
                ],
                "web/libraries/{$name}": [
                    "type:drupal-library"
                ],
                "web/modules/contrib/{$name}": [
                    "type:drupal-module"
                ],
                "web/profiles/contrib/{$name}": [
                    "type:drupal-profile"
                ],
                "web/themes/contrib/{$name}": [
                    "type:drupal-theme"
                ],
                "drush/Commands/contrib/{$name}": [
                    "type:drupal-drush"
                ],
                "web/modules/custom/{$name}": [
                    "type:drupal-custom-module"
                ],
                "web/profiles/custom/{$name}": [
                    "type:drupal-custom-profile"
                ],
                "web/themes/custom/{$name}": [
                    "type:drupal-custom-theme"
                ]
            },
            "drupal-core-project-message": {
                "include-keys": [
                    "homepage",
                    "support"
                ],
                "post-create-project-cmd-message": [
                    "<bg=blue;fg=white>                                                         </>",
                    "<bg=blue;fg=white>  Congratulations, youโ€™ve installed the Drupal codebase  </>",
                    "<bg=blue;fg=white>  from the drupal/recommended-project template!          </>",
                    "<bg=blue;fg=white>                                                         </>",
                    "",
                    "<bg=yellow;fg=black>Next steps</>:",
                    "  * Install the site: https://www.drupal.org/docs/installing-drupal",
                    "  * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
                    "  * Get support: https://www.drupal.org/support",
                    "  * Get involved with the Drupal community:",
                    "      https://www.drupal.org/getting-involved",
                    "  * Remove the plugin that prints this message:",
                    "      composer remove drupal/core-project-message"
                ]
            }
        },
        "require-dev": {
            "palantirnet/drupal-rector": "^0.20.3"
        }
    }
    

    re-opening this ticket.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Akhil Babu Chengannur

    akhil babu โ†’ made their first commit to this issueโ€™s fork.

  • Hello,
    I've installed the project browser module version 2.0.0-alpha3 in Drupal version 10.3.6 after which I enabled the Drupal Core in the project browser config page (admin/config/development/project_browser). Visted the /admin/modules/browse page after saving the configurations. Tried filtering categories under Drupal core tab however the results obtained are inappropriate as per the filter, also the filter text is not visible after selection. The number in the tab doesn't change after filtering the categories, it shows changed number when different tabs are clicked ( sometimes single tab change works otherwise two tab change works ) but on visiting the Drupal core tab it displays the unchanged number. Attaching ss and video for better understanding.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sourav_paul Kolkata

    The problem is in these methods getProjects() & getProjectData() in DrupalCore.php.

    Its looks like caching issue...

    /**
       * {@inheritdoc}
       */
      public function getProjects(array $query = []): ProjectsResultsPage
      {
        $projects = $this->getProjectData();
    
        // Filter by project machine name.
        if (!empty($query['machine_name'])) {
          $projects = array_filter($projects, fn(Project $project) => $project->machineName === $query['machine_name']);
        }
    
        // Filter by coverage.
        if (!empty($query['security_advisory_coverage']) && $query['security_advisory_coverage'] === SecurityStatus::Covered->value) {
          $projects = array_filter($projects, fn(Project $project) => $project->isCovered);
        }
    
        // Filter by categories.
        if (!empty($query['categories'])) {
          $projects = array_filter($projects, fn(Project $project) => array_intersect(array_column($project->categories, 'id'), explode(',', $query['categories'])));
        }
    
        // Filter by search text.
        if (!empty($query['search'])) {
          $projects = array_filter($projects, fn(Project $project) => stripos($project->title, $query['search']) !== FALSE);
        }
    
        // Filter by sorting criterion.
        if (!empty($query['sort'])) {
          $sort = $query['sort'];
          switch ($sort) {
            case 'a_z':
              usort($projects, fn($x, $y) => $x->title <=> $y->title);
              break;
    
            case 'z_a':
              usort($projects, fn($x, $y) => $y->title <=> $x->title);
              break;
          }
        }
        $project_count = count($projects);
        if (!empty($query['page']) && !empty($query['limit'])) {
          $projects = array_chunk($projects, $query['limit'])[$query['page']] ?? [];
        }
        return $this->createResultsPage($projects, $project_count);
      }
    
      /**
       * Gets the project data from cache if available, or builds it if not.
       *
       * @return \Drupal\project_browser\ProjectBrowser\Project[]
       *   Array of projects.
       */
      protected function getProjectData(): array {
        $stored_projects = $this->cacheBin->get('DrupalCore:projects');
        if ($stored_projects) {
          return $stored_projects->data;
        }
    
        $request = $this->requestStack->getCurrentRequest();
        $returned_list = [];
        foreach ($this->getCoreModules() as $module_name => $module) {
          // Dummy data is used for the fields that are unavailable for core
          // modules.
          $returned_list[] = new Project(
            logo: [
              'file' => [
                'uri' => $request->getSchemeAndHttpHost() . '/core/misc/logo/drupal-logo.svg',
                'resource' => 'image',
              ],
              'alt' => '',
            ],
            // All core projects are considered compatible.
            isCompatible: TRUE,
            isMaintained: TRUE,
            isCovered: $module->info['package'] !== 'Core (Experimental)',
            isActive: TRUE,
            starUserCount: -1,
            projectUsageTotal: -1,
            machineName: $module_name,
            body: [
              'summary' => $module->info['description'],
              'value' => $module->info['description'],
            ],
            title: $module->info['name'],
            changed: 280299600,
            created: 280299600,
            author: [
              'name' => 'Drupal Core',
            ],
            packageName: 'drupal/core',
            categories: [
              [
                'id' => $module->info['package'],
                'name' => $module->info['package'],
              ],
            ],
            id: $module_name,
          );
        }
    
        // $this->cacheBin->set('DrupalCore:projects', $returned_list);
        return $returned_list;
      }
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sourav_paul Kolkata
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sourav_paul Kolkata

    @chrisfromredfin Could you please check this one?

Production build 0.71.5 2024