Skip to content

Commit

Permalink
Fixed few bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
neochief committed Oct 26, 2018
1 parent afb4758 commit e03e7b5
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/Builders/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ protected function reScan(Page $page)
$filepath = dirname($filename);
foreach ($this->scanners as $scanner_pair) {
foreach ($scanner_pair['paths'] as $path) {
if (strpos($filepath, rtrim($path, '/') . '/') !== false) {
if (mb_strpos($filepath, rtrim($path, '/') . '/') !== false) {
$scanner = $this->makeScanner($scanner_pair);
return $scanner->scanFile($filename, $path);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Builders/StaticCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function write($path, $content, $is_html = true) {

// Do not create file cache for very long filenames.
foreach (explode('/', $cache_path) as $part) {
if (strlen($part) >= 255) {
if (mb_strlen($part) >= 255) {
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function getContentTimestamp()
return response()->json([
'timestamp' => $date ? strtotime($date) : 0
], 200, [], JSON_NUMERIC_CHECK)
->header('Cache-Control', 'no-cache, private')
->header('Cache-Control', 'no-cache')
->header('Content-Type', 'application/json');
}
}
4 changes: 2 additions & 2 deletions src/Page/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static function extractLocale($uri, $localeInUrl = null)
{
$defaultLocale = config('app.default_locale', '');
$defaultLocaleIsInUrl = $localeInUrl === null ? config('jetpages.default_locale_in_url', false) : $localeInUrl;
$uri_has_parts = strpos($uri, '/') !== false;
$uri_has_parts = mb_strpos($uri, '/') !== false;

if ($uri_has_parts) {
list($locale, $path) = explode('/', $uri, 2);
Expand Down Expand Up @@ -192,7 +192,7 @@ static function extractLocale($uri, $localeInUrl = null)
*/
static function isValidLocale($string)
{
if (strlen($string) != 2) {
if (mb_strlen($string) != 2) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Page/PageRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function hasSearchIndex($columns);
* @param $columns
* @param $caseSensitive
*/
public function makeSearchIndex($columns, $caseSensitive = true);
public function makeSearchIndex($columns);

/**
* Find page in search index.
Expand Down
13 changes: 7 additions & 6 deletions src/Page/SimplePageRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ public function hasSearchIndex($columns) {
* @param $columns
* @param $caseSensitive
*/
public function makeSearchIndex($columns, $caseSensitive = true) {
public function makeSearchIndex($columns) {
$name = join('__', $columns);
foreach ($this->getAll() as $page) {
$key = $this->makeSearchIndexKey($columns, $page, $caseSensitive);
$key = $this->makeSearchIndexKey($columns, $page);
$this->searchIndexes[$name][$key] = $page;
}
}
Expand All @@ -281,11 +281,11 @@ public function makeSearchIndex($columns, $caseSensitive = true) {
* @param $caseSensitive
* @return string
*/
protected function makeSearchIndexKey($columns, Page $page, $caseSensitive = true) {
protected function makeSearchIndexKey($columns, Page $page) {
$parts = [];
foreach ($columns as $column) {
$part = $page->getAttribute($column);
$parts[] = $caseSensitive ? $part : strtolower($part);
$parts[] = mb_strtolower(trim($part));
}
return join('__', $parts);
}
Expand All @@ -297,8 +297,9 @@ protected function makeSearchIndexKey($columns, Page $page, $caseSensitive = tru
* @param $key
* @return Page|null
*/
public function findInSearchIndex($name, $key) {
return $this->searchIndexes[$name][$key] ?? $this->searchIndexes[$name][strtolower($key)] ?? null;
public function findInSearchIndex($name, $key, $caseSensitive = false) {
$key = mb_strtolower(trim($key));
return $this->searchIndexes[$name][$key] ?? null;
}

/**
Expand Down

0 comments on commit e03e7b5

Please sign in to comment.