Uploaded image for project: 'Islandora'
  1. Islandora
  2. ISLANDORA-2378

Solr Search use of Drupal's pager fails on PHP 7.2

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 7.x-1.9, 7.x-1.10, 7.x-1.11, 7.x-1.12
    • Fix Version/s: 7.x-1.13
    • Component/s: Solr Search
    • Labels:
      None

      Description

      Solr Search has this pager theme call https://github.com/Islandora/islandora_solr_search/blob/7.x/includes/results.inc#L73-L79

      // Pager.
          islandora_solr_pager_init($elements['solr_total'], $islandora_solr_query->solrLimit);
          $elements['solr_pager'] = theme('pager', array(
            'tags' => NULL,
            'element' => 0,
            'parameters' => NULL,
            'quantity' => 5,
          ));
      

      Drupal on the other side has this implementation of the https://api.drupal.org/api/drupal/includes%21pager.inc/function/theme_pager_link/7.x

       $text = $variables['text'];
        $page_new = $variables['page_new'];
        $element = $variables['element'];
        $parameters = $variables['parameters'];
        $attributes = $variables['attributes'];
        $page = isset($_GET['page']) ? $_GET['page'] : '';
        if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
          $parameters['page'] = $new_page;
        }
        $query = array();
        if (count($parameters)) {
          $query = drupal_get_query_parameters($parameters, array());
        }
        if ($query_pager = pager_get_query_parameters()) {
          $query = array_merge($query, $query_pager);
        }
      
        // Set each pager link title
        if (!isset($attributes['title'])) {
          static $titles = NULL;
          if (!isset($titles)) {
            $titles = array(
              t('« first') => t('Go to first page'),
              t('‹ previous') => t('Go to previous page'),
              t('next ›') => t('Go to next page'),
              t('last »') => t('Go to last page'),
            );
          }
          if (isset($titles[$text])) {
            $attributes['title'] = $titles[$text];
          }
          elseif (is_numeric($text)) {
            $attributes['title'] = t('Go to page @number', array(
              '@number' => $text,
            ));
          }
        }
      

      Seems like that by passing to the theming function a NULL in the 'parameters' key we are allowing the theme to do a count() on it, which on PHP 7.2 is illegal. This is an integration issue that with a code sniffer/automated test is invisible.

      The actual error (well, warning.. not error) triggers when pressing on any link in the pager during a Solr result.

      Warning: count(): Parameter must be an array or an Object that implements Countable in theme_pager_link()

      Hope i'm understanding the error correctly! I wonder if we are doing similar assumptions with built in Themes when invoking them somewhere else.. Also, should we see this as a Bug?

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            dpinokrayon Diego Pino Navarro
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Zendesk Support