mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-12 14:28:56 +00:00
Merge pull request #4116 from marc1706/ticket/14402
[ticket/14402] Tidy plupload cron should not rely on user id/ip being available * marc1706/ticket/14402: [ticket/14402] Directly pass user id and ip [ticket/14402] Get rid of globals in tidy_plupload cron [ticket/14402] Do not expect user id and ip to be available in cron
This commit is contained in:
commit
77d033f99e
2 changed files with 14 additions and 4 deletions
|
@ -106,6 +106,8 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- '%core.root_path%'
|
- '%core.root_path%'
|
||||||
- '@config'
|
- '@config'
|
||||||
|
- '@log'
|
||||||
|
- '@user'
|
||||||
calls:
|
calls:
|
||||||
- [set_name, [cron.task.core.tidy_plupload]]
|
- [set_name, [cron.task.core.tidy_plupload]]
|
||||||
tags:
|
tags:
|
||||||
|
|
|
@ -42,6 +42,12 @@ class tidy_plupload extends \phpbb\cron\task\base
|
||||||
*/
|
*/
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
|
/** @var \phpbb\log\log_interface */
|
||||||
|
protected $log;
|
||||||
|
|
||||||
|
/** @var \phpbb\user */
|
||||||
|
protected $user;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directory where plupload stores temporary files.
|
* Directory where plupload stores temporary files.
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -53,11 +59,15 @@ class tidy_plupload extends \phpbb\cron\task\base
|
||||||
*
|
*
|
||||||
* @param string $phpbb_root_path The root path
|
* @param string $phpbb_root_path The root path
|
||||||
* @param \phpbb\config\config $config The config
|
* @param \phpbb\config\config $config The config
|
||||||
|
* @param \phpbb\log\log_interface $log Log
|
||||||
|
* @param \phpbb\user $user User object
|
||||||
*/
|
*/
|
||||||
public function __construct($phpbb_root_path, \phpbb\config\config $config)
|
public function __construct($phpbb_root_path, \phpbb\config\config $config, \phpbb\log\log_interface $log, \phpbb\user $user)
|
||||||
{
|
{
|
||||||
$this->phpbb_root_path = $phpbb_root_path;
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
$this->log = $log;
|
||||||
|
$this->user = $user;
|
||||||
|
|
||||||
$this->plupload_upload_path = $this->phpbb_root_path . $this->config['upload_path'] . '/plupload';
|
$this->plupload_upload_path = $this->phpbb_root_path . $this->config['upload_path'] . '/plupload';
|
||||||
}
|
}
|
||||||
|
@ -67,8 +77,6 @@ class tidy_plupload extends \phpbb\cron\task\base
|
||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
global $user, $phpbb_log;
|
|
||||||
|
|
||||||
// Remove old temporary file (perhaps failed uploads?)
|
// Remove old temporary file (perhaps failed uploads?)
|
||||||
$last_valid_timestamp = time() - $this->max_file_age;
|
$last_valid_timestamp = time() - $this->max_file_age;
|
||||||
try
|
try
|
||||||
|
@ -90,7 +98,7 @@ class tidy_plupload extends \phpbb\cron\task\base
|
||||||
}
|
}
|
||||||
catch (\UnexpectedValueException $e)
|
catch (\UnexpectedValueException $e)
|
||||||
{
|
{
|
||||||
$phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_PLUPLOAD_TIDY_FAILED', false, array(
|
$this->log->add('critical', $this->user->data['user_id'], $this->user->ip, 'LOG_PLUPLOAD_TIDY_FAILED', false, array(
|
||||||
$this->plupload_upload_path,
|
$this->plupload_upload_path,
|
||||||
$e->getMessage(),
|
$e->getMessage(),
|
||||||
$e->getTraceAsString()
|
$e->getTraceAsString()
|
||||||
|
|
Loading…
Add table
Reference in a new issue