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

Call to a member function structure() on null #3478

Closed
Robinvm opened this issue Apr 6, 2021 · 11 comments · Fixed by #3901
Closed

Call to a member function structure() on null #3478

Robinvm opened this issue Apr 6, 2021 · 11 comments · Fixed by #3901

Comments

@Robinvm
Copy link

Robinvm commented Apr 6, 2021

Bug Description

I suddenly get the error: Call to a member function structure() on null

Statamic\Structures\CollectionTree::Statamic\Structures{closure} vendor/statamic/cms/src/Structures/CollectionTree.php:19

return Blink::once('collection-tree-structure-'.$this->handle(), function () {

   ERROR====> return Collection::findByHandle($this->handle())->structure();

});

How to Reproduce

I made a new collection, and after that pages collection started to do this. When i save it says saved, save again, error, save again, saved, save again, error.

Extra Detail

Schermafbeelding 2021-04-06 om 11 06 18

Environment

Statamic 3.1.3 Pro
Laravel 8.35.1
PHP 7.4.16
cnj/seotamic 2.0.3
pecotamic/sitemap 1.2.1

Statamic version: 3.0.{?}
3.1.3 Pro

PHP version: 7.4.16

Install method (choose one):

  • Fresh install from statamic/statamic THIS ONE
  • Starter kit
  • Existing Laravel app
  • Other (please explain this magic!)
@duncanmcclean
Copy link
Member

duncanmcclean commented Apr 7, 2021

So you created a new collection, then you went back to your Pages collection and it gave you that error? Correct?

Also, when you get the error, are you in the CP or in the front-end?

@taylorcammack
Copy link

Having a similar issue, but different scenario so hopefully could provide some insight.

In my case, just migrated from a V2 site. Created the Pages collection, started seeing this error pop up. After refreshing, it seems to work correctly. After deleting the page, it throws a similar console error. In both cases, refreshing seems to clear things up.

Screen.Recording.2021-04-20.at.10.08.42.AM.mov

Environment

Statamic 3.1.9 Solo
Laravel 7.30.4
PHP 7.4.15
aryehraber/statamic-captcha 1.4.0
encore/app dev-master
spatie/statamic-responsive-images 2.5.3
statamic/migrator dev-master

@taylorcammack
Copy link

Looks like it also throws the error after every page update. Resolves on a refresh. Any idea for where to start poking around?

@robdekort
Copy link
Contributor

Getting a similar issue on the site I'm working. It happens when warming the stache here.
Screenshot 2021-04-21 at 09 24 46

@robdekort
Copy link
Contributor

And when saving pages

@Robinvm
Copy link
Author

Robinvm commented Apr 21, 2021

I got a fix for it. In the tree directory, i deleted the pages.yaml or something, it just regenerated and now it works correctly on my side. Not the best fix i guess, but it works.

@robdekort
Copy link
Contributor

Hmmm, doesn't seem to work here. I just loose my page tree ;-)

@Robinvm
Copy link
Author

Robinvm commented Apr 21, 2021

Yes but then just save a page and it regenerates

@robdekort
Copy link
Contributor

robdekort commented Apr 21, 2021

Ah! I removed content/trees/pages.yaml while the issue was with content/trees/projects.yaml. It just contained:

{ }

Projects was as a structured collection before and then later I turned it into a date based collections. This seems to leave behind a nearly empty tree file which causes this error when warming the stache.

Hope it helps solving this one.

@robdekort
Copy link
Contributor

I was able to reproduce this on a fresh install by:

  1. Making a new orderable collection
  2. Adding some entries so you get a tree
  3. Turn collection into a non structured collection (date based for example)
  4. Warm the stache.

If you use statamic-issue-3478.zip you'll get it for free. Just run php please stache:warm.

Switching to non structured collection should probably remove the tree collection.yaml file.

@DrTrills
Copy link

I have the same issue. New site install. in terminal if I run php please stache:warm

Warming Stache...

   Error

  Call to a member function structure() on null

  at vendor/statamic/cms/src/Structures/CollectionTree.php:19
     15▕ {
     16▕     public function structure()
     17▕     {
     18▕         return Blink::once('collection-tree-structure-'.$this->handle(), function () {
  ➜  19▕             return Collection::findByHandle($this->handle())->structure();
     20▕         });
     21▕     }
     22▕
     23▕     public function path()

      +8 vendor frames
  9   [internal]:0
      Statamic\Stache\Indexes\Value::Statamic\Stache\Indexes\{closure}()

      +26 vendor frames
  36  please:37
      Illuminate\Foundation\Console\Kernel::handle()

Also possibly related, in the CP when I click clear content stache I get a 500 error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants