aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2016-01-10 10:10:41 +0100
committerMarc Alexander <admin@m-a-styles.de>2016-01-15 11:21:08 +0100
commit3a555d94af24645142fe76ba1c691cc2ceb88374 (patch)
treeea867611e880a5d0e86a482c3de26e14056cdc2b
parent3a82ace3eb15ca1e0f4bfcfb2104cc15628ff1c3 (diff)
downloadforums-3a555d94af24645142fe76ba1c691cc2ceb88374.tar
forums-3a555d94af24645142fe76ba1c691cc2ceb88374.tar.gz
forums-3a555d94af24645142fe76ba1c691cc2ceb88374.tar.bz2
forums-3a555d94af24645142fe76ba1c691cc2ceb88374.tar.xz
forums-3a555d94af24645142fe76ba1c691cc2ceb88374.zip
[ticket/14402] Get rid of globals in tidy_plupload cron
PHPBB3-14402
-rw-r--r--phpBB/config/default/container/services_cron.yml2
-rw-r--r--phpBB/phpbb/cron/task/core/tidy_plupload.php20
2 files changed, 16 insertions, 6 deletions
diff --git a/phpBB/config/default/container/services_cron.yml b/phpBB/config/default/container/services_cron.yml
index eb7df540d7..dd3982a659 100644
--- a/phpBB/config/default/container/services_cron.yml
+++ b/phpBB/config/default/container/services_cron.yml
@@ -106,6 +106,8 @@ services:
arguments:
- '%core.root_path%'
- '@config'
+ - '@log'
+ - '@user'
calls:
- [set_name, [cron.task.core.tidy_plupload]]
tags:
diff --git a/phpBB/phpbb/cron/task/core/tidy_plupload.php b/phpBB/phpbb/cron/task/core/tidy_plupload.php
index 027804ae68..6630daa9c1 100644
--- a/phpBB/phpbb/cron/task/core/tidy_plupload.php
+++ b/phpBB/phpbb/cron/task/core/tidy_plupload.php
@@ -42,6 +42,12 @@ class tidy_plupload extends \phpbb\cron\task\base
*/
protected $config;
+ /** @var \phpbb\log\log_interface */
+ protected $log;
+
+ /** @var \phpbb\user */
+ protected $user;
+
/**
* Directory where plupload stores temporary files.
* @var string
@@ -53,11 +59,15 @@ class tidy_plupload extends \phpbb\cron\task\base
*
* @param string $phpbb_root_path The root path
* @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->config = $config;
+ $this->log = $log;
+ $this->user = $user;
$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()
{
- global $user, $phpbb_log;
-
// Remove old temporary file (perhaps failed uploads?)
$last_valid_timestamp = time() - $this->max_file_age;
try
@@ -90,9 +98,9 @@ class tidy_plupload extends \phpbb\cron\task\base
}
catch (\UnexpectedValueException $e)
{
- $user_id = (empty($user->data)) ? ANONYMOUS : $user->data['user_id'];
- $user_ip = (empty($user->ip)) ? '' : $user->ip;
- $phpbb_log->add('critical', $user_id, $user_ip, 'LOG_PLUPLOAD_TIDY_FAILED', false, array(
+ $user_id = (empty($this->user->data)) ? ANONYMOUS : $this->user->data['user_id'];
+ $user_ip = (empty($this->user->ip)) ? '' : $this->user->ip;
+ $this->log->add('critical', $user_id, $user_ip, 'LOG_PLUPLOAD_TIDY_FAILED', false, array(
$this->plupload_upload_path,
$e->getMessage(),
$e->getTraceAsString()