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

Statamic 4 + SSG won't Generate #74

Closed
mc4rdle opened this issue Jun 4, 2023 · 7 comments
Closed

Statamic 4 + SSG won't Generate #74

mc4rdle opened this issue Jun 4, 2023 · 7 comments
Labels
statamic Is dependent on a Statamic issue

Comments

@mc4rdle
Copy link

mc4rdle commented Jun 4, 2023

When I run php please ssg:generate I get this error:

Gathering content to be generated...

   Error

  Call to a member function url() on null

  at vendor/statamic/ssg/src/Request.php:51
     47▕     }
     48▕
     49▕     public function getPathInfo(): string
     50▕     {
  ➜  51▕         return $this->page->url();
     52▕     }
     53▕
     54▕     public function path()
     55▕     {

      +34 vendor frames

  35  [internal]:0
      Illuminate\Support\Collection::Illuminate\Support\Traits\{closure}(Object(Statamic\Entries\Entry))
      +21 vendor frames

  57  please:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

As soon as I uninstall it, it generates fine.

My project:
Environment
Application Name: Keepme
Laravel Version: 10.12.0
PHP Version: 8.1.17
Composer Version: 2.5.5
Environment: local
Debug Mode: ENABLED
URL: keepme.test
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 3
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 4.3.0 PRO

Statamic Addons
aerni/advanced-seo: 2.1.1
statamic/ssg: 2.0.0
stefangalescu/statamic-heroicons: 2.1

@mc4rdle
Copy link
Author

mc4rdle commented Jun 4, 2023

I've tried clearing cache and stache but still it persists.

@aerni
Copy link
Owner

aerni commented Jun 4, 2023

I'm going to need more information to work with. What's causing the error? I just tried to reproduce it on a fresh installation with aerni/advanced-seo and statamic/ssg. I can run ssg:generate without an error.

Please create a fresh repo that reproduces the error so I can take a look at it.

@mc4rdle
Copy link
Author

mc4rdle commented Jun 7, 2023

Yea, the logs don't seem to give any clues. I tried to remove everything one by one until it worked. It turns out two collections were causing it (Blog and Webinars), and they both had two things in common:

  1. they were sorted by date
  2. they had a taxonomy linked to the collection

Deleting every entry in both collections stopped the error. Removing the Taxonomy or disabling Enable Publish Dates from the collection alone doesn't stop it, but removing/disabling both on the collection at the same time does, which is strange.

Log File:
log.txt

@mc4rdle
Copy link
Author

mc4rdle commented Jun 7, 2023

I was able to replicate it on a new site.

  1. Created a fresh new blank statamic site
  2. Install SSG package
  3. Create a collection and give them a URL eg blog/{slug}
  4. Make the collection orderable by date
  5. Attach a taxonomy to the collection
  6. Run php please ssg:generate and it will fail

The collection's yaml file on my new fresh site:

title: Blog
template: blog/show
layout: layout
taxonomies:
  - tags
revisions: false
route: '/blog/{slug}'
date: true
sort_dir: asc
date_behavior:
  past: public
  future: private
preview_targets:
  -
    label: Entry
    url: '{permalink}'
    refresh: true

@aerni
Copy link
Owner

aerni commented Jun 7, 2023

I tracked this down, and it seems to be an issue with the statamic/ssg package. Advanced SEO depends on the request()->path() to determine if a collection's blueprint should be extended or not. This is where the ssg:generate command fails. I'll open an issue on the repo and see where that goes. I might be able to fix the issue on my end with a nasty workaround. But I rather not.

@aerni
Copy link
Owner

aerni commented Jun 7, 2023

This is the issue I opened for reference: statamic/ssg#134

@aerni aerni added the statamic Is dependent on a Statamic issue label Jun 7, 2023
@mc4rdle
Copy link
Author

mc4rdle commented Jun 8, 2023

Thank you!

@aerni aerni closed this as completed Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
statamic Is dependent on a Statamic issue
Projects
None yet
Development

No branches or pull requests

2 participants