diff --git a/core/config/schema/core.data_types.schema.yml b/core/config/schema/core.data_types.schema.yml index cc89fa9..04ccc80 100644 --- a/core/config/schema/core.data_types.schema.yml +++ b/core/config/schema/core.data_types.schema.yml @@ -438,20 +438,23 @@ field.value.*: field.storage_settings.string: type: mapping label: 'String settings' mapping: max_length: type: integer label: 'Maximum length' case_sensitive: type: boolean label: 'Case sensitive' + is_alphanumeric: + type: boolean + label: 'US ASCII characters only' field.field_settings.string: type: mapping label: 'String settings' field.value.string: type: mapping label: 'Default value' mapping: value: diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index b1144e4..ba35597 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -436,20 +436,21 @@ protected function normalizeCid($cid) { * Defines the schema for the {cache_*} bin tables. */ public function schemaDefinition() { $schema = array( 'description' => 'Storage for the cache API.', 'fields' => array( 'cid' => array( 'description' => 'Primary Key: Unique cache ID.', 'type' => 'varchar', 'length' => 255, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '', 'binary' => TRUE, ), 'data' => array( 'description' => 'A collection of data to cache.', 'type' => 'blob', 'not null' => FALSE, 'size' => 'big', ), @@ -476,20 +477,21 @@ public function schemaDefinition() { ), 'tags' => array( 'description' => 'Space-separated list of cache tags for this entry.', 'type' => 'text', 'size' => 'big', 'not null' => FALSE, ), 'checksum' => array( 'description' => 'The tag invalidation checksum when this entry was saved.', 'type' => 'varchar', + 'is_alphanumeric' => TRUE, 'length' => 255, 'not null' => TRUE, ), ), 'indexes' => array( 'expire' => array('expire'), ), 'primary key' => array('cid'), ); return $schema; diff --git a/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php b/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php index cc882ee..27663e2 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php +++ b/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php @@ -170,20 +170,21 @@ protected function ensureTableExists() { * Defines the schema for the {cachetags} table. */ public function schemaDefinition() { $schema = array( 'description' => 'Cache table for tracking cache tag invalidations.', 'fields' => array( 'tag' => array( 'description' => 'Namespace-prefixed tag string.', 'type' => 'varchar', 'length' => 255, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '', ), 'invalidations' => array( 'description' => 'Number incremented when the tag is invalidated.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, ), ), diff --git a/core/lib/Drupal/Core/Config/DatabaseStorage.php b/core/lib/Drupal/Core/Config/DatabaseStorage.php index 6c33273..5cd05ff 100644 --- a/core/lib/Drupal/Core/Config/DatabaseStorage.php +++ b/core/lib/Drupal/Core/Config/DatabaseStorage.php @@ -187,27 +187,29 @@ protected function ensureTableExists() { * Defines the schema for the configuration table. */ protected static function schemaDefinition() { $schema = array( 'description' => 'The base table for configuration data.', 'fields' => array( 'collection' => array( 'description' => 'Primary Key: Config object collection.', 'type' => 'varchar', 'length' => 255, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '', ), 'name' => array( 'description' => 'Primary Key: Config object name.', 'type' => 'varchar', 'length' => 255, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '', ), 'data' => array( 'description' => 'A serialized configuration object data.', 'type' => 'blob', 'not null' => FALSE, 'size' => 'big', ), ), diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php index d0aba49..75645c7 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php @@ -137,20 +137,23 @@ protected function createTableSql($name, $table) { protected function createFieldSql($name, $spec) { $sql = "`" . $name . "` " . $spec['mysql_type']; if (in_array($spec['mysql_type'], array('VARCHAR', 'CHAR', 'TINYTEXT', 'MEDIUMTEXT', 'LONGTEXT', 'TEXT'))) { if (isset($spec['length'])) { $sql .= '(' . $spec['length'] . ')'; } if (!empty($spec['binary'])) { $sql .= ' BINARY'; } + if (!empty($spec['is_alphanumeric'])) { + $sql .= ' CHARACTER SET ascii COLLATE ascii_general_ci'; + } } elseif (isset($spec['precision']) && isset($spec['scale'])) { $sql .= '(' . $spec['precision'] . ', ' . $spec['scale'] . ')'; } if (!empty($spec['unsigned'])) { $sql .= ' unsigned'; } if (isset($spec['not null'])) { diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php index 9ab60a4..b5d9f49 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php @@ -37,20 +37,21 @@ * https://www.drupal.org/node/2329937 is completed. */ class LanguageItem extends FieldItemBase { /** * {@inheritdoc} */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { $properties['value'] = DataDefinition::create('string') ->setLabel(t('Language code')) + ->setSetting('is_alphanumeric', TRUE) ->setRequired(TRUE); $properties['language'] = DataReferenceDefinition::create('language') ->setLabel(t('Language object')) ->setDescription(t('The referenced language')) // The language object is retrieved via the language code. ->setComputed(TRUE) ->setReadOnly(FALSE); return $properties; diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php index 8817c87..d05a91b 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php @@ -25,33 +25,35 @@ * ) */ class StringItem extends StringItemBase { /** * {@inheritdoc} */ public static function defaultStorageSettings() { return array( 'max_length' => 255, + 'is_alphanumeric' => FALSE, ) + parent::defaultStorageSettings(); } /** * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { return array( 'columns' => array( 'value' => array( 'type' => 'varchar', 'length' => (int) $field_definition->getSetting('max_length'), 'binary' => $field_definition->getSetting('case_sensitive'), + 'is_alphanumeric' => $field_definition->getSetting('is_alphanumeric'), ), ), ); } /** * {@inheritdoc} */ public function getConstraints() { $constraints = parent::getConstraints(); diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php index 84d1ec5..cba8f1f 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php @@ -23,20 +23,21 @@ * ) */ class UuidItem extends StringItem { /** * {@inheritdoc} */ public static function defaultStorageSettings() { return array( 'max_length' => 128, + 'is_alphanumeric' => TRUE, ) + parent::defaultStorageSettings(); } /** * {@inheritdoc} */ public function applyDefaultValue($notify = TRUE) { // Default to one field item with a generated UUID. $uuid = \Drupal::service('uuid'); $this->setValue(array('value' => $uuid->generate()), $notify); diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php index 2ce68f7..aa3a7a5 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php @@ -1188,45 +1188,49 @@ protected function definitionFields() { * The schema API definition for the SQL storage table. */ protected static function schemaDefinition() { $schema = array( 'description' => 'Contains the menu tree hierarchy.', 'fields' => array( 'menu_name' => array( 'description' => "The menu name. All links with the same menu name (such as 'tools') are part of the same menu.", 'type' => 'varchar', 'length' => 32, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '', ), 'mlid' => array( 'description' => 'The menu link ID (mlid) is the integer primary key.', 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, ), 'id' => array( 'description' => 'Unique machine name: the plugin ID.', 'type' => 'varchar', 'length' => 255, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, ), 'parent' => array( 'description' => 'The plugin ID for the parent of this link.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, + 'is_alphanumeric' => TRUE, 'default' => '', ), 'route_name' => array( 'description' => 'The machine name of a defined Symfony Route this menu item represents.', 'type' => 'varchar', + 'is_alphanumeric' => TRUE, 'length' => 255, ), 'route_param_key' => array( 'description' => 'An encoded string of route parameters for loading by route.', 'type' => 'varchar', 'length' => 255, ), 'route_parameters' => array( 'description' => 'Serialized array of route parameters of this menu link.', 'type' => 'blob', @@ -1276,20 +1280,21 @@ protected static function schemaDefinition() { 'description' => 'A serialized array of URL options, such as a query string or HTML attributes.', 'type' => 'blob', 'size' => 'big', 'not null' => FALSE, 'serialize' => TRUE, ), 'provider' => array( 'description' => 'The name of the module that generated this link.', 'type' => 'varchar', 'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => 'system', ), 'enabled' => array( 'description' => 'A flag for whether the link should be rendered in menus. (0 = a disabled menu item that may be shown on admin screens, 1 = a normal, visible link)', 'type' => 'int', 'not null' => TRUE, 'default' => 1, 'size' => 'small', ), diff --git a/core/modules/aggregator/src/Entity/Feed.php b/core/modules/aggregator/src/Entity/Feed.php index 6f3d2e2..5d2bafe 100644 --- a/core/modules/aggregator/src/Entity/Feed.php +++ b/core/modules/aggregator/src/Entity/Feed.php @@ -219,20 +219,21 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['description'] = BaseFieldDefinition::create('string_long') ->setLabel(t('Description')) ->setDescription(t("The parent website's description that comes from the !description element in the feed.", array('!description' => ''))); $fields['image'] = BaseFieldDefinition::create('uri') ->setLabel(t('Image')) ->setDescription(t('An image representing the feed.')); $fields['hash'] = BaseFieldDefinition::create('string') ->setLabel(t('Hash')) + ->setSetting('is_alphanumeric', TRUE) ->setDescription(t('Calculated hash of the feed data, used for validating cache.')); $fields['etag'] = BaseFieldDefinition::create('string') ->setLabel(t('Etag')) ->setDescription(t('Entity tag HTTP response header, used for validating cache.')); // This is updated by the fetcher and not when the feed is saved, therefore // it's a timestamp and not a changed field. $fields['modified'] = BaseFieldDefinition::create('timestamp') ->setLabel(t('Modified')) diff --git a/core/modules/aggregator/src/FeedInterface.php b/core/modules/aggregator/src/FeedInterface.php index 29c6782..738a3dc 100644 --- a/core/modules/aggregator/src/FeedInterface.php +++ b/core/modules/aggregator/src/FeedInterface.php @@ -163,21 +163,22 @@ public function setImage($image); * * @return string * The calculated hash of the feed data. */ public function getHash(); /** * Sets the calculated hash of the feed data, used for validating cache. * * @param string $hash - * A string containing the calculated hash of the feed. + * A string containing the calculated hash of the feed. Must be base64 + * encoded so it contains US ASCII characters only. * * @return \Drupal\aggregator\FeedInterface * The class instance that this method is called on. */ public function setHash($hash); /** * Returns the entity tag HTTP response header, used for validating cache. * * @return string diff --git a/core/modules/aggregator/src/ItemsImporter.php b/core/modules/aggregator/src/ItemsImporter.php index 3098f08..1c1aaa2 100644 --- a/core/modules/aggregator/src/ItemsImporter.php +++ b/core/modules/aggregator/src/ItemsImporter.php @@ -2,20 +2,21 @@ /** * @file * Contains \Drupal\aggregator\Entity\ItemsImporter. */ namespace Drupal\aggregator; use Drupal\aggregator\Plugin\AggregatorPluginManager; use Drupal\Component\Plugin\Exception\PluginException; +use Drupal\Component\Utility\Crypt; use Drupal\Core\Config\ConfigFactoryInterface; use Psr\Log\LoggerInterface; /** * Defines an importer of aggregator items. */ class ItemsImporter implements ItemsImporterInterface { /** * The aggregator fetcher manager. @@ -106,21 +107,21 @@ public function refresh(FeedInterface $feed) { $processor_instances[$processor] = $this->processorManager->createInstance($processor); } catch (PluginException $e) { watchdog_exception('aggregator', $e); } } // We store the hash of feed data in the database. When refreshing a // feed we compare stored hash and new hash calculated from downloaded // data. If both are equal we say that feed is not updated. - $hash = hash('sha256', $feed->source_string); + $hash = Crypt::hashBase64('sha256', $feed->source_string); $has_new_content = $success && ($feed->getHash() != $hash); if ($has_new_content) { // Parse the feed. try { if ($this->parserManager->createInstance($this->config->get('parser'))->parse($feed)) { if (!$feed->getWebsiteUrl()) { $feed->setWebsiteUrl($feed->getUrl()); } $feed->setHash($hash); diff --git a/core/modules/ban/ban.install b/core/modules/ban/ban.install index 7a5494f..8ccf574 100644 --- a/core/modules/ban/ban.install +++ b/core/modules/ban/ban.install @@ -15,20 +15,21 @@ function ban_schema() { 'iid' => array( 'description' => 'Primary Key: unique ID for IP addresses.', 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, ), 'ip' => array( 'description' => 'IP address', 'type' => 'varchar', 'length' => 40, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '', ), ), 'indexes' => array( 'ip' => array('ip'), ), 'primary key' => array('iid'), ); return $schema; diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index 64aa6bd..94a59a4 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -43,27 +43,29 @@ function comment_schema() { 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The entity_id of the entity for which the statistics are compiled.', ), 'entity_type' => array( 'type' => 'varchar', 'not null' => TRUE, 'default' => 'node', 'length' => EntityTypeInterface::ID_MAX_LENGTH, + 'is_alphanumeric' => TRUE, 'description' => 'The entity_type of the entity to which this comment is a reply.', ), 'field_name' => array( 'type' => 'varchar', 'not null' => TRUE, 'default' => '', 'length' => FieldStorageConfig::NAME_MAX_LENGTH, + 'is_alphanumeric' => TRUE, 'description' => 'The field_name of the field that was used to add this comment.', ), 'cid' => array( 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'The {comment}.cid of the last comment.', ), 'last_comment_timestamp' => array( 'type' => 'int', diff --git a/core/modules/dblog/dblog.install b/core/modules/dblog/dblog.install index b7454c1..18f8532 100644 --- a/core/modules/dblog/dblog.install +++ b/core/modules/dblog/dblog.install @@ -22,20 +22,21 @@ function dblog_schema() { 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The {users}.uid of the user who triggered the event.', ), 'type' => array( 'type' => 'varchar', 'length' => 64, 'not null' => TRUE, 'default' => '', + 'is_alphanumeric' => TRUE, 'description' => 'Type of log message, for example "user" or "page not found."', ), 'message' => array( 'type' => 'text', 'not null' => TRUE, 'size' => 'big', 'description' => 'Text of log message to be passed into the t() function.', ), 'variables' => array( 'type' => 'blob', @@ -66,20 +67,21 @@ function dblog_schema() { 'referer' => array( 'type' => 'text', 'not null' => FALSE, 'description' => 'URL of referring page.', ), 'hostname' => array( 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '', + 'is_alphanumeric' => TRUE, 'description' => 'Hostname of the user who triggered the event.', ), 'timestamp' => array( 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'Unix timestamp of when event occurred.', ), ), 'primary key' => array('wid'), diff --git a/core/modules/file/file.install b/core/modules/file/file.install index 6e188c6..5a8a54e 100644 --- a/core/modules/file/file.install +++ b/core/modules/file/file.install @@ -15,33 +15,36 @@ function file_schema() { 'fid' => array( 'description' => 'File ID.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, ), 'module' => array( 'description' => 'The name of the module that is using the file.', 'type' => 'varchar', 'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '', ), 'type' => array( 'description' => 'The name of the object type in which the file is used.', 'type' => 'varchar', 'length' => 64, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '', ), 'id' => array( 'description' => 'The primary key of the object using the file.', 'type' => 'varchar', + 'is_alphanumeric' => TRUE, 'length' => 64, 'not null' => TRUE, 'default' => 0, ), 'count' => array( 'description' => 'The number of times this file is used by this object.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, diff --git a/core/modules/file/src/Entity/File.php b/core/modules/file/src/Entity/File.php index 42de0ae..2156142 100644 --- a/core/modules/file/src/Entity/File.php +++ b/core/modules/file/src/Entity/File.php @@ -247,20 +247,21 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDescription(t('Name of the file with no path components.')); $fields['uri'] = BaseFieldDefinition::create('uri') ->setLabel(t('URI')) ->setDescription(t('The URI to access the file (either local or remote).')) ->setSetting('max_length', 255) ->setSetting('case_sensitive', TRUE); $fields['filemime'] = BaseFieldDefinition::create('string') ->setLabel(t('File MIME type')) + ->setSetting('is_alphanumeric', TRUE) ->setDescription(t("The file's MIME type.")); $fields['filesize'] = BaseFieldDefinition::create('integer') ->setLabel(t('File size')) ->setDescription(t('The size of the file in bytes.')) ->setSetting('unsigned', TRUE) ->setSetting('size', 'big'); $fields['status'] = BaseFieldDefinition::create('boolean') ->setLabel(t('Status')) diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install index 81aadf5..fea0571 100644 --- a/core/modules/locale/locale.install +++ b/core/modules/locale/locale.install @@ -62,27 +62,29 @@ function locale_schema() { ), 'source' => array( 'type' => 'text', 'mysql_type' => 'blob', 'not null' => TRUE, 'description' => 'The original string in English.', ), 'context' => array( 'type' => 'varchar', 'length' => 255, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '', 'description' => 'The context this string applies to.', ), 'version' => array( 'type' => 'varchar', 'length' => 20, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => 'none', 'description' => 'Version of Drupal where the string was last used (for locales optimization).', ), ), 'primary key' => array('lid'), 'indexes' => array( 'source_context' => array(array('source', 30), 'context'), ), ); @@ -98,20 +100,21 @@ function locale_schema() { ), 'translation' => array( 'type' => 'text', 'mysql_type' => 'blob', 'not null' => TRUE, 'description' => 'Translation string value in this language.', ), 'language' => array( 'type' => 'varchar', 'length' => 12, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '', 'description' => 'Language code. References {language}.langcode.', ), 'customized' => array( 'type' => 'int', 'not null' => TRUE, 'default' => 0, // LOCALE_NOT_CUSTOMIZED 'description' => 'Boolean indicating whether the translation is custom to this site.', ), @@ -137,34 +140,36 @@ function locale_schema() { 'description' => 'Unique identifier of this location.', ), 'sid' => array( 'type' => 'int', 'not null' => TRUE, 'description' => 'Unique identifier of this string.', ), 'type' => array( 'type' => 'varchar', 'length' => 50, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '', 'description' => 'The location type (file, config, path, etc).', ), 'name' => array( 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', 'description' => 'Type dependent location information (file name, path, etc).', ), 'version' => array( 'type' => 'varchar', 'length' => 20, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => 'none', 'description' => 'Version of Drupal where the location was found.', ), ), 'primary key' => array('lid'), 'foreign keys' => array( 'locales_source' => array( 'table' => 'locales_source', 'columns' => array('sid' => 'lid'), diff --git a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php index 5570a2a..ea9adf0 100644 --- a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php +++ b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php @@ -243,20 +243,21 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['uuid'] = BaseFieldDefinition::create('uuid') ->setLabel(t('UUID')) ->setDescription(t('The content menu link UUID.')) ->setReadOnly(TRUE); $fields['bundle'] = BaseFieldDefinition::create('string') ->setLabel(t('Bundle')) ->setDescription(t('The content menu link bundle.')) ->setSetting('max_length', EntityTypeInterface::BUNDLE_MAX_LENGTH) + ->setSetting('is_alphanumeric', TRUE) ->setReadOnly(TRUE); $fields['title'] = BaseFieldDefinition::create('string') ->setLabel(t('Menu link title')) ->setDescription(t('The text to be used for this link in the menu.')) ->setRequired(TRUE) ->setTranslatable(TRUE) ->setSettings(array( 'max_length' => 255, )) @@ -284,21 +285,22 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { 'weight' => 0, )) ->setDisplayOptions('form', array( 'type' => 'string_textfield', 'weight' => 0, )); $fields['menu_name'] = BaseFieldDefinition::create('string') ->setLabel(t('Menu name')) ->setDescription(t('The menu name. All links with the same menu name (such as "tools") are part of the same menu.')) - ->setDefaultValue('tools'); + ->setDefaultValue('tools') + ->setSetting('is_alphanumeric', TRUE); $fields['link'] = BaseFieldDefinition::create('link') ->setLabel(t('Link')) ->setDescription(t('The location this menu link points to.')) ->setRequired(TRUE) ->setSettings(array( 'link_type' => LinkItemInterface::LINK_GENERIC, 'title' => DRUPAL_DISABLED, )) ->setDisplayOptions('form', array( diff --git a/core/modules/node/node.install b/core/modules/node/node.install index fa0d245..b91b6f6 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -49,20 +49,21 @@ function node_schema() { 'description' => 'The {node}.nid this record affects.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), 'langcode' => array( 'description' => 'The {language}.langcode of this node.', 'type' => 'varchar', 'length' => 12, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '', ), 'fallback' => array( 'description' => 'Boolean indicating whether this record should be used as a fallback if a language condition is not provided.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 1, ), diff --git a/core/modules/search/search.install b/core/modules/search/search.install index a298f2f..e09e8f5 100644 --- a/core/modules/search/search.install +++ b/core/modules/search/search.install @@ -15,27 +15,29 @@ function search_schema() { 'sid' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'Search item ID, e.g. node ID for nodes.', ), 'langcode' => array( 'type' => 'varchar', 'length' => '12', + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'description' => 'The {languages}.langcode of the item variant.', 'default' => '', ), 'type' => array( 'type' => 'varchar', 'length' => 64, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'description' => 'Type of item, e.g. node.', ), 'data' => array( 'type' => 'text', 'not null' => TRUE, 'size' => 'big', 'description' => 'List of space-separated words from the item.', ), 'reindex' => array( @@ -62,27 +64,29 @@ function search_schema() { 'sid' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The {search_dataset}.sid of the searchable item to which the word belongs.', ), 'langcode' => array( 'type' => 'varchar', 'length' => '12', + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'description' => 'The {languages}.langcode of the item variant.', 'default' => '', ), 'type' => array( 'type' => 'varchar', 'length' => 64, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'description' => 'The {search_dataset}.type of the searchable item to which the word belongs.', ), 'score' => array( 'type' => 'float', 'not null' => FALSE, 'description' => 'The numeric score of the word, higher being more important.', ), ), 'indexes' => array( diff --git a/core/modules/shortcut/shortcut.install b/core/modules/shortcut/shortcut.install index c1a6883..769f2eb 100644 --- a/core/modules/shortcut/shortcut.install +++ b/core/modules/shortcut/shortcut.install @@ -17,20 +17,21 @@ function shortcut_schema() { 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The {users}.uid for this set.', ), 'set_name' => array( 'type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => '', + 'is_alphanumeric' => TRUE, 'description' => "The {shortcut_set}.set_name that will be displayed for this user.", ), ), 'primary key' => array('uid'), 'indexes' => array( 'set_name' => array('set_name'), ), 'foreign keys' => array( 'set_user' => array( 'table' => 'users', diff --git a/core/modules/simpletest/simpletest.install b/core/modules/simpletest/simpletest.install index 47c0ee2..12bb0a5 100644 --- a/core/modules/simpletest/simpletest.install +++ b/core/modules/simpletest/simpletest.install @@ -123,20 +123,21 @@ function simpletest_schema() { ), 'message' => array( 'type' => 'text', 'not null' => TRUE, 'description' => 'The message itself.', ), 'message_group' => array( 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, + 'is_alphanumeric' => TRUE, 'default' => '', 'description' => 'The message group this message belongs to. For example: warning, browser, user.', ), 'function' => array( 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', 'description' => 'Name of the assertion function or method that created this message.', ), diff --git a/core/modules/system/src/Tests/Database/SchemaTest.php b/core/modules/system/src/Tests/Database/SchemaTest.php index a59b9d9..46997c8 100644 --- a/core/modules/system/src/Tests/Database/SchemaTest.php +++ b/core/modules/system/src/Tests/Database/SchemaTest.php @@ -42,33 +42,50 @@ function testSchema() { 'not null' => TRUE, 'description' => 'Schema table description may contain "quotes" and could be long—very long indeed. There could be "multiple quoted regions".', ), 'test_field_string' => array( 'type' => 'varchar', 'length' => 20, 'not null' => TRUE, 'default' => "'\"funky default'\"", 'description' => 'Schema column description for string.', ), + 'test_field_string_is_alphanumeric' => array( + 'type' => 'varchar', + 'length' => 255, + 'is_alphanumeric' => TRUE, + 'description' => 'Schema column description for is_alphanumeric string.', + ), ), ); db_create_table('test_table', $table_specification); // Assert that the table exists. $this->assertTrue(db_table_exists('test_table'), 'The table exists.'); // Assert that the table comment has been set. $this->checkSchemaComment($table_specification['description'], 'test_table'); // Assert that the column comment has been set. $this->checkSchemaComment($table_specification['fields']['test_field']['description'], 'test_table', 'test_field'); + // Make sure that varchard fields have the correct collation. + $columns = db_query('SHOW FULL COLUMNS FROM {test_table}'); + foreach ($columns as $column) { + if ($column->Field == 'test_field_string') { + $this->assertTrue($column->Collation == 'utf8_general_ci'); + } + if ($column->Field == 'test_field_string_is_alphanumeric') { + $this->assertTrue($column->Collation == 'ascii_general_ci'); + } + } + // An insert without a value for the column 'test_table' should fail. $this->assertFalse($this->tryInsert(), 'Insert without a default failed.'); // Add a default value to the column. db_field_set_default('test_table', 'test_field', 0); // The insert should now succeed. $this->assertTrue($this->tryInsert(), 'Insert with a default succeeded.'); // Remove the default. db_field_set_no_default('test_table', 'test_field'); diff --git a/core/modules/system/system.install b/core/modules/system/system.install index f1e6612..d4a3d35 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -680,20 +680,21 @@ function system_schema() { // This is not a serial column, to allow both progressive and // non-progressive batches. See batch_process(). 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, ), 'token' => array( 'description' => "A string token generated against the current user's session id and the batch id, used to ensure that only the user who submitted the batch can effectively access it.", 'type' => 'varchar', 'length' => 64, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, ), 'timestamp' => array( 'description' => 'A Unix timestamp indicating when this batch was submitted for processing. Stale batches are purged at cron time.', 'type' => 'int', 'not null' => TRUE, ), 'batch' => array( 'description' => 'A serialized array containing the processing data for the batch.', 'type' => 'blob', @@ -712,27 +713,29 @@ function system_schema() { 'fields' => array( 'fid' => array( 'description' => 'Unique flood event ID.', 'type' => 'serial', 'not null' => TRUE, ), 'event' => array( 'description' => 'Name of event (e.g. contact).', 'type' => 'varchar', 'length' => 64, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '', ), 'identifier' => array( 'description' => 'Identifier of the visitor, such as an IP address or hostname.', 'type' => 'varchar', 'length' => 128, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '', ), 'timestamp' => array( 'description' => 'Timestamp of the event.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, ), 'expiration' => array( @@ -820,20 +823,21 @@ function system_schema() { 'item_id' => array( 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'Primary Key: Unique item ID.', ), 'name' => array( 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, + 'is_alphanumeric' => TRUE, 'default' => '', 'description' => 'The queue name.', ), 'data' => array( 'type' => 'blob', 'not null' => FALSE, 'size' => 'big', 'serialize' => TRUE, 'description' => 'The arbitrary data for the item.', ), @@ -857,20 +861,21 @@ function system_schema() { ), ); $schema['router'] = array( 'description' => 'Maps paths to various callbacks (access, page and title)', 'fields' => array( 'name' => array( 'description' => 'Primary Key: Machine name of this route', 'type' => 'varchar', 'length' => 255, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '', ), 'path' => array( 'description' => 'The path for this URI', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', ), @@ -906,20 +911,21 @@ function system_schema() { 'primary key' => array('name'), ); $schema['semaphore'] = array( 'description' => 'Table for holding semaphores, locks, flags, etc. that cannot be stored as state since they must not be cached.', 'fields' => array( 'name' => array( 'description' => 'Primary Key: Unique name.', 'type' => 'varchar', 'length' => 255, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '' ), 'value' => array( 'description' => 'A value for the semaphore.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '' ), @@ -956,26 +962,28 @@ function system_schema() { 'uid' => array( 'description' => 'The {users}.uid corresponding to a session, or 0 for anonymous user.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, ), 'sid' => array( 'description' => "A session ID (hashed). The value is generated by Drupal's session handlers.", 'type' => 'varchar', 'length' => 128, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, ), 'hostname' => array( 'description' => 'The IP address that last used this session ID (sid).', 'type' => 'varchar', 'length' => 128, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '', ), 'timestamp' => array( 'description' => 'The Unix timestamp when this session last requested a page. Old records are purged by PHP automatically.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, ), 'session' => array( @@ -1020,20 +1028,21 @@ function system_schema() { 'description' => 'The alias for this path; e.g. title-of-the-story.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', ), 'langcode' => array( 'description' => "The language code this alias is for; if 'und', the alias will be used for unknown languages. Each Drupal path can have an alias for each supported language.", 'type' => 'varchar', 'length' => 12, + 'is_alphanumeric' => TRUE, 'not null' => TRUE, 'default' => '', ), ), 'primary key' => array('pid'), 'indexes' => array( 'alias_langcode_pid' => array('alias', 'langcode', 'pid'), 'source_langcode_pid' => array('source', 'langcode', 'pid'), ), ); diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php index c55953c..09f6713 100644 --- a/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php +++ b/core/modules/text/src/Plugin/Field/FieldType/TextLongItem.php @@ -29,19 +29,20 @@ class TextLongItem extends TextItemBase { public static function schema(FieldStorageDefinitionInterface $field_definition) { return array( 'columns' => array( 'value' => array( 'type' => 'text', 'size' => 'big', ), 'format' => array( 'type' => 'varchar', 'length' => 255, + 'is_alphanumeric' => TRUE, ), ), 'indexes' => array( 'format' => array('format'), ), ); } } diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php b/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php index 48d4dac..6907d14 100644 --- a/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php +++ b/core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php @@ -63,20 +63,21 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) 'type' => 'text', 'size' => 'big', ), 'summary' => array( 'type' => 'text', 'size' => 'big', ), 'format' => array( 'type' => 'varchar', 'length' => 255, + 'is_alphanumeric' => TRUE, ), ), 'indexes' => array( 'format' => array('format'), ), ); } /** * {@inheritdoc}