mirror of
https://github.com/getgrav/grav.git
synced 2026-07-11 14:33:10 +02:00
Fixed exception when trying to find user account and there is no user://accounts folder
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
1. [](#improved)
|
||||
* Genericized `direct-install` so it can be called via Admin plugin
|
||||
1. [](#bugfix)
|
||||
* Fix a minor bug in Number validation [#1329](https://github.com/getgrav/grav/issues/1329)
|
||||
* Fixed a minor bug in Number validation [#1329](https://github.com/getgrav/grav/issues/1329)
|
||||
* Fixed exception when trying to find user account and there is no `user://accounts` folder
|
||||
|
||||
# v1.1.17
|
||||
## 02/17/2017
|
||||
|
||||
@@ -57,14 +57,14 @@ class User extends Data
|
||||
/**
|
||||
* Find a user by username, email, etc
|
||||
*
|
||||
* @param $query the query to search for
|
||||
* @param string $query the query to search for
|
||||
* @param array $fields the fields to search
|
||||
* @return User
|
||||
*/
|
||||
public static function find($query, $fields = ['username', 'email'])
|
||||
{
|
||||
$account_dir = Grav::instance()['locator']->findResource('account://');
|
||||
$files = array_diff(scandir($account_dir), ['.', '..']);
|
||||
$files = $account_dir ? array_diff(scandir($account_dir), ['.', '..']) : [];
|
||||
|
||||
// Try with username first, you never know!
|
||||
if (in_array('username', $fields)) {
|
||||
@@ -100,7 +100,7 @@ class User extends Data
|
||||
public static function remove($username)
|
||||
{
|
||||
$file_path = Grav::instance()['locator']->findResource('account://' . $username . YAML_EXT);
|
||||
if (file_exists($file_path) && unlink($file_path)) {
|
||||
if ($file_path && unlink($file_path)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user