// Split the key into schema and table for querying.
list($schema,$table_name)=explode('.',$key);
$table_information=(object)array(
'blob_fields'=>array(),
'sequences'=>array(),
);
// Don't use {} around information_schema.columns table.
$result=$this->connection->query("SELECT column_name, data_type, column_default FROM information_schema.columns WHERE table_schema = :schema AND table_name = :table AND (data_type = 'bytea' OR (numeric_precision IS NOT NULL AND column_default LIKE :default))",array(
':schema'=>$schema,
':table'=>$table_name,
':default'=>'%nextval%',
// The bytea columns and sequences for a table can be found in
// pg_attribute, which is significantly faster than querying the
// information_schema. The data type of a field can be found by lookup
// of the attribute ID, and the default value must be extracted from the
// node tree for the attribute definition instead of the historical
// human-readable column, adsrc.
$sql=<<<'EOD'
SELECT pg_attribute.attname AS column_name, format_type(pg_attribute.atttypid, pg_attribute.atttypmod) AS data_type, pg_get_expr(pg_attrdef.adbin, pg_attribute.attrelid) AS column_default
FROM pg_attribute
LEFT JOIN pg_attrdef ON pg_attrdef.adrelid = pg_attribute.attrelid AND pg_attrdef.adnum = pg_attribute.attnum
WHERE pg_attribute.attnum > 0
AND NOT pg_attribute.attisdropped
AND pg_attribute.attrelid = :key::regclass
AND (format_type(pg_attribute.atttypid, pg_attribute.atttypmod) = 'bytea'
OR pg_get_expr(pg_attrdef.adbin, pg_attribute.attrelid) LIKE 'nextval%')
return(bool)$this->connection->query("SELECT 1 FROM pg_tables WHERE schemaname = :schema AND tablename = :table",array(':schema'=>$prefixInfo['schema'],':table'=>$prefixInfo['table']))->fetchField();
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.",array('@table'=>$table,'@table_new'=>$new_name)));
...
...
@@ -328,10 +492,31 @@ function renameTable($table, $new_name) {
// rename them when renaming the table.
$indexes=$this->connection->query('SELECT indexname FROM pg_indexes WHERE schemaname = :schema AND tablename = :table',array(':schema'=>$old_schema,':table'=>$old_table_name));
return(bool)$this->connection->query("SELECT 1 FROM pg_attribute WHERE attrelid = :key::regclass AND attname = :column AND NOT attisdropped AND attnum > 0",array(':key'=>$prefixInfo['schema'].'.'.$prefixInfo['table'],':column'=>$column))->fetchField();
@@ -343,7 +348,70 @@ public function findTables($table_expression) {
// couldn't use db_select() here because it would prefix
// information_schema.tables and the query would fail.
// Don't use {} around information_schema.tables table.
return$this->connection->query("SELECT table_name FROM information_schema.tables WHERE ".(string)$condition,$condition->arguments())->fetchAllKeyed(0,0);
return$this->connection->query("SELECT table_name AS table_name FROM information_schema.tables WHERE ".(string)$condition,$condition->arguments())->fetchAllKeyed(0,0);
}
/**
* Finds all tables that are like the specified base table name. This is a
* backport of the change made to findTables in Drupal 8 to work with virtual,
* un-prefixed table names. The original function is retained for Backwards
* Compatibility.
* @see https://www.drupal.org/node/2552435
*
* @param string $table_expression
* An SQL expression, for example "cache_%" (without the quotes).
*
* @return array
* Both the keys and the values are the matching tables.
*/
publicfunctionfindTablesD8($table_expression){
// Load all the tables up front in order to take into account per-table
// prefixes. The actual matching is done at the bottom of the method.
// Always use the AS keyword for field aliases, as some
// databases require it (e.g., PostgreSQL).
$fields[]=(isset($field['table'])?$this->connection->escapeTable($field['table']).'.':'').$this->connection->escapeField($field['field']).' AS '.$this->connection->escapeAlias($field['alias']);
$fields[]=$table.$this->connection->escapeField($field['field']).' AS '.$this->connection->escapeAlias($field['alias']);
}
foreach($this->expressionsas$alias=>$expression){
$fields[]=$expression['expression'].' AS '.$this->connection->escapeAlias($expression['alias']);
...
...
@@ -1555,10 +1596,10 @@ public function __toString() {
// Don't use the AS keyword for table aliases, as some
@@ -128,10 +140,10 @@ public function __destruct() {
$count=$this->query('SELECT COUNT(*) FROM '.$prefix.'.sqlite_master WHERE type = :type AND name NOT LIKE :pattern',array(':type'=>'table',':pattern'=>'sqlite_%'))->fetchField();
// We can prune the database file if it doesn't have any tables.
$errors[]=t('For security reasons, your upload has been rejected.');
}
return$errors;
}
/**
...
...
@@ -1802,7 +1862,7 @@ function file_validate_is_image(stdClass $file) {
$info=image_get_info($file->uri);
if(!$info||empty($info['extension'])){
$errors[]=t('Only JPEG, PNG and GIF images are allowed.');
$errors[]=t('The image file is invalid or the image type is not allowed. Allowed types: %allowed_types',array('%allowed_types'=>t('Only JPEG, PNG and GIF images are allowed.')));
}
return$errors;
...
...
@@ -1845,6 +1905,8 @@ function file_validate_image_resolution(stdClass $file, $maximum_dimensions = 0,
if($image=image_load($file->uri)){
image_scale($image,$width,$height);
image_save($image);
// Update the image info since we have resized it.
$info=$image->info;
$file->filesize=$image->info['file_size'];
drupal_set_message(t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.',array('%dimensions'=>$maximum_dimensions)));
@@ -1135,12 +1135,8 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
* Helper function to call form_set_error() if there is a token error.
*/
function_drupal_invalid_token_set_form_error(){
$path=current_path();
$query=drupal_get_query_parameters();
$url=url($path,array('query'=>$query));
// Setting this error will cause the form to fail validation.
form_set_error('form_token',t('The form has become outdated. Copy any unsaved work in the form below and then <a href="@link">reload this page</a>.',array('@link'=>$url)));
form_set_error('form_token',t('The form has become outdated. Press the back button, copy any unsaved work in the form, and then reload the page.'));
}
/**
...
...
@@ -1181,6 +1177,11 @@ function drupal_validate_form($form_id, &$form, &$form_state) {
form_error($elements,$t('!name cannot be longer than %max characters but is currently %length characters long.',array('!name'=>empty($elements['#title'])?$elements['#parents'][0]:$elements['#title'],'%max'=>$elements['#maxlength'],'%length'=>drupal_strlen($elements['#value']))));
drupal_set_message(st('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the <a href="@handbook_url">online handbook</a>.',array('%dir'=>$settings_dir,'%file'=>$settings_file,'@handbook_url'=>'http://drupal.org/server-permissions')),'warning');
drupal_set_message(st('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the <a href="@handbook_url">online handbook</a>.',array(