/**
  * Gets the TYPO3 Locker object or creates an instance of it.
  *
  * @throws \RuntimeException
  * @return \TYPO3\CMS\Core\Locking\Locker|NULL Only NULL if we are in installer and typo3temp does not exist yet
  */
 protected function getLocker()
 {
     if (NULL === $this->lockObject) {
         $this->isLoadingLocker = TRUE;
         try {
             $this->lockObject = new Locker('ClassLoader-cache-classes', Locker::LOCKING_METHOD_SIMPLE);
         } catch (\RuntimeException $e) {
             // The RuntimeException in constructor happens if directory typo3temp/locks could not be created.
             // This usually happens during installation step 1 where typo3temp itself does not exist yet. In
             // this case we proceed without locking, otherwise a missing typo3temp directory indicates a
             // hard problem of the instance and we throw up.
             // @TODO: This solution currently conflicts with separation of concerns since the class loader
             // handles installation specific stuff. Find a better way to do this.
             if (defined('TYPO3_enterInstallScript') && TYPO3_enterInstallScript) {
                 // Installer is running => So work without Locking.
                 return NULL;
             } else {
                 throw $e;
             }
         }
         $this->lockObject->setEnableLogging(FALSE);
         $this->isLoadingLocker = FALSE;
     }
     return $this->lockObject;
 }
 /**
  * Does some processing BEFORE the pagegen script is included.
  *
  * @return void
  * @todo Define visibility
  */
 public function generatePage_preProcessing()
 {
     // Same codeline as in getFromCache(). But $this->all has been changed by t3lib_TStemplate::start() in the meantime, so this must be called again!
     $this->newHash = $this->getHash();
     // For cache management informational purposes.
     $this->config['hash_base'] = $this->hash_base;
     if (!is_object($this->pages_lockObj) || $this->pages_lockObj->getLockStatus() == FALSE) {
         // Here we put some temporary stuff in the cache in order to let the first hit generate the page. The temporary cache will expire after a few seconds (typ. 30) or will be cleared by the rendered page, which will also clear and rewrite the cache.
         $this->tempPageCacheContent();
     }
     // Setting cache_timeout_default. May be overridden by PHP include scritps.
     $this->cacheTimeOutDefault = intval($this->config['config']['cache_period']);
     // Page is generated
     $this->no_cacheBeforePageGen = $this->no_cache;
 }
Esempio n. 3
0
 /**
  * @test
  * @dataProvider invalidFileReferences
  */
 public function releaseDoesNotRemoveFilesNotWithinTypo3TempLocksDirectory($lockMethod, $file)
 {
     if (TYPO3_OS === 'WIN') {
         $this->markTestSkipped('releaseDoesNotRemoveFilesNotWithinTypo3TempLocksDirectory() test not available on Windows.');
     }
     // Create test file
     touch($file);
     if (!is_file($file)) {
         $this->markTestSkipped('releaseDoesNotRemoveFilesNotWithinTypo3TempLocksDirectory() skipped: Test file could not be created');
     }
     // Create instance, set lockfile to invalid path
     $instance = new Locker(999999999, $lockMethod);
     $instance->setEnableLogging(false);
     $t3libLockReflection = new \ReflectionClass(\TYPO3\CMS\Core\Locking\Locker::class);
     $t3libLockReflectionResourceProperty = $t3libLockReflection->getProperty('resource');
     $t3libLockReflectionResourceProperty->setAccessible(true);
     $t3libLockReflectionResourceProperty->setValue($instance, $file);
     $t3libLockReflectionAcquiredProperty = $t3libLockReflection->getProperty('isAcquired');
     $t3libLockReflectionAcquiredProperty->setAccessible(true);
     $t3libLockReflectionAcquiredProperty->setValue($instance, true);
     // Call release method
     $instance->release();
     // Check if file is still there and clean up
     $fileExists = is_file($file);
     if (is_file($file)) {
         unlink($file);
     }
     $this->assertTrue($fileExists);
 }