Hello,

panels is making great progress - thanks a lot. Upgrades work fine.

I noticed that on a fresh install, the requirements check does not seem to work.

As far as I can see, there should be "define('PANELS_REQUIRED_CTOOLS_API', '1.0.1');" inserted in panels.install. But somehow panels_requirements do not pass anyway, when installing via an installation profile using the following order 'ctools', 'delegator', 'panels'.

modules used:
panels-DRUPAL-6-3 and ctools-HEAD, both checked out today.

CommentFileSizeAuthor
#16 panels-n460902.patch851 bytesdamienmckenna

Comments

dawehner’s picture

its definied on the top of

panels.module

define('PANELS_REQUIRED_CTOOLS_API', '1.0.1');

merlinofchaos’s picture

I'm surprised that the requirements do not pass, though. I updated the demo site to -dev just a couple of nights ago, both using 1.0.1 and it *does* pass, so I am a little confused.

ano1’s picture

I have experienced the same behavior that drupal24 noted in his post.

merlinofchaos’s picture

Hm. Yes, it would appear that the install process does not load the .module file. That is obnoxious, as I thought it did. Not sure how to fix this offhand. Redefining the constant is a bad one, as then the version # has to be in 2 places and that's got a high chance of breaking.

merlinofchaos’s picture

Status: Active » Fixed

Ok, I believe I have this all fixed in Panels CVS now.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

digi24’s picture

Status: Closed (fixed) » Active

Hmm, I noticed another issue, closely related to the problem mentioned before. Feel free to close it if you consider it unimportant:

When using a custom installation profile, hook_requirements is being called before any databases are created. This implies that drupal_get_path cannot work, and

if (!defined('CTOOLS_API_VERSION')) {
      include_once drupal_get_path('module', 'ctools') . '/ctools.module';
    }

fails. as far as "include_once 'panels.module';" is concerned this is a minor issue, as we do not need the path, but with respect to ctools it cannot be assumed that the module is in the same folder hierarchy.

PS:
A possible solution would be to move the requirements phase from "install" to "runtime". Would this cause serious errors, in case a user with an outdated ctools module installed panels?

Or maybe something like this (untested)

Index: panels.install
===================================================================
--- panels.install      (Revision 435)
+++ panels.install      (Arbeitskopie)
@@ -7,7 +7,7 @@
 function panels_requirements($phase) {
   $requirements = array();
   $t = get_t();
-  if ($phase == 'install') {
+  if (drupal_get_path('module', 'ctools')) {
     // apparently the install process doesn't include .module files,
     // so we need to force the issue in order for our versioning
     // check to work.
@@ -29,6 +29,14 @@
        );
     }
   }
+  else{
+    $requirements['panels_ctools'] = array(
+         'title' => $t('CTools API Version'),
+         'value' => CTOOLS_API_VERSION,
+         'severity' => REQUIREMENT_INFO,
+         'description' => t('The CTools version cannot be determined, please check the status page, after installing the panels module.')
+       );
+  }
   return $requirements;
 }

damienmckenna’s picture

@drupal24: the problem with using it in an installation profile is that the system table does not exist, therefore it cannot find the path to the directory, e.g.:

Warning: Table 'drupal_blah.system' doesn't exist query: SELECT filename FROM system WHERE name = 'panels' AND type = 'module' in /blah/trunk/includes/database.mysql.inc on line 128

What might be worth doing is checking for whether one of the site installation functions, e.g. "install_verify_drupal", exists as that should only ever be available during site installation vs normal module installation. Of course, at that point I'm not sure how it could verify the paths without doing some crazy code?

Damien

damienmckenna’s picture

