示例#1
0
 /**
  * Implements CoreInterface::clearCache().
  */
 public function clearCache()
 {
     // Need to change into the Drupal root directory or the registry explodes.
     $current_path = getcwd();
     chdir(DRUPAL_ROOT);
     drupal_flush_all_caches();
 }
示例#2
0
/**
 * Remove update overrides and flush all caches.
 *
 * This will need to be run once all (if any) updates are run. Do not call this
 * while updates are running.
 */
function update_flush_all_caches()
{
    $GLOBALS['conf']['update_service_provider_overrides'] = FALSE;
    \Drupal::service('kernel')->updateModules(\Drupal::moduleHandler()->getModuleList());
    // No updates to run, so caches won't get flushed later.  Clear them now.
    drupal_flush_all_caches();
}
 /**
  * Deletes config.
  *
  */
 protected function removeFilterConfig()
 {
     $mailchimp_campaign_filter = \Drupal::configFactory()->getEditable('filter.format.mailchimp_campaign');
     $mailchimp_campaign_filter->delete();
     // Clear cache.
     drupal_flush_all_caches();
 }
示例#4
0
 public function testInactiveDomain()
 {
     // Create three new domains programmatically.
     $this->domainCreateTestDomains(3);
     $domains = \Drupal::service('domain.loader')->loadMultiple();
     // Grab the last domain for testing.
     $domain = end($domains);
     $this->drupalGet($domain->getPath());
     $this->assertTrue($domain->status(), 'Tested domain is set to active.');
     $this->assertTrue($domain->getPath() == $this->getUrl(), 'Loaded the active domain.');
     // Disable the domain and test for redirect.
     $domain->disable();
     $default = \Drupal::service('domain.loader')->loadDefaultDomain();
     // Must flush cache.
     drupal_flush_all_caches();
     $this->drupalGet($domain->getPath());
     $this->assertFalse($domain->status(), 'Tested domain is set to inactive.');
     $this->assertTrue($default->getPath() == $this->getUrl(), 'Redirected an inactive domain to the default domain.');
     // Try to access with the proper permission.
     user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access inactive domains'));
     $this->assertFalse($domain->status(), 'Tested domain is set to inactive.');
     // Must flush cache.
     drupal_flush_all_caches();
     $this->drupalGet($domain->getPath());
     $this->assertTrue($domain->getPath() == $this->getUrl(), 'Loaded the inactive domain with permission.');
 }
示例#5
0
/**
 * Form submit handler for the theme settings form.
 */
function at_core_submit_layouts(&$form, &$form_state) {
  $build_info = $form_state->getBuildInfo();
  $values = $form_state->getValues();
  $theme = $build_info['args'][0];

  // Generate and save a new layout.
  if (isset($values['settings_layouts_enable']) && $values['settings_layouts_enable'] == 1) {

    $generateLayout = new LayoutSubmit($theme, $values);

    // Update the themes info file with new regions.
    $generateLayout->saveLayoutRegions();

    // Build and save the suggestions layout css files.
    $generateLayout->saveLayoutSuggestionsCSS();

    // Build and save the suggestions twig templates.
    $generateLayout->saveLayoutSuggestionsMarkup();

    // Add a new suggestion to the page suggestions array in config.
    if (!empty($values['ts_name'])) {
      $suggestion = trim($values['ts_name']);
      $clean_suggestion = str_replace('-', '_', $suggestion);
      $values["settings_suggestion_page__$clean_suggestion"] = $clean_suggestion;
    }

    // Delete suggestion files
    $templates_directory = drupal_get_path('theme', $theme) . '/templates/page';
    $css_directory = $values['settings_generated_files_path'];

    foreach ($values as $values_key => $values_value) {
      if (substr($values_key, 0, 18) === 'delete_suggestion_') {
        if ($values_value === 1) {
          $delete_suggestion_keys[] = Unicode::substr($values_key, 18);
        }
      }
    }

    if (isset($delete_suggestion_keys)) {
      foreach ($delete_suggestion_keys as $suggestion_to_remove) {
        $formatted_suggestion = str_replace('_', '-', $suggestion_to_remove);
        $template_file_path = $templates_directory . '/' . $formatted_suggestion . '.html.twig';
        $css_file_path = $css_directory . '/' . $theme . '--layout__' . $formatted_suggestion . '.css';
        if (file_exists($template_file_path)) {unlink($template_file_path);}
        if (file_exists($css_file_path)) {unlink($css_file_path);}
      }
    }
  }

  // Flush all caches. This is the only realy reliable way I have found to ensure
  // new templates and layouts work correctly.
  drupal_flush_all_caches();

  // Manage settings and configuration.
  // Must get mutable config otherwise bad things happen.
  $config = \Drupal::configFactory()->getEditable($theme . '.settings');
  $convertToConfig = new ThemeSettingsConfig();
  $convertToConfig->settingsConvertToConfig($values, $config);
}
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $config = $this->configFactory->getEditable('autofloat.settings');
     $config->set('start', $form_state->getValue('autofloat_start'))->set('css', $form_state->getValue('autofloat_css'))->set('span', $form_state->getValue('autofloat_span'))->set('div', $form_state->getValue('autofloat_div'));
     $config->save();
     drupal_flush_all_caches();
     parent::submitForm($form, $form_state);
 }
