Skip to content
Snippets Groups Projects
Select Git revision
  • cafa95e68f1a4ef38c03ab04aec04534ede33d4f
  • 11.x default protected
  • 11.2.x protected
  • 10.5.x protected
  • 10.6.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 8.9.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
  • 11.1.7 protected
  • 10.4.6 protected
  • 11.1.6 protected
  • 10.3.14 protected
  • 10.4.5 protected
  • 11.0.13 protected
41 results

FileStorage.php

  • Alex Pott's avatar
    Issue #2278025 by duellj | alexpott: Fixed Remove retrieveTemporaryFiles().
    Alex Pott authored
    cafa95e6
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    FileStorage.php 1.60 KiB
    <?php
    
    /**
     * @file
     * Definition of Drupal\file\FileStorage.
     */
    
    namespace Drupal\file;
    
    use Drupal\Core\Entity\ContentEntityDatabaseStorage;
    
    /**
     * File storage for files.
     */
    class FileStorage extends ContentEntityDatabaseStorage implements FileStorageInterface {
    
      /**
       * {@inheritdoc}
       */
      public function spaceUsed($uid = NULL, $status = FILE_STATUS_PERMANENT) {
        $query = $this->database->select($this->entityType->getBaseTable(), 'f')
          ->condition('f.status', $status);
        $query->addExpression('SUM(f.filesize)', 'filesize');
        if (isset($uid)) {
          $query->condition('f.uid', $uid);
        }
        return $query->execute()->fetchField();
      }
    
      /**
       * {@inheritdoc}
       */
      public function getSchema() {
        $schema = parent::getSchema();
    
        // Marking the respective fields as NOT NULL makes the indexes more
        // performant.
        $schema['file_managed']['fields']['status']['not null'] = TRUE;
        $schema['file_managed']['fields']['changed']['not null'] = TRUE;
        $schema['file_managed']['fields']['uri']['not null'] = TRUE;
    
        // @todo There should be a 'binary' field type or setting.
        $schema['file_managed']['fields']['uri']['binary'] = TRUE;
        $schema['file_managed']['indexes'] += array(
          'file__status' => array('status'),
          'file__changed' => array('changed'),
        );
        $schema['file_managed']['unique keys'] += array(
          // FIXME We have an index size of 255, but the max URI length is 2048 so
          // this might now always work. Should we replace this with a regular
          // index?
          'file__uri' => array(array('uri', 255)),
        );
    
        return $schema;
      }
    
    }