Force a guest user in BackgroundQueueHandler::performJob()
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 6 Jan 2016 16:26:27 +0000 (17:26 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 6 Jan 2016 16:26:27 +0000 (17:26 +0100)
wcfsetup/install/files/lib/system/background/BackgroundQueueHandler.class.php

index ff22fe0ea756ce2d2e36f287d361bb4ddeab4d80..dedd7dd6563a1ebcfc5c27cce9bc19de58c824ca 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace wcf\system\background;
+use wcf\data\user\User;
 use wcf\system\background\job\AbstractBackgroundJob;
 use wcf\system\exception\LoggedException;
 use wcf\system\exception\SystemException;
@@ -85,7 +86,10 @@ class BackgroundQueueHandler extends SingletonFactory {
         * @param       \wcf\system\background\job\AbstractBackgroundJob        $job    The job to perform.
         */
        public function performJob(AbstractBackgroundJob $job) {
+               $user = WCF::getUser();
+               
                try {
+                       SessionHandler::getInstance()->changeUser(new User(null), true);
                        $job->perform();
                }
                catch (\Exception $e) {
@@ -100,6 +104,9 @@ class BackgroundQueueHandler extends SingletonFactory {
                                if ($e instanceof LoggedException) $e->getExceptionID();
                        }
                }
+               finally {
+                       SessionHandler::getInstance()->changeUser($user, true);
+               }
        }
        
        /**