示例#7
0
function _rename_field($old_name, $new_name)
{
    $args = array(':old_name' => $old_name, ':new_name' => $new_name);
    db_query("UPDATE {field_config} SET field_name = :new_name WHERE field_name = :old_name", $args);
    db_query("UPDATE {field_config_instance} SET field_name = :new_name WHERE field_name = :old_name", $args);
    db_query("RENAME TABLE `field_data_{$old_name}` TO `field_data_{$new_name}`");
    db_query("RENAME TABLE `field_revision_{$old_name}` TO `field_revision_{$new_name}`");
    drupal_flush_all_caches();
}
示例#8
0
 /**
  * @AfterFeature @enableDKAN_Workflow
  */
 public static function disableDKAN_Workflow(AfterFeatureScope $event)
 {
     if (!parent::shouldEnableModule("dkan_workflow")) {
         return;
     }
     // Enable 'open_data_federal_extras' module.
     module_disable(array('dkan_workflow', 'dkan_workflow_permissions', 'views_dkan_workflow_tree', 'workbench', 'workbench_email', 'workbench_moderation'));
     drupal_flush_all_caches();
 }
/**
 * Form submit handler for the Extension settings.
 * @param $form
 * @param $form_state
 */
function at_core_submit_extension_settings(&$form, &$form_state)
{
    $build_info = $form_state->getBuildInfo();
    $values = $form_state->getValues();
    $theme = $build_info['args'][0];
    $at_core_path = drupal_get_path('theme', 'at_core');
    // Don't let this timeout easily.
    set_time_limit(60);
    // Path to save generated CSS files.
    $generated_files_path = $values['settings_generated_files_path'];
    if ($values['settings_enable_extensions'] === 1) {
        // Require submit handlers and helper functions for extensions.
        if (isset($values['settings_enable_fonts']) && $values['settings_enable_fonts'] === 1 || isset($values['settings_enable_titles']) && $values['settings_enable_titles'] === 1) {
            require_once $at_core_path . '/forms/ext/fonts.inc';
            require_once $at_core_path . '/forms/ext/fonts_submit.php';
            require_once $at_core_path . '/forms/ext/titles_submit.php';
        }
        // Submit handler for Fonts.
        if (isset($values['settings_enable_fonts']) && $values['settings_enable_fonts'] === 1) {
            // Returns modified values to pass in new settings for typekit and google fonts.
            $values = at_core_submit_fonts($values, $generated_files_path);
        }
        // Submit handler for Titles.
        if (isset($values['settings_enable_titles']) && $values['settings_enable_titles'] === 1) {
            at_core_submit_titles($values, $generated_files_path);
        }
        // Submit handler for Markup Overrides.
        if (isset($values['settings_enable_markup_overrides']) && $values['settings_enable_markup_overrides'] === 1) {
            // Breadcrumbs
            if (!empty($values['settings_breadcrumb_separator'])) {
                require_once $at_core_path . '/forms/ext/breadcrumb_submit.php';
                at_core_submit_breadcrumb($values, $generated_files_path);
            }
        }
        // Submit handler for Mobile blocks.
        if (isset($values['settings_enable_mobile_blocks']) && $values['settings_enable_mobile_blocks'] === 1) {
            require_once $at_core_path . '/forms/ext/mobile_blocks_submit.php';
            at_core_submit_mobile_blocks($values, $theme, $generated_files_path);
        }
        // Submit handler for Custom CSS.
        if (isset($values['settings_enable_custom_css']) && $values['settings_enable_custom_css'] === 1) {
            require_once $at_core_path . '/forms/ext/custom_css_submit.php';
            at_core_submit_custom_css($values, $generated_files_path);
        }
    }
    // Flush caches. I really, really tried to avoid this, but if you know a better
    // way of always clearing twig, CSS and the registry?
    drupal_flush_all_caches();
    // Manage settings and configuration.
    // Must get mutable config otherwise bad things happen.
    $config = \Drupal::configFactory()->getEditable($theme . '.settings');
    $convertToConfig = new ThemeSettingsConfig();
    $convertToConfig->settingsExtensionsConvertToConfig($values, $config);
    drupal_set_message(t('Extensions configuration saved.'), 'status');
    //$performance_url = Url::fromRoute('system.performance_settings')->setOptions(array('attributes' => array('target' => '_blank')));
    //drupal_set_message(t('Extensions configuration saved. If settings have not taken effect, please <b>@perm</b>.', array('@perm' => \Drupal::l(t('clear the cache'), $performance_url))), 'status');
}
示例#10
0
 /**
  * Tests the interface to manage metatag defaults.
  */
 function testDefaults()
 {
     // Save the default title to test the Revert operation at the end.
     $metatag_defaults = \Drupal::config('metatag.metatag_defaults.global');
     $default_title = $metatag_defaults->get('tags')['title'];
     // Initiate session with a user who can manage metatags.
     $permissions = array('administer site configuration', 'administer meta tags');
     $account = $this->drupalCreateUser($permissions);
     $this->drupalLogin($account);
     // Check that the user can see the list of metatag defaults.
     $this->drupalGet('admin/structure/metatag_defaults');
     $this->assertResponse(200);
     // Check that the Global defaults were created.
     $this->assertLinkByHref('/admin/structure/metatag_defaults/global', 0, t('Global defaults were created on installation.'));
     // Check that Global and entity defaults can't be deleted.
     $this->assertNoLinkByHref('/admin/structure/metatag_defaults/global/delete', 0, t('Global defaults can\'t be deleted'));
     $this->assertNoLinkByHref('/admin/structure/metatag_defaults/node/delete', 0, t('Entity defaults can\'t be deleted'));
     // Check that the module defaults were injected into the Global config entity.
     $this->drupalGet('admin/structure/metatag_defaults/global');
     $this->assertFieldById('edit-title', $metatag_defaults->get('title'), t('Metatag defaults were injected into the Global configuration entity.'));
     // Update the Global defaults and test them.
     $values = array('title' => 'Test title', 'description' => 'Test description');
     $this->drupalPostForm('admin/structure/metatag_defaults/global', $values, 'Save');
     $this->assertText('Saved the Global Metatag defaults.');
     $this->drupalGet('hit-a-404');
     foreach ($values as $metatag => $value) {
         $this->assertRaw($value, t('Updated metatag @tag was found in the HEAD section of the page.', array('@tag' => $metatag)));
     }
     // Check that tokens are processed.
     $values = array('title' => '[site:name] | Test title', 'description' => '[site:name] | Test description');
     $this->drupalPostForm('admin/structure/metatag_defaults/global', $values, 'Save');
     $this->assertText('Saved the Global Metatag defaults.');
     drupal_flush_all_caches();
     $this->drupalGet('hit-a-404');
     foreach ($values as $metatag => $value) {
         $processed_value = \Drupal::token()->replace($value);
         $this->assertRaw($processed_value, t('Processed token for metatag @tag was found in the HEAD section of the page.', array('@tag' => $metatag)));
     }
     // Test the Robots plugin.
     $robots_values = array('index', 'follow', 'noydir');
     $form_values = array();
     foreach ($robots_values as $value) {
         $values['robots[' . $value . ']'] = TRUE;
     }
     $this->drupalPostForm('admin/structure/metatag_defaults/global', $values, 'Save');
     $this->assertText('Saved the Global Metatag defaults.');
     drupal_flush_all_caches();
     $this->drupalGet('hit-a-404');
     $robots_value = implode(', ', $robots_values);
     $this->assertRaw($robots_value, t('Robots metatag has the expected values.'));
     // Test reverting global configuration to its defaults.
     $this->drupalPostForm('admin/structure/metatag_defaults/global/revert', array(), 'Revert');
     $this->assertText('Reverted Global defaults.');
     $this->assertText($default_title, 'Global title was reverted to its default value.');
     $this->drupalLogout();
 }
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     ConfigurableLanguage::createFromLangcode('fr')->save();
     $this->config('system.site')->set('langcode', 'fr')->save();
     // Make sure new entity type definitions are processed.
     \Drupal::service('entity.definition_update_manager')->applyUpdates();
     // Clear all caches so that the base field definition, its cache in the
     // entity manager, the t() cache, etc. are all cleared.
     drupal_flush_all_caches();
 }
 /**
  * Connect.
  */
 public function connect()
 {
     \Drupal::configFactory()->getEditable('acquia_connector.settings')->set('spi.ssl_verify', FALSE)->save();
     \Drupal::configFactory()->getEditable('acquia_connector.settings')->set('spi.ssl_override', TRUE)->save();
     $admin_user = $this->createAdminUser();
     $this->drupalLogin($admin_user);
     $edit_fields = array('acquia_identifier' => $this->randomString(8), 'acquia_key' => $this->randomString(8));
     $submit_button = 'Connect';
     $this->drupalPostForm('admin/config/system/acquia-connector/credentials', $edit_fields, $submit_button);
     \Drupal::service('module_installer')->install(array('acquia_search'));
     drupal_flush_all_caches();
 }
 /**
  * Test the field configuration form.
  */
 public function testFieldConfiguration()
 {
     $this->drupalLogin($this->createAdminUser());
     $this->createContentType(['type' => 'page', 'name' => 'Page']);
     drupal_flush_all_caches();
     $this->drupalGet('admin/structure/types/manage/page/fields/add-field');
     $this->submitForm(['new_storage_type' => 'video_embed_field', 'label' => 'Video Embed', 'field_name' => 'video_embed'], t('Save and continue'));
     $this->submitForm([], t('Save field settings'));
     $this->submitForm(['label' => 'Video Embed', 'description' => 'Some help.', 'required' => '1', 'default_value_input[field_video_embed][0][value]' => 'http://example.com', 'settings[allowed_providers][vimeo]' => 'vimeo', 'settings[allowed_providers][youtube]' => 'youtube', 'settings[allowed_providers][youtube_playlist]' => 'youtube_playlist'], t('Save settings'));
     $this->assertSession()->pageTextContains('Could not find a video provider to handle the given URL.');
     $this->submitForm(['default_value_input[field_video_embed][0][value]' => 'https://www.youtube.com/watch?v=XgYu7-DQjDQ'], t('Save settings'));
     $this->assertSession()->pageTextContains('Saved Video Embed configuration.');
 }
 /**
  * Tests that changes to the info file are picked up.
  */
 public function testChanges()
 {
     $this->themeHandler->install(array('test_theme'));
     $this->themeHandler->setDefault('test_theme');
     $this->themeManager->resetActiveTheme();
     $active_theme = $this->themeManager->getActiveTheme();
     // Make sure we are not testing the wrong theme.
     $this->assertEqual('test_theme', $active_theme->getName());
     $this->assertEqual(['classy/base', 'core/normalize', 'test_theme/global-styling'], $active_theme->getLibraries());
     // @see theme_test_system_info_alter()
     $this->state->set('theme_test.modify_info_files', TRUE);
     drupal_flush_all_caches();
     $active_theme = $this->themeManager->getActiveTheme();
     $this->assertEqual(['classy/base', 'core/normalize', 'test_theme/global-styling', 'core/backbone'], $active_theme->getLibraries());
 }
 public static function run()
 {
     ini_set('max_execution_time', 60 * 60);
     ini_set('memory_limit', '2G');
     self::migrateTaxonomy();
     self::migrateNode();
     self::migrateBlockContent();
     self::migrateUsers();
     self::migrateComments();
     self::migrateFields();
     self::migrateFiles();
     self::migratePathAliases();
     self::migrateLocaleStrings();
     drupal_flush_all_caches();
 }
