Closed tao closed 3 years ago
The error was caused by a config error as there was a mismatch between the sites handle in the config and the languages handle used in the collection yaml file.
Hi @tao
I have the same problem. Where, more specific, did you have the mismatch? Thanks.
@thomaskenne this was a while ago so can't remember 100% but double check that the sites handle in config/statamic/sites.php
is that same as the ones used in your collection yaml file and the folder names in each collection are the same too.
For example, if your sites config has this:
'sites' => [
'en' => [
'name' => 'English',
'locale' => 'en_US',
'url' => '/',
],
'bg' => [
'name' => 'Bulgarian',
'locale' => 'bg_BG',
'url' => '/bg/',
],
Make sure the collection yaml file has the same ones:
title: Articles
sites:
- en
- bg (not bs)
As well as the folders in Articles subfolders should match:
├── articles
│ └── en
│ └── bg
@tao thanks Daniel! Unfortunately this is not the case here. Seems to be at random where ssg halts when building. Hmm. I will dig deeper.
The randomness is to be expected - the SSG generates the pages in a random order.
If you could provide the stack trace which ends up in your log file, that would be helpful.
@jasonvarga ah - ok. Thanks for chiming in:
This the support details:
Statamic 3.2.6 Pro
Laravel 8.61.0
PHP 8.0.10
statamic/ssg 0.8.0
Here is a stacktrace:
[2021-09-24 14:19:19] local.ERROR: Call to a member function handle() on null {"exception":"[object] (Error(code: 0): Call to a member function handle() on null at /Users/thomas/Projects/doording-cms/vendor/statamic/ssg/src/Generator.php:353)
[stacktrace]
#0 /Users/thomas/Projects/doording-cms/vendor/statamic/ssg/src/Generator.php(232): Statamic\\StaticSite\\Generator->updateCurrentSite(NULL)
#1 /Users/thomas/Projects/doording-cms/vendor/spatie/fork/src/Task.php(92): Statamic\\StaticSite\\Generator->Statamic\\StaticSite\\{closure}()
#2 /Users/thomas/Projects/doording-cms/vendor/spatie/fork/src/Fork.php(154): Spatie\\Fork\\Task->execute()
#3 /Users/thomas/Projects/doording-cms/vendor/spatie/fork/src/Fork.php(128): Spatie\\Fork\\Fork->executeInChildTask(Object(Spatie\\Fork\\Task), Object(Spatie\\Fork\\Connection))
#4 /Users/thomas/Projects/doording-cms/vendor/spatie/fork/src/Fork.php(103): Spatie\\Fork\\Fork->forkForTask(Object(Spatie\\Fork\\Task))
#5 /Users/thomas/Projects/doording-cms/vendor/spatie/fork/src/Fork.php(183): Spatie\\Fork\\Fork->runTask(Object(Spatie\\Fork\\Task))
#6 /Users/thomas/Projects/doording-cms/vendor/spatie/fork/src/Fork.php(76): Spatie\\Fork\\Fork->startRunning(Object(Spatie\\Fork\\Task))
#7 /Users/thomas/Projects/doording-cms/vendor/spatie/fork/src/Fork.php(69): Spatie\\Fork\\Fork->waitFor(Object(Spatie\\Fork\\Task))
#8 /Users/thomas/Projects/doording-cms/vendor/statamic/ssg/src/ConcurrentTasks.php(18): Spatie\\Fork\\Fork->run(Object(Closure))
#9 /Users/thomas/Projects/doording-cms/vendor/statamic/ssg/src/Generator.php(185): Statamic\\StaticSite\\ConcurrentTasks->run(Object(Closure))
#10 /Users/thomas/Projects/doording-cms/vendor/statamic/ssg/src/Generator.php(91): Statamic\\StaticSite\\Generator->createContentFiles()
#11 /Users/thomas/Projects/doording-cms/vendor/statamic/ssg/src/Commands/StaticSiteGenerate.php(60): Statamic\\StaticSite\\Generator->generate()
#12 /Users/thomas/Projects/doording-cms/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Statamic\\StaticSite\\Commands\\StaticSiteGenerate->handle()
#13 /Users/thomas/Projects/doording-cms/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#14 /Users/thomas/Projects/doording-cms/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#15 /Users/thomas/Projects/doording-cms/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#16 /Users/thomas/Projects/doording-cms/vendor/laravel/framework/src/Illuminate/Container/Container.php(651): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#17 /Users/thomas/Projects/doording-cms/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\\Container\\Container->call(Array)
#18 /Users/thomas/Projects/doording-cms/vendor/symfony/console/Command/Command.php(299): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#19 /Users/thomas/Projects/doording-cms/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#20 /Users/thomas/Projects/doording-cms/vendor/symfony/console/Application.php(978): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#21 /Users/thomas/Projects/doording-cms/vendor/symfony/console/Application.php(295): Symfony\\Component\\Console\\Application->doRunCommand(Object(Statamic\\StaticSite\\Commands\\StaticSiteGenerate), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#22 /Users/thomas/Projects/doording-cms/vendor/symfony/console/Application.php(167): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#23 /Users/thomas/Projects/doording-cms/vendor/laravel/framework/src/Illuminate/Console/Application.php(92): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#24 /Users/thomas/Projects/doording-cms/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#25 /Users/thomas/Projects/doording-cms/please(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#26 {main}
Right between these two lines:
https://github.com/statamic/ssg/blob/54dd99f77db5620af44e6c84fa549a31c1f30bd9/src/Generator.php#L231-L232
(Which will be in vendor/statamic/ssg/src/Generator.php
)
Add this:
if (!$page->site()) {
dd($page->url(), $page);
}
Then run the generator again. Can you paste or provide a screenshot of what you see?
hmm - is it 404-something?
doording-cms php please ssg:generate
You may be able to speed up site generation significantly by installing spatie/fork and using multiple workers (requires PHP 8+).
[✔] Gathered content to be generated
Generating /til-opgangen
"/404"
Statamic\StaticSite\Page^ {#337
#files: Illuminate\Filesystem\Filesystem^ {#112}
#config: array:7 [
"base_url" => "http://doording.test"
"destination" => "/Users/thomas/Projects/doording-cms/storage/app/static"
"copy" => array:4 [
"/Users/thomas/Projects/doording-cms/public/css" => "css"
"/Users/thomas/Projects/doording-cms/public/js" => "js"
"/Users/thomas/Projects/doording-cms/public/img" => "img"
"/Users/thomas/Projects/doording-cms/public/assets" => "assets"
]
"symlinks" => []
"urls" => []
"exclude" => []
"glide" => array:1 [
"directory" => "img"
]
]
#content: Statamic\StaticSite\Route^ {#471
#url: "http://doording.test/404"
}
[✔] Generated 0 content files
[✔] /Users/thomas/Projects/doording-cms/public/css copied to /Users/thomas/Projects/doording-cms/storage/app/static/css
[✔] /Users/thomas/Projects/doording-cms/public/js copied to /Users/thomas/Projects/doording-cms/storage/app/static/js
[✔] /Users/thomas/Projects/doording-cms/public/img copied to /Users/thomas/Projects/doording-cms/storage/app/static/img
[✔] /Users/thomas/Projects/doording-cms/public/assets copied to /Users/thomas/Projects/doording-cms/storage/app/static/assets
Static site generated into /Users/thomas/Projects/doording-cms/storage/app/static
´´´
What's in your config/statamic/sites.php
?
return [
'sites' => [
'doording-dk' => [
'name' => 'Doording (DK)',
'locale' => 'da',
'url' => 'http://doording-cms.test/',
],
'uwt-en' => [
'name' => 'UWT (EN)',
'locale' => 'en',
'url' => 'http://uwt.test/',
],
],
];
Oh boy - I just found out now that my env('APP_URL') was wrong. Correcting that, fixed this issue.
@jasonvarga Thanks for taking the time and bringing the dd
that helped me realize that.
Thanks for following up!
It seems like since updating I'm having an issue with this absoluteUrl method:
If I do a quick modification to the function to test
$this->site()
is not null before calling->absoluteUrl()
then it seems to work not throw this error anymore.But after over-coming the first one I'm also getting this error on random pages during generation... so $site is null is causing a larger issue in other classes too?
As well as this one at the end: