distantnative / search-for-kirby

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

Updateing text field on site-object does not work anymore #39

Closed bnomei closed 3 years ago

bnomei commented 3 years ago
Argument 1 passed to Kirby\Search\Index::update() must be of the type string, null given, called in /XXX/site/plugins/search-for-kirby/src/config/hooks.php on line 16 
bnomei commented 3 years ago
'search' => [
        'provider' => 'sqlite',
        'sqlite' => [
            'file'  => realpath(__DIR__ . '/../../storage') . '/search/search.sqlite', // absolute path, default points to `media/search.sqlite`
            'fuzzy' => [
                'pages' => ['title'],
            ],
        ],
        'entries' => [
            'pages' => 'site.index',
            'files' => false,
            'users' => false,
        ],
        'fields' => [
            'pages' => [
                'title',
                'date' => function ($page) {
                    if (in_array($page->template()->name(), ['seite', 'termine'])) {
                        return implode(',', $page->daysInEvents());
                    }
                    return $page->date()->isNotEmpty() ?
                        $page->date()->toDate('d.m.Y') :
                        date('d.m.Y', $page->modified());
                },
                'tags' => function ($page) {
                    return $page->tags()->isNotEmpty() ?
                        $page->tags()->value() :
                        '';
                },
                'newslettertags' => function ($page) {
                    return $page->newslettertags()->isNotEmpty() ?
                        $page->newslettertags()->value() :
                        '';
                },
                'standort' => function ($page) {
                    return $page->standort()->isNotEmpty() ?
                        $page->standort()->value() :
                        '';
                },
//                'location' => function ($page) {
//                    $loc =  $page->location()->isNotEmpty() ?
//                        $page->location()->value() :
//                        '';
//
//                    if ($page->blueprint()->fields()['location']['type'] === 'locator') {
//                        $loc = $page->eventLocation();
//                    }
//
//                    return $loc;
//                },
                'description' => function ($page) {
                    return $page->description()->isNotEmpty() ?
                        strip_tags($page->description()->kt()) :
                        '';
                },
                'text' => function ($page) {
                    return strip_tags($page->text()->kt());
                },
            ],
        ],
        'templates' => [
            'pages' => function ($page) {
                $templates = (array) option('xxx.suche.templates', []);
                return in_array($page->template()->name(), $templates);
            },
            'files' => null,
            'users' => null
        ],
    ],
distantnative commented 3 years ago

"Not anymore" means you are using the latest develop branch version? Or just you're using the release and suddenly it stopped working?

bnomei commented 3 years ago

i am using "distantnative/search-for-kirby": "^1.0",. on localhost i can save the site->object (editing via panel) but on live server i can not but get that error. i checked file permissions for sqlite db of retour and all seems well (app user and www-data group)

bnomei commented 3 years ago

editing other content pages in panel (that should trigger search plugin hooks) works fine. also running the forced reindex of search via CLI does not yield errors. so maybe its just something about the site object?

distantnative commented 3 years ago

I would think it's the same bug fixed by https://github.com/distantnative/search-for-kirby/commit/57f4a9ffb56125c7180d875b95960996d331d8da

Or in your version the code might still look different, but removing the site hook from config/hooks.php might solve it for you too (until new version gets released alongside Kirby 3.5)

bnomei commented 3 years ago

how could i miss that issue. thanks for clarifying

distantnative commented 3 years ago

Easy to miss, no worries. As long as it solves your problem!