- First commit to issue fork.
- Status changed to Needs work
10 months ago 4:14pm 15 January 2024 - 🇬🇧United Kingdom joachim
Setting to NW based on #8.
Making a MR for this and going to address some of the points.
- 🇬🇧United Kingdom joachim
> we also generate static HTML via the command line and tome_static_cron,
This to me really suggests that more of the static generation code should be in an API and less in the running/UI code -- Drush/cron/batch. But that's for another issue.
I can add the success event to the Drush StaticCommand class, but I'm not sure where the failure event would get called? There's this in exportPaths():
if (!empty($collected_errors)) { $this->displayErrors($collected_errors); }
but exportPaths is called recursively in StaticCommand AND by the inner command StaticExportPathCommand -- so the event would be fired multiple times which we don't want. (See 📌 refactor code to remove Drush command calling another command Active .)
For cron it's even worse -- I'm not suere where we'd call the success event, as things are put into a queue. I guess we could add a final queue item whose sole purpose is to fire the event?
- 🇬🇧United Kingdom joachim
I think the success/failure distinction needs more thought.
This code in the StaticGeneratorForm (in the MR version) shows this:
if (!$success) { # This is a failure of the whole batch with Batch API. $this->messenger()->addError($this->t('Static build failed - consult the error log for more details.')); $event = new BuildFinishEvent(FALSE); $this->eventDispatcher->dispatch($event, TomeStaticEvents::BUILD_FINISH); return; } if (!empty($results['errors'])) { # This is exceptions from making requests with StaticGenerator. # This counts as a success! foreach ($results['errors'] as $error) { $this->messenger()->addError($error); } }
We have batch API failure, but also a case where we have error messages from StaticGenerator - but that's treated as a success.
And furthermore, error messages from StaticGenerator do NOT include errors if requests for site paths produce a 500 from the site -- those errors are just ignored -- see ✨ StaticGenerator::requestPath() doesn't do anything with a request that produces a 500 error Needs review .
- 🇧🇪Belgium yoerioptr
I've updated the patch so it applies again. Also triggered the event after executing the
tome:static
command.