Skip to content
Snippets Groups Projects
Commit 3b76e90a authored by Jürgen Haas's avatar Jürgen Haas Committed by Adam G-H
Browse files

Issue #3497302 by phenaproxima, jurgenhaas, thejimbirch, pameeela,...

Issue #3497302 by phenaproxima, jurgenhaas, thejimbirch, pameeela, a.dmitriiev: Search must be indexed after recipe is applied
parent 1c7f1821
Branches
Tags
No related merge requests found
Pipeline #389904 passed
......@@ -4,6 +4,10 @@
## Usage: rebuild
## Example: "ddev rebuild"
ddev drush sql:drop --yes
drush sql:drop --yes
rm -f composer.lock patches.lock.json
ddev restart
generate-composer-json > composer.json
composer install
composer patches-relock
composer patches-repatch
......@@ -12,7 +12,7 @@
"drupal/drupal_cms_privacy_basic": "*",
"drupal/geocoder": "^4.10",
"drupal/geofield": "^1.47",
"drupal/leaflet": "^10.2.25",
"drupal/leaflet": "^10.2.33",
"drupal/smart_date": "^4.2.1",
"geocoder-php/nominatim-provider": "^5.7"
}
......
# By resetting the last cron run time, this forces the `content` search index
# to be rebuilt when it is created, because the next page request will run
# cron via the automated_cron module. This can be removed when there is a
# config action to rebuild a search index, or some other way for a recipe to
# trigger a cron run.
langcode: en
status: true
dependencies:
module:
- eca_base
- eca_config
id: init_search
modeller: fallback
label: 'Initialize search index'
version: 1.0.0
weight: 0
events:
Event_write_config:
plugin: 'config:save'
label: 'Write config'
configuration: { }
successors:
-
id: Gateway_and_1
condition: Flow_is_search_index
conditions:
Flow_is_search_index:
plugin: eca_scalar
configuration:
negate: false
case: false
left: '[config_name]'
right: search_api.index.content
operator: equal
type: value
Flow_is_new:
plugin: eca_scalar
configuration:
case: false
left: '[config_original:name]'
right: '[config:name]'
operator: equal
type: value
negate: true
gateways:
Gateway_and_1:
type: 0
successors:
-
id: Activity_reset_last_cron_run
condition: Flow_is_new
actions:
Activity_reset_last_cron_run:
plugin: eca_keyvaluestore_write
label: 'Reset last cron run'
configuration:
collection: state
key: system.cron_last
value: '0'
use_yaml: false
ifnotexists: false
successors: { }
......@@ -6,6 +6,7 @@ namespace Drupal\Tests\drupal_cms_starter\Functional;
use Composer\InstalledVersions;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\State\StateInterface;
use Drupal\Tests\BrowserTestBase;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;
......@@ -112,9 +113,54 @@ class ComponentValidationTest extends BrowserTestBase {
// Pages should have the expected path aliases.
$assert_session->addressMatches('/\/test-page$/');
}
$this->drupalCreateNode([
'type' => $node_type,
'title' => "Search for this $node_type",
'moderation_state' => 'published',
]);
}
$this->drupalLogout();
// If we apply the search recipe, the content we just created in the loop
// above should all be searchable.
$dir = InstalledVersions::getInstallPath('drupal/drupal_cms_search');
$this->applyRecipe($dir);
// The creation of the search index should have reset the last cron run time
// to zero.
/** @var \Drupal\Core\State\StateInterface $state */
$state = $this->container->get(StateInterface::class);
$last_cron_run = $state->get('system.cron_last');
$this->assertSame('0', $last_cron_run);
$last_cron_run = intval($last_cron_run);
// Thanks to automated_cron, this request will trigger a cron run.
$this->drupalGet('/search');
// The cron work may outlive the HTTP request, so wait for it to finish.
$seconds_waited = 0;
while ($last_cron_run === 0) {
$state->resetCache();
$last_cron_run = (int) $state->get('system.cron_last');
// We've given it a whole minute; it should be done by now.
if (++$seconds_waited === 60) {
break;
}
else {
sleep(1);
}
}
$this->assertGreaterThan(0, $last_cron_run);
// The content we created should now be searchable.
foreach ($node_types as $node_type) {
$page->fillField('Search keywords', $node_type);
$page->pressButton('Find');
$assert_session->linkExists("Search for this $node_type");
}
// If you have permission to administer modules, you should see a dedicated
// tab to browse recipes.
$account = $this->drupalCreateUser(['administer modules']);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment