Last active
April 2, 2021 15:32
-
-
Save niclashoyer/d54596d8c92a5816a2407da587532f2d to your computer and use it in GitHub Desktop.
Patch for bolt cms 3.7 for PHP 7.4 compatibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Patch for 7.4 compatibility | |
@package bolt/bolt | |
@level 1 | |
diff -uNBr bolt-orig/src/Controller/Frontend.php bolt/src/Controller/Frontend.php | |
--- bolt-orig/src/Controller/Frontend.php 2020-11-29 20:23:33.138756011 +0100 | |
+++ bolt/src/Controller/Frontend.php 2021-04-02 17:32:03.669398282 +0200 | |
@@ -541,18 +541,27 @@ | |
if ($isLegacy) { | |
$result = $this->storage()->searchContent($q, $contenttypes, $filters, $limit, $offset); | |
- /** @var \Bolt\Pager\PagerManager $manager */ | |
- $manager = $this->app['pager']; | |
- $manager | |
- ->createPager($context) | |
- ->setCount($result['no_of_results']) | |
- ->setTotalpages(ceil($result['no_of_results'] / $pageSize)) | |
- ->setCurrent($page) | |
- ->setShowingFrom($offset + 1) | |
- ->setShowingTo($offset + ($result ? count($result['results']) : 0)); | |
- ; | |
- | |
- $manager->setLink($this->generateUrl('search', ['q' => $q]) . '&page_search='); | |
+ if ($result == false) { | |
+ $result = [ | |
+ 'results' => [], | |
+ 'query' => [ | |
+ 'sanitized_q' => strip_tags($q), | |
+ ], | |
+ 'no_of_results' => 0 | |
+ ]; | |
+ } else { | |
+ /** @var \Bolt\Pager\PagerManager $manager */ | |
+ $manager = $this->app['pager']; | |
+ $manager | |
+ ->createPager($context) | |
+ ->setCount($result['no_of_results']) | |
+ ->setTotalpages(ceil($result['no_of_results'] / $pageSize)) | |
+ ->setCurrent($page) | |
+ ->setShowingFrom($offset + 1) | |
+ ->setShowingTo($offset + ($result ? count($result['results']) : 0)); | |
+ ; | |
+ $manager->setLink($this->generateUrl('search', ['q' => $q]) . '&page_search='); | |
+ } | |
} else { | |
$appCt = array_keys($this->app['query.search_config']->getSearchableTypes()); | |
$textQuery = '(' . join(',', $appCt) . ')/search'; | |
diff -uNBr bolt-orig/src/Legacy/Storage.php bolt/src/Legacy/Storage.php | |
--- bolt-orig/src/Legacy/Storage.php 2020-11-29 20:23:33.150756407 +0100 | |
+++ bolt/src/Legacy/Storage.php 2021-04-02 17:17:09.019652302 +0200 | |
@@ -1030,6 +1030,9 @@ | |
function ($name) use ($instance) { | |
$ct = $instance->getContentType($name); | |
+ if ($ct == false) { | |
+ return null; | |
+ } | |
return $ct['slug']; | |
}, | |
$contenttypes | |
@@ -1062,7 +1065,11 @@ | |
$decoded['return_single'] = true; | |
// if allow_numeric_slug option is set on contenttype, interpret number as slug instead of id | |
$contenttype = $this->getContentType($decoded['contenttypes'][0]); | |
- $field = ($contenttype['allow_numeric_slugs'] === true ? 'slug' : 'id'); | |
+ if ($contenttype == false) { | |
+ $field = 'id'; | |
+ } else { | |
+ $field = ($contenttype['allow_numeric_slugs'] === true ? 'slug' : 'id'); | |
+ } | |
$ctypeParameters[$field] = $match[2]; | |
} elseif (preg_match('#^/?([a-z0-9_(\),-]+)/search(/([0-9]+))?$#i', $textquery, $match)) { | |
// like 'page/search or '(entry,page)/search' | |
@@ -2711,6 +2718,9 @@ | |
$contenttype = $this->getContentType($contenttype); | |
} | |
+ if ($contenttype == false) { | |
+ return $this->getTablename(null); | |
+ } | |
return $this->getTablename($contenttype['tablename']); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment