Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/modules/dashboard/includes/block.node_types.inc checks twice if $access is TRUE #6689

Open
avpaderno opened this issue Aug 21, 2024 · 0 comments · May be fixed by backdrop/backdrop#4849

Comments

@avpaderno
Copy link
Member

avpaderno commented Aug 21, 2024

The core/modules/dashboard/includes/block.node_types.inc file contains the following code.

    if ($access) {
      foreach ($node_types as $machine => $node_type) {
        // If no types are specified, show all types.
        if (empty($this->settings['types']) || in_array($machine, $this->settings['types'])) {
          $type_url_string = str_replace('_', '-', $node_type->type);
          $links['configure'] = array(
            'title' => t('Configure'),
            'href' => 'admin/structure/types/manage/' . $type_url_string,
            'query' => $options,
          );
          $links['manage'] = array(
            'title' => t('Manage fields'),
            'href' => 'admin/structure/types/manage/' . $type_url_string . '/fields',
            'query' => $options,
          );
          $links['add'] = array(
            'title' => t('Manage display'),
            'href' => 'admin/structure/types/manage/' . $type_url_string . '/display',
            'query' => $options,
          );
          $operations = array(
            '#type' => 'dropbutton',
            '#links' => $links,
          );
          $rows[] = array(
            'data' => array(
              check_plain(t($node_type->name)),
              backdrop_render($operations),
            ),
          );
        }
      }
    }
    else {
      return array();
    }

    $panel = array(
      '#theme' => 'dashboard_panel__node_types',
    );
    $panel['table'] = array(
      '#theme' => 'table',
      '#header' => $header,
      '#rows' => $rows,
      '#empty' => t('There are no content types to display.'),
    );

    if ($access) {
      $panel['link'] = array(
        '#theme' => 'link',
        '#path' => 'admin/structure/types',
        '#text' => t('Manage content types'),
      );
    }

The second time $access is checked, it is surely TRUE, or the previous lines would have returned an empty array. Since $access is not changed after the first time it is checked, there is no need to check it again.

@avpaderno avpaderno changed the title core/modules/dashboard/includes/block.node_types.inc check twice if $access is TRUE core/modules/dashboard/includes/block.node_types.inc checks twice if $access is TRUE Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant