Hello,
I'm trying to add an extra path to the static build following the same pattern that its followed in Lunr module. However, that path is not being added to the /html folder.
The path I'm talking about is like "/modules/custom/mymodule/images/my_image.png". So I'm adding it to the event subscriber, expecting to have it exported to the /html folder.
However, it is not being exported. After some debugging, I found that StaticGenerator::requestPath()
is not working correctly in this case. This line $response = $this->httpKernel->handle($request, HttpKernelInterface::MASTER_REQUEST);
is returning a 404 error, even if the file is there actually. I believe this is because that path in the original site is not being served by PHP, but directly by the Apache server.
Reading the requestPath
docs, it says this "This method should only be called for paths that need a Drupal bootstrap.". So it seems that the Lunr or my example use cases are not covered. However, it seems that it the Lunr module integration is working.
The annoying thing, is that I tried to replicate the Lunr module behavior and I found that Lunr index related json files are not being exported to /html folder anymore. Those files were exported in other tests I made before, so maybe I'm doing something wrong now.
Any idea?
Here are some environment details that could help:
Drupal version: 8.6.13
PHP version: 7.2.15
Tome version: 1.0-beta-4
Lunr version: 1.x-dev
Comment | File | Size | Author |
---|---|---|---|
#4 | 3046290-4-ui-export.patch | 659 bytes | plopesc |
|
Comments
Comment #2
plopescComment #3
plopescHello,
After a bit more of debugging, I found this is happening only when generating the static site from the UI. Generating the site from Drush, it works as expected. Both the Lunr json files and my custom image are being exported to the html file successfully.
From my basic understanding, it is happening because
StaticGenerator::exportPaths()
is the first thing executed by the drush command. However, generating the static site from the UI, it is executed at the end of the process, once these paths have been discarded because they return the 404 code inStaticCommand::RequestPath
.Regards.
Comment #4
plopescHere is a simple patch that worked for me. It just runs
StaticGenerator::exportPaths()
at the beginning of the process, as it's happening from Drush. Both lunr and my custom files are being imported and the rest of the static site is still working as expected, I think.Regards.
Comment #6
samuel.mortenson@plopesc This makes sense to me - thanks for figuring it out!