Commit 161a9970 authored by webchick's avatar webchick

#308534 by Dave Reid: Remove stray whitespace core-wide.

parent cf987be1
......@@ -9,13 +9,13 @@
class InsertQuery_mysql extends InsertQuery {
public function execute() {
// Confirm that the user did not try to specify an identical
// field and default field.
if (array_intersect($this->insertFields, $this->defaultFields)) {
throw new PDOException('You may not specify the same field to have a value and a schema-default value.');
}
$last_insert_id = 0;
$max_placeholder = 0;
......@@ -37,10 +37,10 @@ public function execute() {
public function __toString() {
$delay = $this->queryOptions['delay'] ? 'DELAYED' : '';
// Default fields are always placed first for consistency.
$insert_fields = array_merge($this->defaultFields, $this->insertFields);
$query = "INSERT $delay INTO {" . $this->table . '} (' . implode(', ', $insert_fields) . ') VALUES ';
$max_placeholder = 0;
......@@ -48,11 +48,11 @@ public function __toString() {
if (count($this->insertValues)) {
foreach ($this->insertValues as $insert_values) {
$placeholders = array();
// Default fields aren't really placeholders, but this is the most convenient
// way to handle them.
$placeholders = array_pad($placeholders, count($this->defaultFields), 'default');
$new_placeholder = $max_placeholder + count($insert_values);
for ($i = $max_placeholder; $i < $new_placeholder; ++$i) {
$placeholders[] = ':db_insert_placeholder_'. $i;
......@@ -87,7 +87,7 @@ public function execute() {
unset($update_fields[$exclude_field]);
}
}
$insert_fields = $this->insertFields + $this->keyFields;
$max_placeholder = 0;
......@@ -106,7 +106,7 @@ public function execute() {
}
unset($update_fields[$field]);
}
// Because we filter $fields the same way here and in __toString(), the
// placeholders will all match up properly.
$max_placeholder = 0;
......@@ -119,7 +119,7 @@ public function execute() {
return $last_insert_id;
}
public function __toString() {
// Set defaults.
......@@ -134,7 +134,7 @@ public function __toString() {
unset($update_fields[$exclude_field]);
}
}
$insert_fields = $this->insertFields + $this->keyFields;
$query = "INSERT INTO {" . $this->table . '} (' . implode(', ', array_keys($insert_fields)) . ') VALUES ';
......@@ -147,7 +147,7 @@ public function __toString() {
}
$query .= '(' . implode(', ', $values) . ') ON DUPLICATE KEY UPDATE ';
// Expressions take priority over literal fields, so we process those first
// and remove any literal fields that conflict.
$max_placeholder = 0;
......@@ -160,7 +160,7 @@ public function __toString() {
foreach ($update_fields as $field => $value) {
$update[] = ($field . '=:db_update_placeholder_' . $max_placeholder++);
}
$query .= implode(', ', $update);
return $query;
......
......@@ -17,7 +17,7 @@ class DatabaseSchema_mysql extends DatabaseSchema {
public function tableExists($table) {
return (bool) $this->connection->query("SHOW TABLES LIKE '{" . $table . "}'", array(), array())->fetchField();
}
public function columnExists($table, $column) {
return (bool) $this->connection->query("SHOW COLUMNS FROM {" . $this->escapeTable($table) . "} LIKE '" . $this->escapeTable($column) . "'", array(), array())->fetchField();
}
......@@ -37,25 +37,25 @@ protected function createTableSql($name, $table) {
if (empty($table['mysql_suffix'])) {
$table['mysql_suffix'] = "/*!40100 DEFAULT CHARACTER SET UTF8 */";
}
$sql = "CREATE TABLE {" . $name . "} (\n";
// Add the SQL statement for each field.
foreach ($table['fields'] as $field_name => $field) {
$sql .= $this->createFieldSql($field_name, $this->processField($field)) . ", \n";
}
// Process keys & indexes.
$keys = $this->createKeysSql($table);
if (count($keys)) {
$sql .= implode(", \n", $keys) . ", \n";
}
// Remove the last comma and space.
$sql = substr($sql, 0, -3) . "\n) ";
$sql .= $table['mysql_suffix'];
return array($sql);
}
......@@ -72,40 +72,40 @@ protected function createTableSql($name, $table) {
*/
protected function createFieldSql($name, $spec) {
$sql = "`" . $name . "` " . $spec['mysql_type'];
if (isset($spec['length'])) {
$sql .= '(' . $spec['length'] . ')';
}
elseif (isset($spec['precision']) && isset($spec['scale'])) {
$sql .= '(' . $spec['precision'] . ', ' . $spec['scale'] . ')';
}
if (!empty($spec['unsigned'])) {
$sql .= ' unsigned';
}
if (!empty($spec['not null'])) {
$sql .= ' NOT NULL';
}
if (!empty($spec['auto_increment'])) {
$sql .= ' auto_increment';
}
if (isset($spec['default'])) {
if (is_string($spec['default'])) {
$spec['default'] = "'" . $spec['default'] . "'";
}
$sql .= ' DEFAULT ' . $spec['default'];
}
if (empty($spec['not null']) && !isset($spec['default'])) {
$sql .= ' DEFAULT NULL';
}
return $sql;
}
/**
* Set database-engine specific properties for a field.
*
......@@ -113,21 +113,21 @@ protected function createFieldSql($name, $spec) {
* A field description array, as specified in the schema documentation.
*/
protected function processField($field) {
if (!isset($field['size'])) {
$field['size'] = 'normal';
}
// Set the correct database-engine specific datatype.
if (!isset($field['mysql_type'])) {
$map = db_type_map();
$field['mysql_type'] = $map[$field['type'] . ':' . $field['size']];
}
if ($field['type'] == 'serial') {
$field['auto_increment'] = TRUE;
}
return $field;
}
......@@ -138,41 +138,41 @@ public function getFieldTypeMap() {
static $map = array(
'varchar:normal' => 'VARCHAR',
'char:normal' => 'CHAR',
'text:tiny' => 'TINYTEXT',
'text:small' => 'TINYTEXT',
'text:medium' => 'MEDIUMTEXT',
'text:big' => 'LONGTEXT',
'text:normal' => 'TEXT',
'serial:tiny' => 'TINYINT',
'serial:small' => 'SMALLINT',
'serial:medium' => 'MEDIUMINT',
'serial:big' => 'BIGINT',
'serial:normal' => 'INT',
'int:tiny' => 'TINYINT',
'int:small' => 'SMALLINT',
'int:medium' => 'MEDIUMINT',
'int:big' => 'BIGINT',
'int:normal' => 'INT',
'float:tiny' => 'FLOAT',
'float:small' => 'FLOAT',
'float:medium' => 'FLOAT',
'float:big' => 'DOUBLE',
'float:normal' => 'FLOAT',
'numeric:normal' => 'DECIMAL',
'blob:big' => 'LONGBLOB',
'blob:normal' => 'BLOB',
'datetime:normal' => 'DATETIME',
);
return $map;
}
......@@ -195,7 +195,7 @@ protected function createKeysSql($spec) {
return $keys;
}
protected function createKeySql($fields) {
$ret = array();
foreach ($fields as $field) {
......@@ -225,7 +225,7 @@ protected function createKeysSqlHelper($fields) {
public function renameTable(&$ret, $table, $new_name) {
$ret[] = update_sql('ALTER TABLE {' . $table . '} RENAME TO {' . $new_name . '}');
}
public function dropTable(&$ret, $table) {
$ret[] = update_sql('DROP TABLE {' . $table . '}');
}
......@@ -265,7 +265,7 @@ public function fieldSetDefault(&$ret, $table, $field, $default) {
else {
$default = is_string($default) ? "'$default'" : $default;
}
$ret[] = update_sql('ALTER TABLE {' . $table . '} ALTER COLUMN ' . $field . ' SET DEFAULT ' . $default);
}
......@@ -276,7 +276,7 @@ public function fieldSetNoDefault(&$ret, $table, $field) {
public function addPrimaryKey(&$ret, $table, $fields) {
$ret[] = update_sql('ALTER TABLE {' . $table . '} ADD PRIMARY KEY (' . $this->createKeySql($fields) . ')');
}
public function dropPrimaryKey(&$ret, $table) {
$ret[] = update_sql('ALTER TABLE {' . $table . '} DROP PRIMARY KEY');
}
......@@ -288,7 +288,7 @@ public function addUniqueKey(&$ret, $table, $name, $fields) {
public function dropUniqueKey(&$ret, $table, $name) {
$ret[] = update_sql('ALTER TABLE {' . $table . '} DROP KEY ' . $name);
}
public function addIndex(&$ret, $table, $name, $fields) {
$query = 'ALTER TABLE {' . $table . '} ADD INDEX ' . $name . ' (' . $this->createKeySql($fields) . ')';
$ret[] = update_sql($query);
......@@ -297,7 +297,7 @@ public function addIndex(&$ret, $table, $name, $fields) {
public function dropIndex(&$ret, $table, $name) {
$ret[] = update_sql('ALTER TABLE {' . $table . '} DROP INDEX ' . $name);
}
public function changeField(&$ret, $table, $field, $field_new, $spec, $keys_new = array()) {
$sql = 'ALTER TABLE {' . $table . '} CHANGE ' . $field . ' ' . $this->createFieldSql($field_new, $this->processField($spec));
if (count($keys_new)) {
......
......@@ -33,7 +33,7 @@ public function __construct(Array $connection_options = array()) {
public function query($query, Array $args = array(), $options = array()) {
$options += $this->defaultOptions();
try {
if ($query instanceof DatabaseStatement) {
$stmt = $query;
......@@ -43,7 +43,7 @@ public function query($query, Array $args = array(), $options = array()) {
$stmt = $this->prepareQuery($query);
$stmt->execute($args, $options);
}
switch ($options['return']) {
case Database::RETURN_STATEMENT:
return $stmt;
......@@ -74,7 +74,7 @@ public function query($query, Array $args = array(), $options = array()) {
return NULL;
}
}
public function queryRange($query, Array $args, $from, $count, Array $options) {
// Backward compatibility hack, temporary.
$query = str_replace(array('%d' , '%f' , '%b' , "'%s'"), '?', $query);
......
......@@ -13,9 +13,9 @@ public function __construct($connection, $table, Array $options = array()) {
parent::__construct($connection, $table, $options);
$this->queryOptions['return'] = Database::RETURN_NULL;
}
public function execute() {
// Confirm that the user did not try to specify an identical
// field and default field.
if (array_intersect($this->insertFields, $this->defaultFields)) {
......@@ -53,13 +53,13 @@ public function execute() {
// when requesting the last insert ID, so we pass that in via
// the options array.
$options = $this->queryOptions;
if ($schema['fields'][$schema['primary key'][0]]['type'] == 'serial') {
$options['sequence_name'] = $this->connection->makeSequenceName($this->table, $schema['primary key'][0]);
$options['return'] = Database::RETURN_INSERT_ID;
}
$last_insert_id = $this->connection->query($stmt, array(), $options);
// Re-initialize the values array so that we can re-use this query.
$this->insertValues = array();
......@@ -67,7 +67,7 @@ public function execute() {
}
public function __toString() {
// Default fields are always placed first for consistency.
$insert_fields = array_merge($this->defaultFields, $this->insertFields);
......@@ -78,11 +78,11 @@ public function __toString() {
if (count($this->insertValues)) {
foreach ($this->insertValues as $insert_values) {
$placeholders = array();
// Default fields aren't really placeholders, but this is the most convenient
// way to handle them.
$placeholders = array_pad($placeholders, count($this->defaultFields), 'default');
$new_placeholder = $max_placeholder + count($insert_values);
for ($i = $max_placeholder; $i < $new_placeholder; ++$i) {
$placeholders[] = ':db_insert_placeholder_' . $i;
......@@ -103,18 +103,18 @@ public function __toString() {
}
}
class UpdateQuery_pgsql extends UpdateQuery {
class UpdateQuery_pgsql extends UpdateQuery {
public function execute() {
$max_placeholder = 0;
$blobs = array();
$blob_count = 0;
$schema = drupal_get_schema($this->table);
// Because we filter $fields the same way here and in __toString(), the
// placeholders will all match up properly.
$stmt = $this->connection->prepareQuery((string)$this);
// Expressions take priority over literal fields, so we process those first
// and remove any literal fields that conflict.
$fields = $this->fields;
......@@ -130,7 +130,7 @@ public function execute() {
}
unset($fields[$field]);
}
foreach ($fields as $field => &$value) {
$placeholder = ':db_update_placeholder_' . ($max_placeholder++);
......@@ -160,7 +160,7 @@ public function execute() {
$options = $this->queryOptions;
$options['already_prepared'] = TRUE;
$this->connection->query($stmt, $options);
//$stmt->execute(NULL, $this->queryOptions);
return $stmt->rowCount();
}
......
......@@ -16,7 +16,7 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
public function tableExists($table) {
return (bool) db_result(db_query("SELECT COUNT(*) FROM pg_class WHERE relname = '{" . db_escape_table($table) . "}'"));
}
public function columnExists($table, $column) {
return (bool) db_result(db_query("SELECT COUNT(pg_attribute.attname) FROM pg_class, pg_attribute WHERE pg_attribute.attrelid = pg_class.oid AND pg_class.relname = '{" . db_escape_table($table) . "}' AND attname = '" . db_escape_table($column) . "'"));
}
......
......@@ -2092,11 +2092,11 @@ function _locale_rebuild_js($langcode = NULL) {
// Construct the array for JavaScript translations.
// We sort on plural so that we have all plural forms before singular forms.
$result = db_query("SELECT s.lid, s.source, t.plid, t.plural, t.translation
FROM {locales_source} s
LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language
WHERE s.location LIKE '%.js%'
AND s.textgroup = 'default'
$result = db_query("SELECT s.lid, s.source, t.plid, t.plural, t.translation
FROM {locales_source} s
LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language
WHERE s.location LIKE '%.js%'
AND s.textgroup = 'default'
ORDER BY t.plural DESC", array(':language' => $language->language));
$translations = $plurals = array();
......
......@@ -10,69 +10,69 @@
* - _sess_close()
* - _sess_read()
* - _sess_write()
* are assigned by session_set_save_handler() in bootstrap.inc and are called
* automatically by PHP. These functions should not be called directly. Session
* are assigned by session_set_save_handler() in bootstrap.inc and are called
* automatically by PHP. These functions should not be called directly. Session
* data should instead be accessed via the $_SESSION superglobal.
*
* The user-level session storage handlers:
* - sess_destroy_sid()
* - sess_gc()
* are assigned by session_set_save_handler() in bootstrap.inc and are called
* are assigned by session_set_save_handler() in bootstrap.inc and are called
* automatically by PHP, but they may safely be called directly.
*/
/**
* Session handler assigned by session_set_save_handler().
*
* This function is used to handle any initialization, such as file paths or
* database connections, that is needed before accessing session data. Drupal
*
* This function is used to handle any initialization, such as file paths or
* database connections, that is needed before accessing session data. Drupal
* does not need to initialize anything in this function.
*
* This function should not be called directly.
*
* @return
* This function will always return TRUE.
*/
*/
function _sess_open() {
return TRUE;
}
/**
* Session handler assigned by session_set_save_handler().
*
* This function is used to close the current session. Because Drupal stores
* session data in the database immediately on write, this function does
*
* This function is used to close the current session. Because Drupal stores
* session data in the database immediately on write, this function does
* not need to do anything.
*
* This function should not be called directly.
*
* @return
* This function will always return TRUE.
*/
*/
function _sess_close() {
return TRUE;
}
/**
* Session handler assigned by session_set_save_handler().
*
* This function will be called by PHP to retrieve the current user's
* session data, which is stored in the database. It also loads the
*
* This function will be called by PHP to retrieve the current user's
* session data, which is stored in the database. It also loads the
* current user's appropriate roles into the user object.
*
* This function should not be called directly. Session data should
* This function should not be called directly. Session data should
* instead be accessed via the $_SESSION superglobal.
*
* @param $key
* Session ID
* @return
* Either an array of the session data, or an empty string, if no data
* Either an array of the session data, or an empty string, if no data
* was found or the user is anonymous.
*/
function _sess_read($key) {
global $user;
// Write and Close handlers are called after destructing objects
// Write and Close handlers are called after destructing objects
// since PHP 5.0.5.
// Thus destructors can use sessions but session handler can't use objects.
// So we are moving session closure before destructing objects.
......@@ -85,7 +85,7 @@ function _sess_read($key) {
return '';
}
// Otherwise, if the session is still active, we have a record of the
// Otherwise, if the session is still active, we have a record of the
// client's session in the database.
$user = db_fetch_object(db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = '%s'", $key));
......@@ -102,7 +102,7 @@ function _sess_read($key) {
$user->roles[$role->rid] = $role->name;
}
}
// We didn't find the client's record (session has expired), or they
// We didn't find the client's record (session has expired), or they
// are an anonymous user.
else {
$session = isset($user->session) ? $user->session : '';
......@@ -114,11 +114,11 @@ function _sess_read($key) {
/**
* Session handler assigned by session_set_save_handler().
*
* This function will be called by PHP to store the current user's
*
* This function will be called by PHP to store the current user's
* session, which Drupal saves to the database.
*
* This function should not be called directly. Session data should
* This function should not be called directly. Session data should
* instead be accessed via the $_SESSION superglobal.
*
* @param $key
......@@ -177,7 +177,7 @@ function drupal_session_regenerate() {
}
/**
* Counts how many users have sessions. Can count either anonymous sessions,
* Counts how many users have sessions. Can count either anonymous sessions,
* authenticated sessions, or both.
*
* @param int $timestamp
......@@ -196,7 +196,7 @@ function drupal_session_count($timestamp = 0, $anonymous = true) {
/**
* Session handler assigned by session_set_save_handler().
*
*
* Cleanup a specific session.
*
* @param string $sid
......@@ -218,7 +218,7 @@ function drupal_session_destroy_uid($uid) {
/**
* Session handler assigned by session_set_save_handler().
*
*
* Cleanup stalled sessions.
*/
function _sess_gc($lifetime) {
......@@ -235,13 +235,13 @@ function _sess_gc($lifetime) {
/**
* Determine whether to save session data of the current request.
*
* This function allows the caller to temporarily disable writing of
* session data, should the request end while performing potentially
* This function allows the caller to temporarily disable writing of
* session data, should the request end while performing potentially
* dangerous operations, such as manipulating the global $user object.
* See http://drupal.org/node/218104 for usage
*
* @param $status
* Disables writing of session data when FALSE, (re-)enables
* Disables writing of session data when FALSE, (re-)enables
* writing when TRUE.
* @return
* FALSE if writing session data has been disabled. Otherwise, TRUE.
......
......@@ -197,8 +197,8 @@ function _init_theme($theme, $base_theme = array(), $registry_callback = '_theme
/**
* Get the theme registry.
* @return
* The theme registry array if it has been stored in memory, NULL otherwise.
* @return
* The theme registry array if it has been stored in memory, NULL otherwise.
*/
function theme_get_registry() {
return _theme_set_registry();
......@@ -208,16 +208,16 @@ function theme_get_registry() {
* Store the theme registry in memory.
* @param $registry
* A registry array as returned by _theme_build_registry()
* @return
* @return
* The theme registry array stored in memory
*/
function _theme_set_registry($registry = NULL) {
static $theme_registry = NULL;
if (isset($registry)) {
$theme_registry = $registry;
}
return $theme_registry;
}
......@@ -2001,4 +2001,3 @@ function template_preprocess_block(&$variables) {
$variables['template_files'][] = 'block-' . $variables['block']->module;
$variables['template_files'][] = 'block-' . $variables['block']->module . '-' . $variables['block']->delta;
}
......@@ -618,7 +618,7 @@ function install_tasks($profile, $task) {
// Bootstrap newly installed Drupal, while preserving existing messages.
$messages = isset($_SESSION['messages']) ? $_SESSION['messages'] : '';
drupal_install_init_database();
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$_SESSION['messages'] = $messages;
......@@ -1179,4 +1179,3 @@ function install_configure_form_submit($form, &$form_state) {
// Start the installer.
install_main();
......@@ -60,7 +60,7 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
$recipients = array('simpletest@example.com', 'simpletest2@example.com', 'simpletest3@example.com');
$this->addCategory($category = $this->randomName(16), implode(',', array($recipients[0])), '', TRUE);
$this->assertRaw(t('Category %category has been added.', array('%category' => $category)), t('Category successfully added.'));
// Test update contact form category
$categories = $this->getCategories();
$category_id = $this->updateCategory($categories, $category = $this->randomName(16), $recipients_str = implode(',', array($recipients[0], $recipients[1])), $reply = $this->randomName(30), FALSE);
......@@ -70,7 +70,7 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
$this->assertEqual($category_array['reply'], $reply);
$this->assertFalse($category_array['selected']);
$this->assertRaw(t('Category %category has been updated.', array('%category' => $category)), t('Category successfully updated.'));
$this->addCategory($category = $this->randomName(16), implode(',', array($recipients[0], $recipients[1])), '', FALSE);
$this->assertRaw(t('Category %category has been added.', array('%category' => $category)), t('Category successfully added.'));
......
......@@ -315,13 +315,13 @@ function menu_nodeapi(&$node, $op) {
if (isset($node->nid)) {
// Give priority to the default menu
$mlid = db_result(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = :path AND menu_name = :menu_name AND module = 'menu' ORDER BY mlid ASC", array(
':path' => 'node/'. $node->nid,
':path' => 'node/'. $node->nid,
':menu_name' => $menu_name,
), 0, 1));
// Check all menus if a link does not exist in the default menu.
if (!$mlid) {
$mlid = db_result(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = :path AND module = 'menu' ORDER BY mlid ASC", array(
':path' => 'node/'. $node->nid,
':path' => 'node/'. $node->nid,
), 0, 1));
}
if ($mlid) {
......
......@@ -478,10 +478,10 @@ function node_admin_nodes() {
// Build the query and load the nodes we want to display.
$filter = node_build_filter_query();
$sort = tablesort_sql($header, '', 'n.changed DESC');
$result = pager_query(db_rewrite_sql('SELECT n.*, u.name FROM {node} n '. $filter['join'] .' INNER JOIN {users} u ON n.uid = u.uid '. $filter['where'] . $sort), 50, 0, NULL, $filter['args']);
// Build the 'Update options' form.
$form['options'] = array(
'#type' => 'fieldset',
......@@ -608,7 +608,7 @@ function theme_node_admin_nodes($form) {
}
$output .= theme('table', $header, $rows);
if ($form['pager']['#markup']) {
$output .= drupal_render($form['pager']);
}
......
......@@ -111,7 +111,7 @@ function profile_autocomplete($field, $string) {
$matches = array();
if (db_result(db_query("SELECT COUNT(*) FROM {profile_fields} WHERE fid = %d AND autocomplete = 1", $field))) {
$result = db_query_range("SELECT value FROM {profile_values} WHERE fid = :fid AND LOWER(value) LIKE LOWER(:value) GROUP BY value ORDER BY value ASC", array(
':fid' => $field,
':fid' => $field,
':value' => $string .'%',
), 0, 10);
while ($data = db_fetch_object($result)) {
......
......@@ -113,7 +113,7 @@ class SimpleTestTestCase extends DrupalWebTestCase {
// Call an assert function specific to that class.
$this->assertNothing();
// Generates a warning inside a PHP function.
array_key_exists(NULL, NULL);
}
......
......@@ -110,7 +110,7 @@ class BootstrapPageCacheTestCase extends DrupalWebTestCase {
}
class BootstrapVariableTestCase extends DrupalWebTestCase {