FYI, what I did to limp through this was to change line 9 in panels.install to the following:

  if ($phase == 'install' && !function_exists('install_verify_drupal')) {

Definitely not a clean fix, but it at least allowed me to add Panels to an installation profile.

digi24’s picture

Thanks a lot Damien!

You actually showed me a flaw in my understanding of Drupal. I always assumed that entries in the system table are only created after the actual install of a module. That is why I thought we would have to get rid of drupal_get_path in the install files.

Thanks a lot for your suggestion this looks a lot easier and is probably a good best practice solution. If I use my install profile, I can assume that the other files match.

damienmckenna’s picture

drupal24: glad to be able to help, though obviously what I provided should be considered a band-aid at best, it really needs a proper fix.

merlinofchaos’s picture

Does something like this fix this? (I don't have a profile handy to test with:)

  if (!db_is_active()) {
    $path = dirname(drupal_get_filename('module', 'panels', NULL));
    require_once './'. $path .'/panels.module';
  }
merlinofchaos’s picture

If possible I'd like to have this fixed for the rc coming up soon. Anyone with an install profile handy to test?

damienmckenna’s picture

merlinofchaos: To verify what was going to be available, I changed the panels_requirement to the following to see what would happen:

function panels_requirements($phase) {
  $requirements = array();
  $t = get_t();
  if ($phase == 'install') {
    print drupal_get_filename('module', 'panels', NULL) . "<br />";
    print drupal_get_path('module', 'panels') . '/panels.module' . "<br />";
    print drupal_get_path('module', 'ctools') . '/ctools.module' . "<br />";
    die('sleep is for the weak');
..

It gave the following error:

( ! ) Warning: Table 'mysite.system' doesn't exist query: SELECT filename FROM system WHERE name = 'panels' AND type = 'module' in mysite/includes/database.mysql.inc on line 128

Next idea? Would it be too crazy to search the entire directory structure to find "ctools.module"?

damienmckenna’s picture

Another test.

I inserted the code provided so it looks like:

function panels_requirements($phase) {
  $requirements = array();
  $t = get_t();
  if ($phase == 'install') {
    if (!db_is_active()) {
      $path = dirname(drupal_get_filename('module', 'panels', NULL));
      require_once './'. $path .'/panels.module';
    }

    // apparently the install process doesn't include .module files,
    // so we need to force the issue in order for our versioning
    // check to work.
    if (!defined('PANELS_REQUIRED_CTOOLS_API')) {
      include_once drupal_get_path('module', 'panels') . '/panels.module';
    }

    // In theory we should check module_exists, but Drupal's gating should
    // actually prevent us from getting here otherwise.
    if (!defined('CTOOLS_API_VERSION')) {
      include_once drupal_get_path('module', 'ctools') . '/ctools.module';
    }
    if (!module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API)) {
       $requirements['panels_ctools'] = array(
         'title' => $t('CTools API Version'),
         'value' => CTOOLS_API_VERSION,
         'severity' => REQUIREMENT_ERROR,
         'description' => t('The CTools API version is too old for Panels. Panels needs at least %version.', array('%version' => PANELS_REQUIRED_CTOOLS_API))
       );
    }
  }
  return $requirements;
}

This results in the following error:

( ! ) Warning: Table 'mysite.system' doesn't exist query: SELECT filename FROM system WHERE name = 'panels' AND type = 'module' in /Users/dmckenna/Sites/mysite/includes/database.mysql.inc on line 128
Call Stack
#	Time	Memory	Function	Location
1	0.0058	386044	{main}( )	../install.php:0
2	0.0086	563132	install_main( )	../install.php:1174
3	0.1729	5777528	install_check_requirements( $profile = 'scubadiving', $verify = TRUE )	../install.php:109
4	0.1729	5779076	drupal_check_profile( $profile = 'scubadiving' )	../install.php:914
5	19.1133	8018192	module_invoke( 'panels', 'requirements', 'install' )	../install.inc:692
6	19.1133	8018816	call_user_func_array ( 'panels_requirements', array (2 => 'install') )	../module.inc:450
7	19.1133	8018880	panels_requirements( $phase = 'install' )	../module.inc:0
8	19.1133	8019876	drupal_get_path( $type = 'module', $name = 'panels' )	../panels.install:20
9	19.1133	8020036	drupal_get_filename( $type = 'module', $name = 'panels', $filename = ??? )	../common.inc:1936
10	19.1134	8021328	db_query( $query = 'SELECT filename FROM {system} WHERE name = \'%s\' AND type = \'%s\'', 'panels', 'module' )	../bootstrap.inc:440
11	19.1135	8023096	_db_query( $query = 'SELECT filename FROM system WHERE name = \'panels\' AND type = \'module\'', $debug = ??? )	../database.mysql-common.inc:42
12	19.1140	8025240	trigger_error ( 'Table &#039;mysite.system&#039; doesn&#039;t exist\nquery: SELECT filename FROM system WHERE name = &#039;panels&#039; AND type = &#039;module&#039;', 512 )	../database.mysql.inc:128

FYI line 20 is:

      include_once drupal_get_path('module', 'panels') . '/panels.module';
damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new851 bytes

Seems there's a cleaner way of identifying whether running an installation profile after all.

James Andres’s picture

DamienMcKenna, panels-n460902.patch works well for me. Thanks.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed! THanks!

dman’s picture

I got the same.
Thanks for the fix.

FTR, I've usually used :

require_once( dirname(__FILE__) . '/required.inc' );

before the days of module_get_include when I needed a nearby file. Saves trusting the absraction layer or requiring a database hit etc etc. Sometimes simple is simpler.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.