distantnative / search-for-kirby

Kirby 3 plugin for adding a search index (sqlite or Algolia).
43 stars 3 forks source link

Develop-branch: Return value of Kirby\Cms\App::root() must be of the type string, null returned #35

Closed hannesherold closed 3 years ago

hannesherold commented 3 years ago

Using the develop-branch, there's an error when trying to create the index from the command line:

Loading Kirby...
Reindexing using the Search plugin...
TypeError: Return value of Kirby\Cms\App::root() must be of the type string, null returned in file /Users/user/plainkit/kirby/src/Cms/App.php on line 1136
Stack trace:
  1. TypeError->() /Users/user/plainkit/kirby/src/Cms/App.php:1136
  2. Kirby\Cms\App->root() /Users/user/plainkit/site/plugins/search/src/models/Providers/Sqlite.php:67
  3. Kirby\Search\Providers\Sqlite->defaults() /Users/user/plainkit/site/plugins/search/src/models/Provider.php:67
  4. Kirby\Search\Provider->setOptions() /Users/user/plainkit/site/plugins/search/src/models/Providers/Sqlite.php:37
  5. Kirby\Search\Providers\Sqlite->\_\_construct() /Users/user/plainkit/site/plugins/search/src/models/Index.php:50
  6. Kirby\Search\Index->\_\_construct() /Users/user/plainkit/site/plugins/search/bin/index:24

Same error with $results = $site->search($query);

In the panel section : Invalid section type ("search“)

The config file of the plainkit:

<?php

return [
  'debug'  => true, 
  'search' => [
    'provider' => 'sqlite',
    'sqlite' => [
      'fuzzy' => false,
    ]
  ]
];

Specifications

distantnative commented 3 years ago

Ah sorry, I didn't really that earlier: I'm building v1.1 to be based on Kirby 3.5 - which features a new logs root. And that's exactly that I am calling there but because you are on 3.4.4 it crashes.

For testing, you could either run Kirby on its features branch. Or you edit the line 67 in site/plugins/search/src/models/Providers/Sqlite.php from

            'file'     => kirby()->root('logs') . '/search/index.sqlite',

to

            'file'    => dirname(__DIR__, 5) . '/logs/search/index.sqlite',

The missing Panel section will return before the v1.1 release.

hannesherold commented 3 years ago

I see, thank you! Replaced the line, now it works.