Skip to content

Commit

Permalink
Prevent exception being thrown when calling the Collator constructor …
Browse files Browse the repository at this point in the history
…failed in a Windows environment with the Intl PHP Extension enabled [#961]
  • Loading branch information
flaviocopes committed Jul 27, 2016
1 parent ab17fb2 commit 74f6890
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Fixed `Folder::delete` method to recursively remove files and folders and causing Upgrade to fail.
* Fix [#952](https://github.com/getgrav/grav/issues/952) hypenize the session name.
* If no parent is set and siblings collection is called, return a new and empty collection [grav-plugin-sitemap/issues/22](https://github.com/getgrav/grav-plugin-sitemap/issues/22)
* Prevent exception being thrown when calling the Collator constructor failed in a Windows environment with the Intl PHP Extension enabled [#961](https://github.com/getgrav/grav/issues/961)

# v1.1.1
## 07/16/2016
Expand Down
9 changes: 7 additions & 2 deletions system/src/Grav/Common/Page/Pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -1065,8 +1065,13 @@ protected function buildSort($path, array $pages, $order_by = 'default', $manual
} else {
// else just sort the list according to specified key
if (extension_loaded('intl')) {
$col = new \Collator(setlocale(LC_COLLATE, 0)); //`setlocale` with a 0 param returns the current locale set
$col->asort($list, $sort_flags);
$locale = setlocale(LC_COLLATE, 0); //`setlocale` with a 0 param returns the current locale set
$col = \Collator::create($locale);
if ($col) {
$col->asort($list, $sort_flags);
} else {
asort($list, $sort_flags);
}
} else {
asort($list, $sort_flags);
}
Expand Down

0 comments on commit 74f6890

Please sign in to comment.