示例#16
0
 /**
  * Tests drupal_flush_all_caches().
  */
 function testFlushAllCaches()
 {
     // Create cache entries for each flushed cache bin.
     $bins = Cache::getBins();
     $this->assertTrue($bins, 'Cache::getBins() returned bins to flush.');
     foreach ($bins as $bin => $cache_backend) {
         $cid = 'test_cid_clear' . $bin;
         $cache_backend->set($cid, $this->defaultValue);
     }
     // Remove all caches then make sure that they are cleared.
     drupal_flush_all_caches();
     foreach ($bins as $bin => $cache_backend) {
         $cid = 'test_cid_clear' . $bin;
         $this->assertFalse($this->checkCacheExists($cid, $this->defaultValue, $bin), format_string('All cache entries removed from @bin.', array('@bin' => $bin)));
     }
 }
示例#17
0
 /**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     $js_injector = $this->entity;
     $status = $js_injector->save();
     switch ($status) {
         case SAVED_NEW:
             drupal_set_message($this->t('Created the %label Js Injector.', ['%label' => $js_injector->label()]));
             break;
         default:
             drupal_set_message($this->t('Saved the %label Js Injector.', ['%label' => $js_injector->label()]));
             $file_name = file_default_scheme() . '://js_injector/' . $js_injector->id . '.js';
             file_unmanaged_delete_recursive($file_name);
     }
     drupal_flush_all_caches();
     $form_state->setRedirectUrl($js_injector->urlInfo('collection'));
 }
示例#18
0
/**
 * @file
 * Saves a parse-able inc file with the full color info array for the active theme.
 *
 * If a custom color scheme has been created in the UI it is injected into the
 * schemes array and saved. You must rename the Custom scheme and give it a
 * unique array key before using the generated file in your theme.
 *
 * Note that color module validates the input of the color form and this is not
 * run if there is a problem, e.g. the user inputting non hexadecimal CSS color
 * strings, which color module validates to avoid XSS.
 */
function at_core_log_color_scheme(&$form, &$form_state)
{
    $build_info = $form_state->getBuildInfo();
    $values = $form_state->getValues();
    $theme = $build_info['args'][0];
    $palette = $values['palette'];
    $indent = str_pad(' ', 6);
    $lines = explode("\n", var_export($palette, TRUE));
    $message = "    'PaletteName' => array(\n";
    $message .= $indent . "'title' => t('PaletteName'),\n";
    $message .= $indent . "'colors' => array(\n";
    $last_line = $indent . array_pop($lines) . ',';
    $message_scss = '';
    array_shift($lines);
    foreach ($lines as $line) {
        if (strpos($line, ' => ') !== FALSE) {
            $parts = explode(' => ', $line);
            $message .= $indent . $parts[0] . str_pad(' ', 52 - strlen($line)) . '=> ' . $parts[1];
        } else {
            $message .= "{$indent}  {$line}";
        }
        $message .= "\n";
    }
    foreach ($lines as $line) {
        if (strpos($line, ' => ') !== FALSE) {
            $parts = explode(' => ', $line);
            $part_0 = trim(str_replace("'", "", $parts[0]));
            $part_1 = trim(str_replace(",", ";", $parts[1]));
            $message_scss .= "\$" . $part_0 . str_pad(' ', 52 - strlen($line)) . " : " . str_replace("'", "", $part_1) . "\n";
        }
    }
    $message .= "{$last_line}\n";
    $message .= "    ),\n";
    $message = '<pre>' . $message . "\n\n" . $message_scss . '</pre>';
    \Drupal::logger($theme)->notice($message);
    // Hopefully this goes away if this ever lands, https://www.drupal.org/node/2415663
    // I'm not holding my breath.
    drupal_flush_all_caches();
    $obi_wan_quotes = array("You'll find that many of the truths we cling to depend greatly on our own point of view.", "Only imperial storm troopers are so precise.", "You will never find a more wretched hive of scum and villainy.", "These aren't the droids you're looking for.", "I felt a great disturbance in the Force.", "Only a Sith Lord deals in absolutes.", "It's over, Anakin. I have the high ground.", "He will learn patience.", "Aren't you a little short for a Storm Trooper?", "You can't win, Darth.", "Use the Force, Luke.", "May the force be with you.");
    $obi_k = array_rand($obi_wan_quotes);
    $obi_wan = $obi_wan_quotes[$obi_k];
    drupal_set_message(t('Color scheme logged. Cache cleared. <p>Obi Wan says... <em>"@obiwan"</em></p>', array('@obiwan' => $obi_wan)), 'status');
}
示例#19
0
 public function testBlock()
 {
     $this->drupalPlaceBlock('multiversion_workspace_block', ['region' => 'sidebar_first', 'label' => 'Workspace switcher']);
     $this->drupalGet('');
     // Confirm that the block is being displayed.
     $this->assertText('Workspace switcher', t('Block successfully being displayed on the page.'));
     $front = Url::fromRoute('<front>')->toString(TRUE)->getGeneratedUrl();
     $this->assertRaw('href="' . $front . '"', 'The id of the default workspace was displayed in the Workspace switcher block as a link.');
     $machine_name = $this->randomMachineName();
     $entity = Workspace::create(['machine_name' => $machine_name, 'label' => $machine_name]);
     $entity->save();
     $id = $entity->id();
     $node = Node::create(['type' => 'article', 'title' => 'Test article']);
     $node->save();
     $nid = $node->id();
     drupal_flush_all_caches();
     $this->drupalGet('');
     $this->assertText('Test article', 'The title of the test article was displayed on the front page.');
     $this->drupalGet("node/{$nid}");
     $this->assertText('Test article');
     $this->drupalGet('<front>');
     $url = $front . "?workspace={$id}";
     $this->assertRaw('href="' . $url . '"', 'The id of the new workspace was displayed in the Workspace switcher block as a link.');
     $this->drupalGet("/node/{$nid}", ['query' => ['workspace' => $id]]);
     $this->assertText('Page not found');
     $this->drupalGet('<front>', ['query' => ['workspace' => 'default']]);
     $this->assertText('Test article', 'The title of the test article was displayed on the front page.');
     $this->drupalGet('<front>', ['query' => ['workspace' => $id]]);
     $this->drupalGet('/node/add/article');
     $this->assertText('Create Article');
     $this->drupalGet('<front>', ['query' => ['workspace' => $id]]);
     $this->assertNoText('Test article', 'The title of the test article was not displayed on the front page after switching the workspace.');
     $entity->delete();
     drupal_flush_all_caches();
     $this->drupalGet('');
     $this->assertNoText($machine_name, 'The name of the deleted workspace was not displayed in the Workspace switcher block.');
 }
示例#20
0
/**
 * Registry Rebuild needs to aggressively clear all caches,
 * not just some bins (at least to attempt it) also *before*
 * attempting to rebuild registry, or it may not be able
 * to fix the problem at all, if it relies on some cached
 * and no longer valid data/paths etc. This problem has been
 * confirmed and reproduced many times with option --fire-bazooka
 * which is available only in the Drush variant, but it confirms
 * the importance of starting with real, raw and not cached
 * in any way site state. While the --no-cache-clear option
 * still disables this procedure, --fire-bazooka takes precedence
 * and forces all caches clear action. All caches are cleared
 * by default in the PHP script variant.
 */
function registry_rebuild_cc_all()
{
    if (function_exists('cache_clear_all')) {
        cache_clear_all('*', 'cache', TRUE);
        cache_clear_all('*', 'cache_form', TRUE);
    } else {
        cache('cache')->deleteAll();
        cache('cache_form')->deleteAll();
    }
    if (function_exists('module_rebuild_cache')) {
        // D5-D6
        module_list(TRUE, FALSE);
        module_rebuild_cache();
    }
    if (function_exists('drupal_flush_all_caches')) {
        // D6+
        drupal_flush_all_caches();
    } else {
        // D5
        cache_clear_all();
        system_theme_data();
        node_types_rebuild();
        menu_rebuild();
    }
    print "All caches have been cleared with registry_rebuild_cc_all.<br/>\n";
}
示例#21
0
 /**
  * {@inheritdoc}
  */
 public function clearCache()
 {
     // Need to change into the Drupal root directory or the registry explodes.
     drupal_flush_all_caches();
 }
示例#22
0
文件: WebTestBase.php 项目: Wylbur/gj
 /**
  * Resets all data structures after having enabled new modules.
  *
  * This method is called by \Drupal\simpletest\WebTestBase::setUp() after
  * enabling the requested modules. It must be called again when additional
  * modules are enabled later.
  */
 protected function resetAll()
 {
     // Clear all database and static caches and rebuild data structures.
     drupal_flush_all_caches();
     $this->container = \Drupal::getContainer();
     // Reset static variables and reload permissions.
     $this->refreshVariables();
 }
