Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292874

block_rehash causes error when running simpletest testcase

$
0
0

I initially wrote this issue in features_extra queue:
https://drupal.org/node/2025817

I need help to understand what is the underlying issue. I am not sure if there is anything needed to code in the fe_block to be able to call this correctly or it is a bug in the block.module.

Problem:
I have created a feature module with a basic content type called "Message board" and a views that displays the content of this message board. the views has a block on top that holds the links to node/add/message that's why I needed the fe_block module.
I then created a TestCase sample.

<?php
class MessageBoardTestCase extends DrupalWebTestCase {
  protected
$privilegedUser;
  protected
$profile = 'minimal';

  public static function
getInfo() {
   
// Note: getInfo() strings are not translated with t().
   
return array(
     
'name'=> 'Message Board',
     
'description'=> '',
     
'group'=> 'Other',
    );
  }

  public function
setUp() {
   
parent::setUp(array('message_board'));

   
// Create and log in our privileged user.
   
$account = $this->drupalCreateUser(array('create message_board content'));
   
$this->drupalLogin($account);
  }

 
/**
    * Tests creation of a Simpletest example node.
    */
 
public function testGlMessageBoardCreate() {
   
// just blank
 
}
}
?>

When running this test, it causes the following error:

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /localhost/batch?id=3&op=do StatusText: Service unavailable (with message) ResponseText: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'bartik-system-main' for key 'tmd': INSERT INTO {block} (module, delta, theme, status, weight, region, pages, cache) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7), (:db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15), (:db_insert_placeholder_16, :db_insert_placeholder_17, :db_insert_placeholder_18, :db_insert_placeholder_19, :db_insert_placeholder_20, :db_insert_placeholder_21, :db_insert_placeholder_22, :db_insert_placeholder_23), (:db_insert_placeholder_24, :db_insert_placeholder_25, :db_insert_placeholder_26, :db_insert_placeholder_27, :db_insert_placeholder_28, :db_insert_placeholder_29, :db_insert_placeholder_30, :db_insert_placeholder_31), (:db_insert_placeholder_32, :db_insert_placeholder_33, :db_insert_placeholder_34, :db_insert_placeholder_35, :db_insert_placeholder_36, :db_insert_placeholder_37, :db_insert_placeholder_38, :db_insert_placeholder_39); Array ( [:db_insert_placeholder_0] => system [:db_insert_placeholder_1] => main [:db_insert_placeholder_2] => bartik [:db_insert_placeholder_3] => 1 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => content [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => -1 [:db_insert_placeholder_8] => user [:db_insert_placeholder_9] => login [:db_insert_placeholder_10] => bartik [:db_insert_placeholder_11] => 1 [:db_insert_placeholder_12] => 0 [:db_insert_placeholder_13] => sidebar_first [:db_insert_placeholder_14] => [:db_insert_placeholder_15] => -1 [:db_insert_placeholder_16] => system [:db_insert_placeholder_17] => navigation [:db_insert_placeholder_18] => bartik [:db_insert_placeholder_19] => 1 [:db_insert_placeholder_20] => 0 [:db_insert_placeholder_21] => sidebar_first [:db_insert_placeholder_22] => [:db_insert_placeholder_23] => -1 [:db_insert_placeholder_24] => system [:db_insert_placeholder_25] => management [:db_insert_placeholder_26] => bartik [:db_insert_placeholder_27] => 1 [:db_insert_placeholder_28] => 1 [:db_insert_placeholder_29] => sidebar_first [:db_insert_placeholder_30] => [:db_insert_placeholder_31] => -1 [:db_insert_placeholder_32] => system [:db_insert_placeholder_33] => help [:db_insert_placeholder_34] => bartik [:db_insert_placeholder_35] => 1 [:db_insert_placeholder_36] => 0 [:db_insert_placeholder_37] => help [:db_insert_placeholder_38] => [:db_insert_placeholder_39] => -1 ) in minimal_install() (line 73 of /www/localhost/profiles/minimal/minimal.install). Fatal error: Class 'Database' not found in /www/localhost/includes/database/database.inc on line 2567

During my investigation, the block_rehash in fe_block.module is causing this error. Without this line, the test runs just fine. Here is the code:

<?php
     
// Rehash if we did not yet.
     
if (empty($themes_rehashed[$theme])) {
       
_block_rehash($theme);  // <---- causing issue
       
$themes_rehashed[$theme] = TRUE;
      }
?>

this line specifically in block.module is the problem Line 459.

<?php
drupal_write_record
('block', $block, $primary_keys);
?>

I tried this in fresh install of dev and it has the same issue.


Viewing all articles
Browse latest Browse all 292874

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>