Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/VOTE-3074 tome increase path count patch #1172

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
"patches": {
"drupal/double_field": {
"Support input filters on text formats (original issue: https://www.drupal.org/node/2091587)": "patches/double_field/2091587-text_long-60_2.patch"
},
"drupal/tome": {
"Paths are exported multiple times with path counts > 1: https://www.drupal.org/project/tome/issues/3478842": "patches/tome/tomePathCountFixes.patch"
}
},
"drupal-scaffold": {
Expand Down
92 changes: 92 additions & 0 deletions patches/tome/tomePathCountFixes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
diff --git a/modules/tome_static/src/Commands/StaticCommand.php b/modules/tome_static/src/Commands/StaticCommand.php
index 56d963b5607c3ffdeebdf6c7854f0d0b1ece1b06..d6fbaca2cb30308f156e9927529673dfbf81f778 100644
--- a/modules/tome_static/src/Commands/StaticCommand.php
+++ b/modules/tome_static/src/Commands/StaticCommand.php
@@ -53,6 +53,8 @@ class StaticCommand extends CommandBase {
*/
protected $state;

+ protected $init_paths = [];
+
/**
* Constructs a StaticCommand instance.
*
@@ -123,6 +125,9 @@ class StaticCommand extends CommandBase {
}

$this->io->writeln('Generating static HTML...');
+
+ $this->setInitialPaths($paths);
+
$this->exportPaths($paths, [], $options['process-count'], $options['path-count'], TRUE, $options['retry-count'], $options['uri']);
$this->io->success('Exported static HTML and related assets.');

@@ -135,6 +140,14 @@ class StaticCommand extends CommandBase {
return 0;
}

+ protected function setInitialPaths(array $paths): void {
+ $this->init_paths = $paths;
+ }
+
+ protected function getInitialPaths(): array {
+ return $this->init_paths;
+ }
+
/**
* Exports the given paths to the static directory.
*
@@ -175,15 +188,18 @@ class StaticCommand extends CommandBase {
$show_progress && $this->io->progressStart(count($paths));

$invoke_paths = [];
- $collected_errors = $this->runCommands($commands, $process_count, $retry_count, function (Process $process) use ($show_progress, &$invoke_paths, $path_count) {
+ $collected_errors = $this->runCommands($commands, $process_count, $retry_count, function (Process $process) use ($show_progress, &$invoke_paths, $path_count, $old_paths) {
$show_progress && $this->io->progressAdvance($path_count);
$output = $process->getOutput();
if (!empty($output) && $json = json_decode($output, TRUE)) {
$invoke_paths = array_unique(array_merge($invoke_paths, $json));
+
+ // don't include paths that are going to be exported by another process
+ $invoke_paths = array_diff($invoke_paths, $old_paths, $this->getInitialPaths());
}
});

- $invoke_paths = array_diff($invoke_paths, $old_paths);
+ $invoke_paths = array_diff($invoke_paths, $old_paths, $this->getInitialPaths());
$old_paths = array_merge($old_paths, $invoke_paths);

$show_progress && $this->io->progressFinish();
@@ -191,6 +207,7 @@ class StaticCommand extends CommandBase {
$this->displayErrors($collected_errors);
}
if (count($invoke_paths)) {
+ $this->init_paths = array_merge($this->init_paths, $invoke_paths);
$this->io->writeln('Processing related assets and paths...');
$this->exportPaths($invoke_paths, $old_paths, $process_count, $path_count, $show_progress, $retry_count, $uri);
}
diff --git a/modules/tome_static/src/Commands/StaticExportPathCommand.php b/modules/tome_static/src/Commands/StaticExportPathCommand.php
index 933321846edd33204522259f1411ff5eab404376..4ff8dd3e79a9cd9e5db72b8b7d0d0f2e73007d4a 100644
--- a/modules/tome_static/src/Commands/StaticExportPathCommand.php
+++ b/modules/tome_static/src/Commands/StaticExportPathCommand.php
@@ -68,6 +68,7 @@ class StaticExportPathCommand extends StaticCommand {
$this->requestPreparer->prepareForRequest();
try {
$invoke_paths = array_merge($this->static->requestPath($path), $invoke_paths);
+ $invoke_paths = array_unique($invoke_paths);
}
catch (\Exception $e) {
$this->io->getErrorStyle()->error($this->formatPathException($path, $e));
diff --git a/modules/tome_static/src/RequestPreparer.php b/modules/tome_static/src/RequestPreparer.php
index be08b0460e494b74492f3940634b8ab71aa1f900..7d514d82f689ddf203b6280dc1f702cfa4327159 100644
--- a/modules/tome_static/src/RequestPreparer.php
+++ b/modules/tome_static/src/RequestPreparer.php
@@ -110,7 +110,7 @@ class RequestPreparer {
}
// Reset active trail cache.
if ($this->menuActiveTrail instanceof CacheCollectorInterface) {
- $this->menuActiveTrail->reset();
+ $this->menuActiveTrail->clear();
}
// Reset the language manager.
$this->languageManager->reset();
2 changes: 1 addition & 1 deletion scripts/upkeep
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ echo ""
echo "**************************************************"
echo "Running 'drush tome:static' in '${environment}'..."
echo "**************************************************"
drush tome:static --uri=${ssg_endpoint} --path-count=1 --retry-count=3 -y
drush tome:static --uri=${ssg_endpoint} --retry-count=3 -y
drush tome:static-export-path '/sitemap.xml,/sitemap_generator/default/sitemap.xsl' --uri=${ssg_sitemap_endpoint} --retry-count=3 -y
drush cr
echo "'drush tome:static' task...completed!"
Expand Down