示例#23
0
 /**
  * Reset any system caches that may be required for proper CiviCRM
  * integration.
  */
 function flush()
 {
     drupal_flush_all_caches();
 }
 /**
  * @param $config
  *
  * @return mixed
  */
 public function install($config)
 {
     global $installDirPath;
     // create database if does not exists
     $this->createDatabaseIfNotExists($config['mysql']['server'], $config['mysql']['username'], $config['mysql']['password'], $config['mysql']['database']);
     global $installDirPath;
     // Build database
     require_once $installDirPath . 'civicrm.php';
     civicrm_main($config);
     if (!$this->errors) {
         global $installType, $installURLPath;
         $registerSiteURL = "https://civicrm.org/register-site";
         $commonOutputMessage = "<li>" . ts("Have you registered this site at CiviCRM.org? If not, please help strengthen the CiviCRM ecosystem by taking a few minutes to <a %1>fill out the site registration form</a>. The information collected will help us prioritize improvements, target our communications and build the community. If you have a technical role for this site, be sure to check Keep in Touch to receive technical updates (a low volume mailing list).", array(1 => "href='{$registerSiteURL}' target='_blank'")) . "</li>" . "<li>" . ts("We have integrated KCFinder with CKEditor and TinyMCE. This allows a user to upload images. All uploaded images are public.") . "</li>";
         $output = NULL;
         if ($installType == 'drupal' && version_compare(VERSION, '7.0-rc1') >= 0) {
             // clean output
             @ob_clean();
             $output .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
             $output .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
             $output .= '<head>';
             $output .= '<title>' . ts('CiviCRM Installed') . '</title>';
             $output .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
             $output .= '<link rel="stylesheet" type="text/css" href="template.css" />';
             $output .= '</head>';
             $output .= '<body>';
             $output .= '<div style="padding: 1em;"><p class="good">' . ts('CiviCRM has been successfully installed') . '</p>';
             $output .= '<ul>';
             $drupalURL = civicrm_cms_base();
             $drupalPermissionsURL = "{$drupalURL}index.php?q=admin/people/permissions";
             $drupalURL .= "index.php?q=civicrm/admin/configtask&reset=1";
             $output .= "<li>" . ts("Drupal user permissions have been automatically set - giving anonymous and authenticated users access to public CiviCRM forms and features. We recommend that you <a %1>review these permissions</a> to ensure that they are appropriate for your requirements (<a %2>learn more...</a>)", array(1 => "target='_blank' href='{$drupalPermissionsURL}'", 2 => "target='_blank' href='http://wiki.civicrm.org/confluence/display/CRMDOC/Default+Permissions+and+Roles'")) . "</li>";
             $output .= "<li>" . ts("Use the <a %1>Configuration Checklist</a> to review and configure settings for your new site", array(1 => "target='_blank' href='{$drupalURL}'")) . "</li>";
             $output .= $commonOutputMessage;
             // automatically enable CiviCRM module once it is installed successfully.
             // so we need to Bootstrap Drupal, so that we can call drupal hooks.
             global $cmsPath, $crmPath;
             // relative / abosolute paths are not working for drupal, hence using chdir()
             chdir($cmsPath);
             // Force the re-initialisation of the config singleton on the next call
             // since so far, we had used the Config object without loading the DB.
             $c = CRM_Core_Config::singleton(FALSE);
             $c->free();
             include_once "./includes/bootstrap.inc";
             include_once "./includes/unicode.inc";
             drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
             // prevent session information from being saved.
             drupal_save_session(FALSE);
             // Force the current user to anonymous.
             $original_user = $GLOBALS['user'];
             $GLOBALS['user'] = drupal_anonymous_user();
             // explicitly setting error reporting, since we cannot handle drupal related notices
             error_reporting(1);
             // rebuild modules, so that civicrm is added
             system_rebuild_module_data();
             // now enable civicrm module.
             module_enable(array('civicrm', 'civicrmtheme'));
             // clear block, page, theme, and hook caches
             drupal_flush_all_caches();
             //add basic drupal permissions
             civicrm_install_set_drupal_perms();
             // restore the user.
             $GLOBALS['user'] = $original_user;
             drupal_save_session(TRUE);
             //change the default language to one chosen
             if (isset($config['seedLanguage']) && $config['seedLanguage'] != 'en_US') {
                 civicrm_api3('Setting', 'create', array('domain_id' => 'current_domain', 'lcMessages' => $config['seedLanguage']));
             }
             $output .= '</ul>';
             $output .= '</div>';
             $output .= '</body>';
             $output .= '</html>';
             echo $output;
         } elseif ($installType == 'drupal' && version_compare(VERSION, '6.0') >= 0) {
             // clean output
             @ob_clean();
             $output .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
             $output .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
             $output .= '<head>';
             $output .= '<title>' . ts('CiviCRM Installed') . '</title>';
             $output .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
             $output .= '<link rel="stylesheet" type="text/css" href="template.css" />';
             $output .= '</head>';
             $output .= '<body>';
             $output .= '<div style="padding: 1em;"><p class="good">' . ts("CiviCRM has been successfully installed") . '</p>';
             $output .= '<ul>';
             $drupalURL = civicrm_cms_base();
             $drupalPermissionsURL = "{$drupalURL}index.php?q=admin/user/permissions";
             $drupalURL .= "index.php?q=civicrm/admin/configtask&reset=1";
             $output .= "<li>" . ts("Drupal user permissions have been automatically set - giving anonymous and authenticated users access to public CiviCRM forms and features. We recommend that you <a %1>review these permissions</a> to ensure that they are appropriate for your requirements (<a %2>learn more...</a>)", array(1 => "target='_blank' href='{$drupalPermissionsURL}'", 2 => "target='_blank' href='http://wiki.civicrm.org/confluence/display/CRMDOC/Default+Permissions+and+Roles'")) . "</li>";
             $output .= "<li>" . ts("Use the <a %1>Configuration Checklist</a> to review and configure settings for your new site", array(1 => "target='_blank' href='{$drupalURL}'")) . "</li>";
             $output .= $commonOutputMessage;
             // explicitly setting error reporting, since we cannot handle drupal related notices
             error_reporting(1);
             // automatically enable CiviCRM module once it is installed successfully.
             // so we need to Bootstrap Drupal, so that we can call drupal hooks.
             global $cmsPath, $crmPath;
             // relative / abosolute paths are not working for drupal, hence using chdir()
             chdir($cmsPath);
             // Force the re-initialisation of the config singleton on the next call
             // since so far, we had used the Config object without loading the DB.
             $c = CRM_Core_Config::singleton(FALSE);
             $c->free();
             include_once "./includes/bootstrap.inc";
             drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
             // rebuild modules, so that civicrm is added
             module_rebuild_cache();
             // now enable civicrm module.
             module_enable(array('civicrm'));
             // clear block, page, theme, and hook caches
             drupal_flush_all_caches();
             //add basic drupal permissions
             db_query('UPDATE {permission} SET perm = CONCAT( perm, \', access CiviMail subscribe/unsubscribe pages, access all custom data, access uploaded files, make online contributions, profile create, profile edit, profile view, register for events, view event info\') WHERE rid IN (1, 2)');
             echo $output;
         } elseif ($installType == 'wordpress') {
             echo '<h1>' . ts('CiviCRM Installed') . '</h1>';
             echo '<div style="padding: 1em;"><p style="background-color: #0C0; border: 1px #070 solid; color: white;">' . ts("CiviCRM has been successfully installed") . '</p>';
             echo '<ul>';
             $cmsURL = civicrm_cms_base();
             $cmsURL .= "wp-admin/admin.php?page=CiviCRM&q=civicrm/admin/configtask&reset=1";
             $wpPermissionsURL = "wp-admin/admin.php?page=CiviCRM&q=civicrm/admin/access/wp-permissions&reset=1";
             $output .= "<li>" . ts("WordPress user permissions have been automatically set - giving Anonymous and Subscribers access to public CiviCRM forms and features. We recommend that you <a %1>review these permissions</a> to ensure that they are appropriate for your requirements (<a %2>learn more...</a>)", array(1 => "target='_blank' href='{$wpPermissionsURL}'", 2 => "target='_blank' href='http://wiki.civicrm.org/confluence/display/CRMDOC/Default+Permissions+and+Roles'")) . "</li>";
             $output .= "<li>" . ts("Use the <a %1>Configuration Checklist</a> to review and configure settings for your new site", array(1 => "target='_blank' href='{$cmsURL}'")) . "</li>";
             $output .= $commonOutputMessage;
             echo '</ul>';
             echo '</div>';
             $c = CRM_Core_Config::singleton(FALSE);
             $c->free();
             $wpInstallRedirect = admin_url("?page=CiviCRM&q=civicrm&reset=1");
             echo "<script>\n         window.location = '{$wpInstallRedirect}';\n        </script>";
         }
     }
     return $this->errors;
 }
