diff --git a/profiles/wcm_base/modules/custom/ocio_search/ocio_search.install b/profiles/wcm_base/modules/custom/ocio_search/ocio_search.install index 3c0bc6b10adee65693fd35e608bb154c2cbde226..1debc16e4b2a8c8ca171d673699bb0425371ac65 100644 --- a/profiles/wcm_base/modules/custom/ocio_search/ocio_search.install +++ b/profiles/wcm_base/modules/custom/ocio_search/ocio_search.install @@ -1,17 +1,14 @@ <?php -/* +/** * Implements hook_install(). */ function ocio_search_install() { // Post Pantheon Apache Solr schema and set variable. - if (function_exists('pantheon_apachesolr_post_schema_exec')) { - $post = ocio_search_solr_post_schema(); - $posted = array( - 'dev' => !empty($post), - 'test' => FALSE, - 'live' => FALSE - ); - variable_set('pantheon_schema_posted', $posted); - } + $posted = array( + 'dev' => FALSE, + 'test' => FALSE, + 'live' => FALSE + ); + ocio_search_solr_post_schema($posted); } diff --git a/profiles/wcm_base/modules/custom/ocio_search/ocio_search.module b/profiles/wcm_base/modules/custom/ocio_search/ocio_search.module index 7184788ce3049180701a7ba660b2cd3d3f80c4b8..f54d05ff3abc109819d39b1f5058d9d8c967f831 100644 --- a/profiles/wcm_base/modules/custom/ocio_search/ocio_search.module +++ b/profiles/wcm_base/modules/custom/ocio_search/ocio_search.module @@ -10,26 +10,41 @@ include_once 'ocio_search.features.inc'; * Implements hook_cron(). */ function ocio_search_cron() { - $env = variable_get('pantheon_environment', 'dev'); + $env = variable_get('pantheon_environment'); $posted = variable_get('pantheon_schema_posted'); + if (empty($posted) || !isset($posted[$env])) { + $posted[$env] = FALSE; + } // If Solr schema has not been posted in the current environment, // post schema and set variable to prevent posting on each cron run. - if (isset($posted[$env]) && !$posted[$env] && function_exists('pantheon_apachesolr_post_schema_exec')) { - $post = ocio_search_solr_post_schema(); - - $posted[$env] = !empty($post); - variable_set('pantheon_schema_posted', $posted); - watchdog('ocio_search', 'ApacheSolr schema posted'); + if (!$posted[$env]) { + ocio_search_solr_post_schema($posted, $env); } } /** * Posts Solr schema and returns schema status. */ -function ocio_search_solr_post_schema() { - $schema = drupal_get_path('module', 'apachesolr') . '/solr-conf/solr-3.x/schema.xml'; - return pantheon_apachesolr_post_schema_exec($schema); +function ocio_search_solr_post_schema($posted, $env = '') { + + if (function_exists('pantheon_apachesolr_post_schema_exec')) { + + $schema = drupal_get_path('module', 'apachesolr') . '/solr-conf/solr-3.x/schema.xml'; + $post = pantheon_apachesolr_post_schema_exec($schema); + $result = !empty($post); + + if ($result) { + watchdog('ocio_search', 'ApacheSolr schema posted'); + } + + if (empty($env)) { + $env = variable_get('pantheon_environment'); + } + + $posted[$env] = $result; + variable_set('pantheon_schema_posted', $posted); + } } /**