After a fresh installation of drupal commons 7.x-3.36, I clicked on search button to see the search page. The search page shows the following warning message

Warning: Missing argument 2 for date_facets_get_ranges(), called in profiles/commons/modules/contrib/date_facets/lib/Drupal/Search/Facetapi/QueryType/DateRangeQueryType.php on line 130 and defined in date_facets_get_ranges() (line 84 of /profiles/commons/modules/contrib/date_facets/date_facets.module).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sukh.singh created an issue. See original summary.

sukh.singh’s picture

Status: Active » Needs review
FileSize
777 bytes

I have found that profiles/commons/modules/contrib/date_facets/lib/Drupal/Search/Facetapi/QueryType/DateRangeQueryType.phpon at line number 130, following code has been written

    // Build the markup for the facet's date ranges.
    $build = date_facets_get_ranges($ranges);

However under the file profiles/commons/modules/contrib/date_facets/date_facets.module at line 80, main function date_facets_get_ranges function expects second parameter. Second parameter has been checked at line number 83, however the parament has not been provide default value as NULL or empty.

/**
 * Returns configured ranges or default range if none are configured.
 */
function date_facets_get_ranges($facet_name, $index_id) {
  $ranges = array();
  $searchers = facetapi_get_active_searchers();
  if (!empty($index_id)) {
    foreach ($searchers as $searcher) {
      // Get current searcher.
      if (strpos($searcher, '@' . $index_id) !== FALSE) {
        $adapter = facetapi_adapter_load($searcher);
        $settings = $adapter->getFacetSettings(facetapi_facet_load($facet_name, $searcher), facetapi_realm_load('block'));
        // Get the configured date ranges, or the default ranges if none have been
        // set up already.
        $ranges = (isset($settings->settings['ranges']) ? $settings->settings['ranges'] : date_facets_default_ranges());
        // Sort ranges.
        $ranges = date_facets_get_ranges_render_arrays($ranges);
      }
    }
  }

  return $ranges;
}
WITTEHOND’s picture

The solution in this patch provides a default for $index_id this error not to appear.
Patch is made relative to Drupal root not the actual module it patches.

function date_facets_get_ranges($facet_name, $index_id = '') {