In the implementation of hook_menu, the menu item for the admin/reports/apachesolr looks like this:

$env_id = apachesolr_default_environment();
$items['admin/reports/apachesolr'] = array(
  'title'              => 'Apache Solr search index',
  'description'        => 'Information about the contents of the index the server',
  'page callback'      => 'apachesolr_index_report',
  'page arguments'     => array($env_id),
  'access arguments'   => array('access site reports'),
  'file'               => 'apachesolr.admin.inc',
);

which means that the $env_id is kinda hard-coded to the default solr env at the time menu cache was flushed. If the default env is changed, this page will still display data of the previous default env until the menu cache is flushed again.

And there is no way to display data from the other (non-default) environments.

I think this URL should make use of an argument from the URL. And fall-back to the default env inside the page callback, to make sure that the correct default env is used.

Comments

khaled.zaidan’s picture

Here's quick patch to fix this, there might still be room for improvement, but at least here's something that works:

Index: apachesolr.admin.inc
===================================================================
--- apachesolr.admin.inc
+++ apachesolr.admin.inc
@@ -510,7 +510,11 @@
   return $output;
 }
 
-function apachesolr_index_report($env_id) {
+function apachesolr_index_report($env_id = NULL) {
+  if (!$env_id) {
+    $env_id = apachesolr_default_environment();
+  }
+
   try {
     $solr = apachesolr_get_solr($env_id);
     $solr->clearCache();

Index: apachesolr.module
===================================================================
--- apachesolr.module
+++ apachesolr.module
@@ -152,12 +152,11 @@
     'file'               => 'apachesolr.admin.inc',
     'type'               => MENU_CALLBACK,
   );
-  $env_id = apachesolr_default_environment();
   $items['admin/reports/apachesolr'] = array(
     'title'              => 'Apache Solr search index',
     'description'        => 'Information about the contents of the index the server',
     'page callback'      => 'apachesolr_index_report',
-    'page arguments'     => array($env_id),
+    'page arguments'     => array(3),
     'access arguments'   => array('access site reports'),
     'file'               => 'apachesolr.admin.inc',
   );
khaled.zaidan’s picture

It might be cool also, in the top of the page, to add a link for each of the currently available environments. That way you can easily view the details of each environment without having to type its machine name in the URL.

nick_vh’s picture

This is indeed something we should improve and we did not expect that the different environments would be picked up so quickly
I'll take a look at you patch during the Drupal Dev Days! Feel free to keep improving your patch over the next coming hours/days.

If you go to the environments page, you can already click on index and it will take you to a page with information about that environment. The basic front page is meant to only show the default one. We should do something similar for the reports I think?

nick_vh’s picture

Category: bug » feature

Feature request, let's get to RC1 first

pwolanin’s picture

Right, we should fix the hook menu bug - I don't think the approach here is optimal.

khaled.zaidan’s picture

Category: feature » bug

Hi Nick,

My main concern is the bug in hook_menu. Sure the suggested feature of having a link for each environment is an extra featured, and can definitely wait.

But the main issue itself (having the default environment fused into the menu item definition) is a bug, not a feature request. I think it is important and simple to fix.

(Changing category back to 'bug report')

pwolanin’s picture

Yes, this is a bug as currently coded.

nick_vh’s picture

Status: Active » Needs review
StatusFileSize
new4.07 KB

This should vastly improve the current problem. We might even want to add a stats link in the environment list?

nick_vh’s picture

StatusFileSize
new5.78 KB

Should be better, file paths were broken

nick_vh’s picture

Version: 7.x-1.x-dev » 6.x-3.x-dev
Status: Needs review » Patch (to be ported)

pushed to 7.x-1.x

Thanks for the input!

killua99’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new5.81 KB

Backport for 6.x-3.x

nick_vh’s picture

StatusFileSize
new6.74 KB
nick_vh’s picture

Status: Needs review » Fixed

committed to 6.x-3.x, had to make some small adjustments

killua99’s picture

Oh I see, that changes ... mmm I did not notice that tables ... nice.

nick_vh’s picture

Status: Fixed » Closed (fixed)