Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Received this notice when viewing a page with an apachesole more like this (MLT) block on it:
Notice: Undefined index: page_id in apachesolr_multilingual_apachesolr_query_alter() (line 402 of /var/www/mts/sites/all/modules/contrib/apachesolr_multilingual/apachesolr_multilingual.module).
The line in question is:
$search_page = apachesolr_search_page_load($context['page_id']);
MLT blocks do not have a page_id, they have a block_id, for instance, this is mine:
block_id (String, 7 characters ) mlt-002
Patch attached in the next comment to allow the query alter on pages only (so the query alter will not run on MLT blocks).
Comment | File | Size | Author |
---|---|---|---|
#18 | 2056055_mlt.patch | 939 bytes | mkalkbrenner |
#6 | 2056055-default-value-page-id-5.patch | 770 bytes | yaronmiro |
#1 | 2056055-page_id_missing.patch | 720 bytes | wiifm |
Comments
Comment #1
wiifmPatch attached.
Comment #2
imoreno CreditAttribution: imoreno commentedpatch in #1 Did the job for me.
error message is gone.
BR
Itzhak
Comment #3
mkalkbrennerThe patch turns off the multilingual query altering for MLT blocks in general. That's ok as long as a MLT block is configured to work on non-text fields. But for text fields we probably have to fix and modify the altering.
Comment #4
mkalkbrennerComment #5
yaronmiro CreditAttribution: yaronmiro commentedPatch in #1 won't work if the page belongs to Views as there is no
$context['page_id']
, but other values exist.I suggest adding something like
$context['page_id'] = !empty($context['page_id']) ? $context['page_id'] : 'views';
Patch will follow.
Comment #6
yaronmiro CreditAttribution: yaronmiro commentedComment #7
mkalkbrenner@yaronmiro: The views issue is not related to MLT.
The views issue is a bug in Apache Solr VIews itself that is somewhat outdated. They did not catch up with an API change within the Apache Solr module. I posted a patch there:
#1969268: Broken compatibility with DrupalSolrQueryInterface causes Apache Solr Multilingual to fail (Undefined index: page_id)
Comment #8
yngens2 CreditAttribution: yngens2 commentedThe patch in #1 cause the "More like this block" to start outputting links to the nodes in other languages. The patch in #6 did the job.
Comment #9
danielkutik CreditAttribution: danielkutik commentedSimilar issue:
Comment #11
mkalkbrennerI committed a first patch that avoids these warnings for MLT and Views:
http://drupalcode.org/project/apachesolr_multilingual.git/commit/6591ee0
But as I stated in #3 and as TODO in the comments in the source code, the final solution for this issue looks different.
With the last commit we apply the default multilingual settings to MLT, like yaronmiro did in his patch. But instead applying the defaults we need to add multilingual settings to the MLT block configuration like we do for search pages.
Comment #13
mkalkbrennerI committed a first version of configurable multilingual MLT blocks:
http://drupalcode.org/project/apachesolr_multilingual.git/commit/ace8f99
Anyone who can test this?
BTW the "error" described in #8 is now configurable by "Limit search to current language by default".
Comment #14
mkalkbrennerComment #17
BarisW CreditAttribution: BarisW commentedThe issue in #9 is still valid with the current DEV.
Comment #18
mkalkbrennerI already committed this patch to git. Does it fix #9?
Comment #20
BarisW CreditAttribution: BarisW commentedYes, thanks! A new pull from git fixes the issue :)
Comment #21
mkalkbrennerComment #23
mkalkbrennerComment #24
ricardoj.m.pinto@gmail.com CreditAttribution: ricardoj.m.pinto@gmail.com commentedmkalkbrenner, is this patch available to 7.x-1.0 ? Thanks.
Comment #25
mkalkbrennerSee comments #18 and #19. The patch has been committed to 7.x-1.x-dev already.
Comment #27
partdigital CreditAttribution: partdigital commentedI was able to reproduce this issue when I used the apachesolr panels module. Please see my comments (and patch) here:
https://www.drupal.org/node/2315731#comment-9251217