1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-11 17:24:46 +02:00

Minor adjustments

This commit is contained in:
Ryan Cramer
2021-04-09 16:23:31 -04:00
parent 7918780af1
commit eb3dd355b0
3 changed files with 19 additions and 3 deletions

View File

@@ -111,7 +111,7 @@ function __($text, $textdomain = null, $context = '') {
$textArray = false;
$encode = $options['entityEncode'];
$user = wire('user');
$language = $user ? $user->language : null; /** @var Language $language */
$language = $user ? $user->get('language') : null; /** @var Language $language */
if(!is_string($text)) {
// getting/setting options or translating with multiple phrases accepted

View File

@@ -669,7 +669,7 @@ class WireArray extends Wire implements \IteratorAggregate, \ArrayAccess, \Count
if(ctype_digit("$key")) return null;
$item = null;
foreach($this->data as $wire) {
if(is_object($wire)) {
if(is_object($wire) && $wire instanceof Wire) {
if($wire->$key === $value) {
$item = $wire;
break;

View File

@@ -266,6 +266,19 @@ class WireLog extends Wire {
return $this->wire('config')->paths->logs . $name . '.' . $this->logExtension;
}
/**
* Does given log name exist?
*
* @param string $name
* @return bool
* @since 3.0.176
*
*/
public function exists($name) {
$filename = $this->getFilename($name);
return is_file($filename);
}
/**
* Return the given number of entries from the end of log file
*
@@ -447,8 +460,10 @@ class WireLog extends Wire {
*
*/
public function delete($name) {
if(!$this->exists($name)) return false;
$log = $this->getFileLog($name);
return $log->delete();
if($log) return $log->delete();
return false;
}
/**
@@ -463,6 +478,7 @@ class WireLog extends Wire {
*
*/
public function prune($name, $days) {
if(!$this->exists($name)) return false;
$log = $this->getFileLog($name);
if($days < 1) throw new WireException("Prune days must be 1 or more");
$oldestDate = strtotime("-$days DAYS");