diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/CategoryBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/CategoryBlock.php index 1bd3af8..0ba054c 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/CategoryBlock.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/CategoryBlock.php @@ -27,7 +27,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin public function getDerivativeDefinitions(array $base_plugin_definition) { $result = db_query('SELECT cid, title FROM {aggregator_category} ORDER BY title'); foreach ($result as $category) { - $this->derivatives[$category->cid] = $this->config; + $this->derivatives[$category->cid] = $base_plugin_definition; $this->derivatives[$category->cid]['delta'] = $category->cid; $this->derivatives[$category->cid]['subject'] = t('@title category latest items', array('@title' => $category->title)); } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/FeedBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/FeedBlock.php index 3daf44e..a444be2 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/FeedBlock.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Derivative/FeedBlock.php @@ -27,7 +27,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin public function getDerivativeDefinitions(array $base_plugin_definition) { $result = db_query('SELECT fid, title FROM {aggregator_feed} WHERE block <> 0 ORDER BY fid'); foreach ($result as $feed) { - $this->derivatives[$feed->fid] = $this->config; + $this->derivatives[$feed->fid] = $base_plugin_definition; $this->derivatives[$feed->fid]['delta'] = $feed->fid; $this->derivatives[$feed->fid]['subject'] = t('@title feed latest items', array('@title' => $feed->title)); } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/CategoryBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/CategoryBlock.php index e65ad2a..c7cd27e 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/CategoryBlock.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/CategoryBlock.php @@ -39,7 +39,7 @@ public function configure($form, &$form_state) { $form['block_count'] = array( '#type' => 'select', '#title' => t('Number of news items in block'), - '#default_value' => $this->config['settings']['block_count'], + '#default_value' => $this->configuration['block_count'], '#options' => drupal_map_assoc(range(2, 20)), ); return $form; @@ -49,7 +49,7 @@ public function configure($form, &$form_state) { * Implements BlockInterface::configureSubmit(). */ public function configureSubmit($form, &$form_state) { - $this->config['settings']['block_count'] = $form_state['values']['block_count']; + $this->configuration['block_count'] = $form_state['values']['block_count']; } /** @@ -58,7 +58,7 @@ public function configureSubmit($form, &$form_state) { public function build() { $id = $this->getPluginId(); if ($category = db_query('SELECT cid, title, block FROM {aggregator_category} WHERE cid = :cid', array(':cid' => $id))->fetchObject()) { - $result = db_query_range('SELECT i.* FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON ci.iid = i.iid WHERE ci.cid = :cid ORDER BY i.timestamp DESC, i.iid DESC', 0, $this->config['settings']['block_count'], array(':cid' => $category->cid)); + $result = db_query_range('SELECT i.* FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON ci.iid = i.iid WHERE ci.cid = :cid ORDER BY i.timestamp DESC, i.iid DESC', 0, $this->configuration['block_count'], array(':cid' => $category->cid)); $read_more = theme('more_link', array('url' => 'aggregator/categories/' . $category->cid, 'title' => t("View this category's recent news."))); $items = array(); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/FeedBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/FeedBlock.php index db418ec..a2a0742 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/FeedBlock.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/block/block/FeedBlock.php @@ -39,7 +39,7 @@ public function configure($form, &$form_state) { $form['block_count'] = array( '#type' => 'select', '#title' => t('Number of news items in block'), - '#default_value' => $this->config['block_count'], + '#default_value' => $this->configuration['block_count'], '#options' => drupal_map_assoc(range(2, 20)), ); return $form; @@ -49,23 +49,23 @@ public function configure($form, &$form_state) { * Implements BlockInterface::configureSubmit(). */ public function configureSubmit($form, &$form_state) { - $this->config['block_count'] = $form_state['values']['block_count']; + $this->configuration['block_count'] = $form_state['values']['block_count']; } /** * Implements BlockInterface::build(). */ public function build() { - $id = $this->getPluginId(); + // Plugin ids look something like this: aggregator_feed_block:1. + $id = substr($this->getPluginId(), 22); if ($feed = db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE block <> 0 AND fid = :fid', array(':fid' => $id))->fetchObject()) { - $result = db_query_range("SELECT * FROM {aggregator_item} WHERE fid = :fid ORDER BY timestamp DESC, iid DESC", 0, $this->config['block_count'], array(':fid' => $id)); + $result = db_query_range("SELECT * FROM {aggregator_item} WHERE fid = :fid ORDER BY timestamp DESC, iid DESC", 0, $this->configuration['block_count'], array(':fid' => $id)); $read_more = theme('more_link', array('url' => 'aggregator/sources/' . $feed->fid, 'title' => t("View this feed's recent news."))); $items = array(); foreach ($result as $item) { $items[] = theme('aggregator_block_item', array('item' => $item)); } - // Only display the block if there are items to show. if (count($items) > 0) { return array( diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php index 7f09317..60e999e 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorRenderingTest.php @@ -27,7 +27,6 @@ public function testBlockLinks() { $feed = $this->createFeed(); $this->updateFeedItems($feed, $this->getDefaultFeedItemCount()); - // Place block on page (@see block.test:moveBlockToRegion()) // Need admin user to be able to access block admin. $this->admin_user = $this->drupalCreateUser(array( 'administer blocks', @@ -37,21 +36,17 @@ public function testBlockLinks() { )); $this->drupalLogin($this->admin_user); - // Prepare to use the block admin form. + $current_theme = variable_get('default_theme', 'stark'); + $machine_name = 'test_aggregator_feed_block'; $block = array( - 'module' => 'aggregator', - 'delta' => 'feed-' . $feed->fid, - 'title' => $feed->title, + 'machine_name' => $machine_name, + 'region' => 'footer', + 'title' => 'feed-' . $feed->title, + 'block_count' => 2, ); - $region = 'footer'; - $edit = array(); - $edit['blocks[' . $block['module'] . '_' . $block['delta'] . '][region]'] = $region; - // Check the feed block is available in the block list form. - $this->drupalGet('admin/structure/block'); - $this->assertFieldByName('blocks[' . $block['module'] . '_' . $block['delta'] . '][region]', '', 'Aggregator feed block is available for positioning.'); - // Position it. - $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); - $this->assertText(t('The block settings have been updated.'), format_string('Block successfully moved to %region_name region.', array( '%region_name' => $region))); + $this->drupalPost("admin/structure/block/manage/aggregator_feed_block:{$feed->fid}/$current_theme", $block, t('Save block')); + $this->assertText(t('The block configuration has been saved.'), 'Block was saved.'); + // Confirm that the block is now being displayed on pages. $this->drupalGet('node'); $this->assertText(t($block['title']), 'Feed block is displayed on the page.'); diff --git a/core/modules/block/block.install b/core/modules/block/block.install index da301c1..520689b 100644 --- a/core/modules/block/block.install +++ b/core/modules/block/block.install @@ -75,7 +75,6 @@ function block_schema() { 'pages' => array( 'type' => 'text', 'not null' => TRUE, - 'default' => '', 'description' => 'Contents of the "Pages" block; contains either a list of paths on which to include/exclude the block or PHP code, depending on "visibility" setting.', ), 'title' => array( diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentBlockTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentBlockTest.php index 0ec3af2..b8c07e6 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentBlockTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentBlockTest.php @@ -46,21 +46,16 @@ public static function getInfo() { */ function testRecentCommentBlock() { $this->drupalLogin($this->admin_user); - - // Set the block to a region to confirm block is available. + $current_theme = variable_get('default_theme', 'stark'); + $machine_name = 'test_recent_comments'; $edit = array( - 'blocks[comment_recent][region]' => 'sidebar_first', - ); - $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); - $this->assertText(t('The block settings have been updated.'), 'Block saved to first sidebar region.'); - - // Set block title and variables. - $block = array( + 'machine_name' => $machine_name, + 'region' => 'sidebar_first', 'title' => $this->randomName(), - 'comment_block_count' => 2, + 'block_count' => 2, ); - $this->drupalPost('admin/structure/block/manage/comment/recent/configure', $block, t('Save block')); - $this->assertText(t('The block configuration has been saved.'), 'Block saved.'); + $this->drupalPost('admin/structure/block/manage/recent_comments/' . $current_theme, $edit, t('Save block')); + $this->assertText(t('The block configuration has been saved.'), 'Block was saved.'); // Add some test comments, one without a subject. $comment1 = $this->postComment($this->node, $this->randomName(), $this->randomName()); @@ -75,14 +70,14 @@ function testRecentCommentBlock() { // posting a node from a node form. cache_invalidate(array('content' => TRUE)); $this->drupalGet(''); - $this->assertNoText($block['title'], 'Block was not found.'); + $this->assertNoText($edit['title'], 'Block was not found.'); user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access comments')); // Test that a user with the 'access comments' permission can see the // block. $this->drupalLogin($this->web_user); $this->drupalGet(''); - $this->assertText($block['title'], 'Block was found.'); + $this->assertText($edit['title'], 'Block was found.'); // Test the only the 2 latest comments are shown and in the proper order. $this->assertNoText($comment1->subject, 'Comment not found in block.'); @@ -94,9 +89,10 @@ function testRecentCommentBlock() { $this->drupalLogout(); $this->drupalLogin($this->admin_user); $block = array( - 'comment_block_count' => 10, + 'block_count' => 10, ); - $this->drupalPost('admin/structure/block/manage/comment/recent/configure', $block, t('Save block')); + + $this->drupalPost("admin/structure/block/manage/plugin.core.block.$current_theme.$machine_name/$current_theme/configure", $block, t('Save block')); $this->assertText(t('The block configuration has been saved.'), 'Block saved.'); // Post an additional comment.