示例#25
0
 /**
  * Finishes the update process and stores the results for eventual display.
  *
  * After the updates run, all caches are flushed. The update results are
  * stored into the session (for example, to be displayed on the update results
  * page in update.php). Additionally, if the site was off-line, now that the
  * update process is completed, the site is set back online.
  *
  * @param $success
  *   Indicate that the batch API tasks were all completed successfully.
  * @param array $results
  *   An array of all the results that were updated in update_do_one().
  * @param array $operations
  *   A list of all the operations that had not been completed by the batch API.
  */
 public static function batchFinished($success, $results, $operations)
 {
     // No updates to run, so caches won't get flushed later.  Clear them now.
     drupal_flush_all_caches();
     $_SESSION['update_results'] = $results;
     $_SESSION['update_success'] = $success;
     $_SESSION['updates_remaining'] = $operations;
     // Now that the update is done, we can put the site back online if it was
     // previously not in maintenance mode.
     if (empty($_SESSION['maintenance_mode'])) {
         \Drupal::state()->set('system.maintenance_mode', FALSE);
     }
     unset($_SESSION['maintenance_mode']);
 }
示例#26
0
 /**
  * Tests loading of CKEditor CSS, JS and JS settings.
  */
 function testLoading()
 {
     // The untrusted user:
     // - has access to 1 text format (plain_text);
     // - doesn't have access to the filtered_html text format, so: no text editor.
     $this->drupalLogin($this->untrustedUser);
     $this->drupalGet('node/add/article');
     list($settings, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck();
     $this->assertFalse($editor_settings_present, 'No Text Editor module settings.');
     $this->assertFalse($editor_js_present, 'No Text Editor JavaScript.');
     $this->assertTrue(count($body) === 1, 'A body field exists.');
     $this->assertTrue(count($format_selector) === 0, 'No text format selector exists on the page.');
     $hidden_input = $this->xpath('//input[@type="hidden" and contains(@class, "editor")]');
     $this->assertTrue(count($hidden_input) === 0, 'A single text format hidden input does not exist on the page.');
     $this->assertNoRaw(drupal_get_path('module', 'ckeditor') . '/js/ckeditor.js', 'CKEditor glue JS is absent.');
     // On pages where there would never be a text editor, CKEditor JS is absent.
     $this->drupalGet('user');
     $this->assertNoRaw(drupal_get_path('module', 'ckeditor') . '/js/ckeditor.js', 'CKEditor glue JS is absent.');
     // The normal user:
     // - has access to 2 text formats;
     // - does have access to the filtered_html text format, so: CKEditor.
     $this->drupalLogin($this->normalUser);
     $this->drupalGet('node/add/article');
     list($settings, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck();
     $ckeditor_plugin = $this->container->get('plugin.manager.editor')->createInstance('ckeditor');
     $editor = Editor::load('filtered_html');
     $expected = array('formats' => array('filtered_html' => array('format' => 'filtered_html', 'editor' => 'ckeditor', 'editorSettings' => $this->castSafeStrings($ckeditor_plugin->getJSSettings($editor)), 'editorSupportsContentFiltering' => TRUE, 'isXssSafe' => FALSE)));
     $this->assertTrue($editor_settings_present, "Text Editor module's JavaScript settings are on the page.");
     $this->assertIdentical($expected, $this->castSafeStrings($settings['editor']), "Text Editor module's JavaScript settings on the page are correct.");
     $this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
     $this->assertTrue(count($body) === 1, 'A body field exists.');
     $this->assertTrue(count($format_selector) === 1, 'A single text format selector exists on the page.');
     $specific_format_selector = $this->xpath('//select[contains(@class, "filter-list") and @data-editor-for="edit-body-0-value"]');
     $this->assertTrue(count($specific_format_selector) === 1, 'A single text format selector exists on the page and has a "data-editor-for" attribute with the correct value.');
     $this->assertTrue(in_array('ckeditor/drupal.ckeditor', explode(',', $settings['ajaxPageState']['libraries'])), 'CKEditor glue library is present.');
     // Enable the ckeditor_test module, customize configuration. In this case,
     // there is additional CSS and JS to be loaded.
     // NOTE: the tests in CKEditorTest already ensure that changing the
     // configuration also results in modified CKEditor configuration, so we
     // don't test that here.
     \Drupal::service('module_installer')->install(array('ckeditor_test'));
     $this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions();
     $editor_settings = $editor->getSettings();
     $editor_settings['toolbar']['rows'][0][0]['items'][] = 'Llama';
     $editor->setSettings($editor_settings);
     $editor->save();
     $this->drupalGet('node/add/article');
     list($settings, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck();
     $expected = array('formats' => array('filtered_html' => array('format' => 'filtered_html', 'editor' => 'ckeditor', 'editorSettings' => $this->castSafeStrings($ckeditor_plugin->getJSSettings($editor)), 'editorSupportsContentFiltering' => TRUE, 'isXssSafe' => FALSE)));
     $this->assertTrue($editor_settings_present, "Text Editor module's JavaScript settings are on the page.");
     $this->assertIdentical($expected, $this->castSafeStrings($settings['editor']), "Text Editor module's JavaScript settings on the page are correct.");
     $this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
     $this->assertTrue(in_array('ckeditor/drupal.ckeditor', explode(',', $settings['ajaxPageState']['libraries'])), 'CKEditor glue library is present.');
     // Assert that CKEditor uses Drupal's cache-busting query string by
     // comparing the setting sent with the page with the current query string.
     $settings = $this->getDrupalSettings();
     $expected = $settings['ckeditor']['timestamp'];
     $this->assertIdentical($expected, \Drupal::state()->get('system.css_js_query_string'), "CKEditor scripts cache-busting string is correct before flushing all caches.");
     // Flush all caches then make sure that $settings['ckeditor']['timestamp']
     // still matches.
     drupal_flush_all_caches();
     $this->assertIdentical($expected, \Drupal::state()->get('system.css_js_query_string'), "CKEditor scripts cache-busting string is correct after flushing all caches.");
 }
示例#27
0
<?php
include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_flush_all_caches();
echo 'Clear cache';
示例#28
0
 /**
  * Clears the caches.
  */
 public function submitCacheClear(array &$form, array &$form_state)
 {
     drupal_flush_all_caches();
     drupal_set_message(t('Caches cleared.'));
 }
 /**
  * Reset all data structures after having enabled new modules.
  *
  * This method is called by DrupalWebTestCase::setUp() after enabling
  * the requested modules. It must be called again when additional modules
  * are enabled later.
  */
 protected function resetAll()
 {
     // Reset all static variables.
     drupal_static_reset();
     // Reset the list of enabled modules.
     module_list(TRUE);
     // Reset cached schema for new database prefix. This must be done before
     // drupal_flush_all_caches() so rebuilds can make use of the schema of
     // modules enabled on the cURL side.
     drupal_get_schema(NULL, TRUE);
     // Perform rebuilds and flush remaining caches.
     drupal_flush_all_caches();
     // Reload global $conf array and permissions.
     $this->refreshVariables();
     $this->checkPermissions(array(), TRUE);
 }
示例#30
0
function update_finished($success, $results, $operations)
{
    // clear the caches in case the data has been updated.
    drupal_flush_all_caches();
    $_SESSION['update_results'] = $results;
    $_SESSION['update_success'] = $success;
    $_SESSION['updates_remaining'] = $operations;
    // Now that the update is done, we can put the site back online if it was
    // previously turned off.
    if (isset($_SESSION['site_offline']) && $_SESSION['site_offline'] == FALSE) {
        variable_set('site_offline', FALSE);
        unset($_SESSION['site_offline']);
    }
}