"Show search box and enabled filters' blocks under the search box" is broken if using Context to control block visiblity

Created on 28 August 2010, about 14 years ago
Updated 7 August 2024, 3 months ago

I am using the Context module to show/hide blocks, rather than having them enabled. I have also created a number of custom CCK facet blocks in my own module that I can use for browsing CCK fields.

When these blocks are disabled in the standard Drupal block admin, but enabled via Context, the blocks are not properly loaded by the Apache Solr module.

The issue occurs on ~ line 270 of the apachesolr_search.module:


        $result = db_query_range(db_rewrite_sql("SELECT DISTINCT b.* FROM {blocks} b
          LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta
          WHERE b.module = '%s' AND b.delta = '%s' AND b.theme = '%s' AND b.status = 1
            AND (r.rid IN (". db_placeholders($rids) .") OR r.rid IS NULL)", 'b', 'bid'), array_merge(array($module, $delta, $theme_key), $rids), 0, 1);
        $block = db_fetch_object($result);        
        $hook_block = (object)module_invoke($module, 'block', 'view', $delta);

The "b.status" condition is causing these blocks not to load properly. The content of the block loads fine, though, but the block ID is not set properly. This causes problems for the "Show more" link in the apachesolr.js file which never gets rendered.

As a workaround you can enable the block, but set the visibility to only show on listed pages and enter a made-up URL, e.g. "foo/bar/baz".

As for a permanent fix, I'm appealing to someone else out there. I tried my hand at a bit of a fix, but it got complicated very quickly. There is a context_block_list() method that is modeled on the block_list() method, as somewhat replicated in the apachesolr_search module, but I'm not sure of the best way to go about fixing this.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024