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

substr_count(): Empty substring #25

Open
replayshot opened this issue Jan 21, 2020 · 2 comments
Open

substr_count(): Empty substring #25

replayshot opened this issue Jan 21, 2020 · 2 comments

Comments

@replayshot
Copy link

For majority of my pages, this plugin works like a charm, but I found this issue with one of the pages. It is online 239 of the php file. Any idea why this happens?

D:\wamp\www\preso\user\plugins\relatedpages\relatedpages.php
$cache->save($cache_id, $this->related_pages);
} else {
$debugger->addMessage("RelatedPages Plugin cache hit.");
}

}

/**
 * if enabled on this page, load the JS + CSS theme.
 */
public function onTwigSiteVariables()
{
    $this->grav['twig']->twig_vars['related_pages'] = $this->related_pages;
}

protected function substringCountArray($haystack, array $needle)
{
    $count = 0;
    foreach ((array)$needle as $substring) {
        **$count += substr_count(strtolower($haystack), strtolower($substring));**
    }
    return $count;
}

protected function mergeRelatedPages(array $pages)
{
    foreach ((array) $pages as $path => $score) {
        $page_exists = array_key_exists($path, $this->related_pages);
        if ($score > $this->config['score_threshold'] &&
            (!$page_exists || ($page_exists && $score > $this->related_pages[$path]))) {
            $this->related_pages[$path] = $score;
        }
    }
}

}

Arguments
"substr_count(): Empty substring"

@replayshot
Copy link
Author

Figured it out. There was an empty tag in the item.md file and that was causing the issue.

tag:
- tag1
- tag2
-
- tag3
- tag4

@mahagr
Copy link
Member

mahagr commented Jan 23, 2020

I think the plugin should work even with empty tags.

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

No branches or pull requests

2 participants