Merge branch '8.x' of git.drupal.org:project/drupal into 8.x

8.0.x
Dries 2012-06-05 08:43:38 -04:00
commit 67af8a4988
52 changed files with 825 additions and 511 deletions

View File

@ -150,12 +150,12 @@ const DRUPAL_BOOTSTRAP_FULL = 7;
/**
* Role ID for anonymous users; should match what's in the "role" table.
*/
const DRUPAL_ANONYMOUS_RID = 1;
const DRUPAL_ANONYMOUS_RID = 'anonymous';
/**
* Role ID for authenticated users; should match what's in the "role" table.
*/
const DRUPAL_AUTHENTICATED_RID = 2;
const DRUPAL_AUTHENTICATED_RID = 'authenticated';
/**
* The number of bytes in a kilobyte.

View File

@ -451,7 +451,7 @@ function drupal_get_query_array($query) {
if (!empty($query)) {
foreach (explode('&', $query) as $param) {
$param = explode('=', $param);
$result[$param[0]] = isset($param[1]) ? rawurldecode($param[1]) : '';
$result[$param[0]] = isset($param[1]) ? rawurldecode($param[1]) : NULL;
}
}
return $result;

View File

@ -29,10 +29,10 @@ use Drupal\Core\Database\Query\Condition;
* inherits much of its syntax and semantics.
*
* Most Drupal database SELECT queries are performed by a call to db_query() or
* db_query_range(). Module authors should also consider using the PagerDefault
* Extender for queries that return results that need to be presented on
* multiple pages, and the Tablesort Extender for generating appropriate queries
* for sortable tables.
* db_query_range(). Module authors should also consider using the
* Drupal\Core\Database\Query\PagerSelectExtender for queries that return
* results that need to be presented on multiple pages, and the Tablesort
* Extender for generating appropriate queries for sortable tables.
*
* For example, one might wish to return a list of the most recent 10 nodes
* authored by a given user. Instead of directly issuing the SQL query

View File

@ -227,8 +227,10 @@ function _drupal_log_error($error, $fatal = FALSE) {
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
if ($fatal) {
// When called from JavaScript, simply output the error message.
print t('%type: !message in %function (line %line of %file).', $error);
if (error_displayable($error)) {
// When called from JavaScript, simply output the error message.
print t('%type: !message in %function (line %line of %file).', $error);
}
exit;
}
}

View File

@ -1,174 +1,10 @@
<?php
use Drupal\Core\Database\Connection;
use Drupal\Core\Database\Query\SelectExtender;
use Drupal\Core\Database\Query\SelectInterface;
/**
* @file
* Functions to aid in presenting database results as a set of pages.
*/
/**
* Query extender for pager queries.
*
* This is the "default" pager mechanism. It creates a paged query with a fixed
* number of entries per page.
*/
class PagerDefault extends SelectExtender {
/**
* The highest element we've autogenerated so far.
*
* @var int
*/
static $maxElement = 0;
/**
* The number of elements per page to allow.
*
* @var int
*/
protected $limit = 10;
/**
* The unique ID of this pager on this page.
*
* @var int
*/
protected $element = NULL;
/**
* The count query that will be used for this pager.
*
* @var SelectQueryInterface
*/
protected $customCountQuery = FALSE;
public function __construct(SelectInterface $query, Connection $connection) {
parent::__construct($query, $connection);
// Add pager tag. Do this here to ensure that it is always added before
// preExecute() is called.
$this->addTag('pager');
}
/**
* Override the execute method.
*
* Before we run the query, we need to add pager-based range() instructions
* to it.
*/
public function execute() {
// Add convenience tag to mark that this is an extended query. We have to
// do this in the constructor to ensure that it is set before preExecute()
// gets called.
if (!$this->preExecute($this)) {
return NULL;
}
// A NULL limit is the "kill switch" for pager queries.
if (empty($this->limit)) {
return;
}
$this->ensureElement();
$total_items = $this->getCountQuery()->execute()->fetchField();
$current_page = pager_default_initialize($total_items, $this->limit, $this->element);
$this->range($current_page * $this->limit, $this->limit);
// Now that we've added our pager-based range instructions, run the query normally.
return $this->query->execute();
}
/**
* Ensure that there is an element associated with this query.
* If an element was not specified previously, then the value of the
* $maxElement counter is taken, after which the counter is incremented.
*
* After running this method, access $this->element to get the element for this
* query.
*/
protected function ensureElement() {
if (!isset($this->element)) {
$this->element = self::$maxElement++;
}
}
/**
* Specify the count query object to use for this pager.
*
* You will rarely need to specify a count query directly. If not specified,
* one is generated off of the pager query itself.
*
* @param SelectQueryInterface $query
* The count query object. It must return a single row with a single column,
* which is the total number of records.
*/
public function setCountQuery(SelectInterface $query) {
$this->customCountQuery = $query;
}
/**
* Retrieve the count query for this pager.
*
* The count query may be specified manually or, by default, taken from the
* query we are extending.
*
* @return SelectQueryInterface
* A count query object.
*/
public function getCountQuery() {
if ($this->customCountQuery) {
return $this->customCountQuery;
}
else {
return $this->query->countQuery();
}
}
/**
* Specify the maximum number of elements per page for this query.
*
* The default if not specified is 10 items per page.
*
* @param $limit
* An integer specifying the number of elements per page. If passed a false
* value (FALSE, 0, NULL), the pager is disabled.
*/
public function limit($limit = 10) {
$this->limit = $limit;
return $this;
}
/**
* Specify the element ID for this pager query.
*
* The element is used to differentiate different pager queries on the same
* page so that they may be operated independently. If you do not specify an
* element, every pager query on the page will get a unique element. If for
* whatever reason you want to explicitly define an element for a given query,
* you may do so here.
*
* Setting the element here also increments the static $maxElement counter,
* which is used for determining the $element when there's none specified.
*
* Note that no collision detection is done when setting an element ID
* explicitly, so it is possible for two pagers to end up using the same ID
* if both are set explicitly.
*
* @param $element
*/
public function element($element) {
$this->element = $element;
if ($element >= self::$maxElement) {
self::$maxElement = $element + 1;
}
return $this;
}
}
/**
* Returns the current page being requested for display within a pager.
*
@ -206,10 +42,11 @@ function pager_find_page($element = 0) {
* If the items being displayed result from a database query performed using
* Drupal's database API, and if you have control over the construction of the
* database query, you do not need to call this function directly; instead, you
* can simply extend the query object with the 'PagerDefault' extender before
* executing it. For example:
* can simply extend the query object with the 'PagerSelectExtender' extender
* before executing it. For example:
* @code
* $query = db_select('some_table')->extend('PagerDefault');
* $query = db_select('some_table')
* ->extend('Drupal\Core\Database\Query\PagerSelectExtender');
* @endcode
*
* However, if you are using a different method for generating the items to be

View File

@ -25,8 +25,7 @@ interface ExtendableInterface {
* @param $extender_name
* The base name of the extending class. The base name will be checked
* against the current database connection to allow driver-specific subclasses
* as well, using the same logic as the query objects themselves. For example,
* PagerDefault_mysql is the MySQL-specific override for PagerDefault.
* as well, using the same logic as the query objects themselves.
* @return Drupal\Core\Database\Query\ExtendableInterface
* The extender object, which now contains a reference to this object.
*/

View File

@ -0,0 +1,172 @@
<?php
/**
* @file
* Definition of Drupal\Core\Database\Query\PagerSelectExtender
*/
namespace Drupal\Core\Database\Query;
use Drupal\Core\Database\Connection;
use Drupal\Core\Database\Query\SelectExtender;
use Drupal\Core\Database\Query\SelectInterface;
/**
* Query extender for pager queries.
*
* This is the "default" pager mechanism. It creates a paged query with a fixed
* number of entries per page.
*/
class PagerSelectExtender extends SelectExtender {
/**
* The highest element we've autogenerated so far.
*
* @var int
*/
static $maxElement = 0;
/**
* The number of elements per page to allow.
*
* @var int
*/
protected $limit = 10;
/**
* The unique ID of this pager on this page.
*
* @var int
*/
protected $element = NULL;
/**
* The count query that will be used for this pager.
*
* @var SelectQueryInterface
*/
protected $customCountQuery = FALSE;
public function __construct(SelectInterface $query, Connection $connection) {
parent::__construct($query, $connection);
// Add pager tag. Do this here to ensure that it is always added before
// preExecute() is called.
$this->addTag('pager');
}
/**
* Override the execute method.
*
* Before we run the query, we need to add pager-based range() instructions
* to it.
*/
public function execute() {
// Add convenience tag to mark that this is an extended query. We have to
// do this in the constructor to ensure that it is set before preExecute()
// gets called.
if (!$this->preExecute($this)) {
return NULL;
}
// A NULL limit is the "kill switch" for pager queries.
if (empty($this->limit)) {
return;
}
$this->ensureElement();
$total_items = $this->getCountQuery()->execute()->fetchField();
$current_page = pager_default_initialize($total_items, $this->limit, $this->element);
$this->range($current_page * $this->limit, $this->limit);
// Now that we've added our pager-based range instructions, run the query normally.
return $this->query->execute();
}
/**
* Ensure that there is an element associated with this query.
* If an element was not specified previously, then the value of the
* $maxElement counter is taken, after which the counter is incremented.
*
* After running this method, access $this->element to get the element for this
* query.
*/
protected function ensureElement() {
if (!isset($this->element)) {
$this->element = self::$maxElement++;
}
}
/**
* Specify the count query object to use for this pager.
*
* You will rarely need to specify a count query directly. If not specified,
* one is generated off of the pager query itself.
*
* @param SelectQueryInterface $query
* The count query object. It must return a single row with a single column,
* which is the total number of records.
*/
public function setCountQuery(SelectInterface $query) {
$this->customCountQuery = $query;
}
/**
* Retrieve the count query for this pager.
*
* The count query may be specified manually or, by default, taken from the
* query we are extending.
*
* @return SelectQueryInterface
* A count query object.
*/
public function getCountQuery() {
if ($this->customCountQuery) {
return $this->customCountQuery;
}
else {
return $this->query->countQuery();
}
}
/**
* Specify the maximum number of elements per page for this query.
*
* The default if not specified is 10 items per page.
*
* @param $limit
* An integer specifying the number of elements per page. If passed a false
* value (FALSE, 0, NULL), the pager is disabled.
*/
public function limit($limit = 10) {
$this->limit = $limit;
return $this;
}
/**
* Specify the element ID for this pager query.
*
* The element is used to differentiate different pager queries on the same
* page so that they may be operated independently. If you do not specify an
* element, every pager query on the page will get a unique element. If for
* whatever reason you want to explicitly define an element for a given query,
* you may do so here.
*
* Setting the element here also increments the static $maxElement counter,
* which is used for determining the $element when there's none specified.
*
* Note that no collision detection is done when setting an element ID
* explicitly, so it is possible for two pagers to end up using the same ID
* if both are set explicitly.
*
* @param $element
*/
public function element($element) {
$this->element = $element;
if ($element >= self::$maxElement) {
self::$maxElement = $element + 1;
}
return $this;
}
}

View File

@ -84,10 +84,7 @@ Drupal.tableDrag = function (table, tableSettings) {
// Make each applicable row draggable.
// Match immediate children of the parent element to allow nesting.
var $rows = $table.find('> tr.draggable, > tbody > tr.draggable');
if ($rows.length > 1) {
$rows.each(function () { self.makeDraggable(this); });
}
$table.find('> tr.draggable, > tbody > tr.draggable').each(function () { self.makeDraggable(this); });
// Add a link before the table for users to show or hide weight columns.
$table.before($('<a href="#" class="tabledrag-toggle-weight"></a>')

View File

@ -134,7 +134,7 @@ function aggregator_load_feed_items($type, $data = NULL) {
}
$result = $query
->extend('PagerDefault')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->limit(20)
->orderBy('i.timestamp', 'DESC')
->orderBy('i.iid', 'DESC')

View File

@ -118,8 +118,8 @@ function block_schema() {
'description' => "The block's unique delta within module, from {block}.delta.",
),
'rid' => array(
'type' => 'int',
'unsigned' => TRUE,
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'description' => "The user's role ID from {users_roles}.rid.",
),
@ -128,6 +128,12 @@ function block_schema() {
'indexes' => array(
'rid' => array('rid'),
),
'foreign keys' => array(
'role' => array(
'table' => 'role',
'columns' => array('rid' => 'rid'),
),
),
);
$schema['block_custom'] = array(
@ -222,6 +228,17 @@ function block_install() {
* @{
*/
/**
* Implements hook_update_dependencies().
*/
function block_update_dependencies() {
// Convert role IDs after User module converted {role}.
$dependencies['block'][8002] = array(
'user' => 8002,
);
return $dependencies;
}
/**
* Block cache is always enabled in 8.x.
*
@ -268,6 +285,32 @@ function block_update_8001() {
db_create_table('block_language', $schema);
}
/**
* Replace serial role IDs with machine name strings.
*
* @see user_update_8002()
*/
function block_update_8002() {
// Change serial rid column into string.
$column = array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'description' => "The user's role ID from {users_roles}.rid.",
);
db_change_field('block_role', 'rid', 'rid', $column);
// Rename the built-in serial role IDs into the hardcoded machine names.
db_update('block_role')
->fields(array('rid' => DRUPAL_ANONYMOUS_RID))
->condition('rid', 1)
->execute();
db_update('block_role')
->fields(array('rid' => DRUPAL_AUTHENTICATED_RID))
->condition('rid', 2)
->execute();
}
/**
* @} End of "addtogroup updates-7.x-to-8.x".
* The next series of updates should start at 9000.

View File

@ -79,7 +79,9 @@ function comment_admin_overview($form, &$form_state, $arg) {
'operations' => array('data' => t('Operations')),
);
$query = db_select('comment', 'c')->extend('PagerDefault')->extend('TableSort');
$query = db_select('comment', 'c')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('TableSort');
$query->join('node', 'n', 'n.nid = c.nid');
$query->addField('n', 'title', 'node_title');
$query->addTag('node_access');

View File

@ -849,7 +849,8 @@ function comment_node_page_additions(Node $node) {
* to consider the trailing "/" so we use a substring only.
*/
function comment_get_thread(Node $node, $mode, $comments_per_page) {
$query = db_select('comment', 'c')->extend('PagerDefault');
$query = db_select('comment', 'c')
->extend('Drupal\Core\Database\Query\PagerSelectExtender');
$query->addField('c', 'cid');
$query
->condition('c.nid', $node->nid)

View File

@ -37,7 +37,9 @@ function dblog_overview() {
array('data' => t('Operations')),
);
$query = db_select('watchdog', 'w')->extend('PagerDefault')->extend('TableSort');
$query = db_select('watchdog', 'w')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('TableSort');
$query->leftJoin('users', 'u', 'w.uid = u.uid');
$query
->fields('w', array('wid', 'uid', 'severity', 'type', 'timestamp', 'message', 'variables', 'link'))
@ -96,7 +98,9 @@ function dblog_top($type) {
$count_query->addExpression('COUNT(DISTINCT(message))');
$count_query->condition('type', $type);
$query = db_select('watchdog', 'w')->extend('PagerDefault')->extend('TableSort');
$query = db_select('watchdog', 'w')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('TableSort');
$query->addExpression('COUNT(wid)', 'count');
$query = $query
->fields('w', array('message', 'variables'))

View File

@ -9,7 +9,7 @@ namespace Drupal\entity;
use Drupal\entity\EntityFieldQueryException;
use Drupal\Core\Database\Query\Select;
use PagerDefault;
use Drupal\Core\Database\Query\PagerSelectExtender;
/**
* Retrieves entities matching a given set of conditions.
@ -571,10 +571,10 @@ class EntityFieldQuery {
*/
public function pager($limit = 10, $element = NULL) {
if (!isset($element)) {
$element = PagerDefault::$maxElement++;
$element = PagerSelectExtender::$maxElement++;
}
elseif ($element >= PagerDefault::$maxElement) {
PagerDefault::$maxElement = $element + 1;
elseif ($element >= PagerSelectExtender::$maxElement) {
PagerSelectExtender::$maxElement = $element + 1;
}
$this->pager = array(

View File

@ -215,7 +215,9 @@ class TextFieldTestCase extends WebTestBase {
$format = filter_format_load($edit['format']);
$format_id = $format->format;
$permission = filter_permission_name($format);
$rid = max(array_keys($this->web_user->roles));
$roles = $this->web_user->roles;
unset($roles[DRUPAL_AUTHENTICATED_RID]);
$rid = key($roles);
user_role_grant_permissions($rid, array($permission));
$this->drupalLogin($this->web_user);

View File

@ -106,8 +106,10 @@ class FilterFormatAccessTest extends WebTestBase {
}
function testFormatRoles() {
// Get the role ID assigned to the regular user; it must be the maximum.
$rid = max(array_keys($this->web_user->roles));
// Get the role ID assigned to the regular user.
$roles = $this->web_user->roles;
unset($roles[DRUPAL_AUTHENTICATED_RID]);
$rid = key($roles);
// Check that this role appears in the list of roles that have access to an
// allowed text format, but does not appear in the list of roles that have

View File

@ -893,7 +893,9 @@ function forum_get_topics($tid, $sortby, $forum_per_page) {
}
}
$query = db_select('forum_index', 'f')->extend('PagerDefault')->extend('TableSort');
$query = db_select('forum_index', 'f')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('TableSort');
$query->fields('f');
$query
->condition('f.tid', $tid)

View File

@ -75,7 +75,9 @@ function _locale_translate_seek() {
$limit_language = $query['language'];
}
$sql_query = $sql_query->extend('PagerDefault')->limit(50);
$sql_query = $sql_query
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->limit(50);
$locales = $sql_query->execute();
$header = array(t('String'), t('Context'), ($limit_language) ? t('Language') : t('Languages'), array('data' => t('Operations'), 'colspan' => '2'));

View File

@ -447,7 +447,9 @@ function node_admin_nodes() {
}
$header['operations'] = array('data' => t('Operations'));
$query = db_select('node', 'n')->extend('PagerDefault')->extend('TableSort');
$query = db_select('node', 'n')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('TableSort');
node_build_filter_query($query);
if (!user_access('bypass node access')) {

View File

@ -1519,7 +1519,9 @@ function node_search_admin() {
*/
function node_search_execute($keys = NULL, $conditions = NULL) {
// Build matching conditions
$query = db_select('search_index', 'i', array('target' => 'slave'))->extend('Drupal\search\SearchQuery')->extend('PagerDefault');
$query = db_select('search_index', 'i', array('target' => 'slave'))
->extend('Drupal\search\SearchQuery')
->extend('Drupal\Core\Database\Query\PagerSelectExtender');
$query->join('node', 'n', 'n.nid = i.sid');
$query
->condition('n.status', 1)
@ -2488,7 +2490,7 @@ function node_page_default() {
->condition('status', 1)
->orderBy('sticky', 'DESC')
->orderBy('created', 'DESC')
->extend('PagerDefault')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->limit(variable_get('default_nodes_main', 10))
->addTag('node_access');

View File

@ -27,7 +27,9 @@ function path_admin_overview($keys = NULL) {
}
$header[] = array('data' => t('Operations'));
$query = db_select('url_alias')->extend('PagerDefault')->extend('TableSort');
$query = db_select('url_alias')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('TableSort');
if ($keys) {
// Replace wildcards with PDO wildcards.
$query->condition('alias', '%' . preg_replace('!\*+!', '%', $keys) . '%', 'LIKE');

View File

@ -29,7 +29,7 @@ function poll_page() {
->groupBy('n.title')
->groupBy('p.active')
->groupBy('n.created')
->extend('PagerDefault')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->limit($polls_per_page)
->addTag('node_access');
$select->setCountQuery($count_select);
@ -56,7 +56,9 @@ function poll_votes($node) {
$header[] = array('data' => t('Vote'), 'field' => 'pc.chtext');
$header[] = array('data' => t('Timestamp'), 'field' => 'pv.timestamp', 'sort' => 'desc');
$select = db_select('poll_vote', 'pv')->extend('PagerDefault')->extend('TableSort');
$select = db_select('poll_vote', 'pv')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('TableSort');
$select->join('poll_choice', 'pc', 'pv.chid = pc.chid');
$select->join('users', 'u', 'pv.uid = u.uid');
$queried_votes = $select

View File

@ -157,8 +157,8 @@ function hook_search_admin() {
/**
* Execute a search for a set of key words.
*
* Use database API with the 'PagerDefault' query extension to perform your
* search.
* Use database API with the 'Drupal\Core\Database\Query\PagerSelectExtender'
* query extension to perform your search.
*
* If your module uses hook_update_index() and search_index() to index its
* items, use table 'search_index' aliased to 'i' as the main table in your
@ -195,7 +195,9 @@ function hook_search_admin() {
*/
function hook_search_execute($keys = NULL, $conditions = NULL) {
// Build matching conditions
$query = db_select('search_index', 'i', array('target' => 'slave'))->extend('Drupal\search\SearchQuery')->extend('PagerDefault');
$query = db_select('search_index', 'i', array('target' => 'slave'))
->extend('Drupal\search\SearchQuery')
->extend('Drupal\Core\Database\Query\PagerSelectExtender');
$query->join('node', 'n', 'n.nid = i.sid');
$query
->condition('n.status', 1)

View File

@ -454,7 +454,8 @@ abstract class TestBase {
*/
protected function verbose($message) {
if ($id = simpletest_verbose($message)) {
$url = file_create_url($this->originalFileDirectory . '/simpletest/verbose/' . get_class($this) . '-' . $id . '.html');
$class = str_replace('\\', '_', get_class($this));
$url = file_create_url($this->originalFileDirectory . '/simpletest/verbose/' . $class . '-' . $id . '.html');
$this->error(l(t('Verbose message'), $url, array('attributes' => array('target' => '_blank'))), 'User notice');
}
}
@ -473,7 +474,8 @@ abstract class TestBase {
*/
public function run(array $methods = array()) {
// Initialize verbose debugging.
simpletest_verbose(NULL, variable_get('file_public_path', conf_path() . '/files'), get_class($this));
$class = get_class($this);
simpletest_verbose(NULL, variable_get('file_public_path', conf_path() . '/files'), str_replace('\\', '_', $class));
// HTTP auth settings (<username>:<password>) for the simpletest browser
// when sending requests to the test site.
@ -485,7 +487,6 @@ abstract class TestBase {
}
set_error_handler(array($this, 'errorHandler'));
$class = get_class($this);
// Iterate through all the methods in this class, unless a specific list of
// methods to run was passed.
$class_methods = get_class_methods($class);

View File

@ -400,17 +400,24 @@ abstract class WebTestBase extends TestBase {
/**
* Internal helper function; Create a role with specified permissions.
*
* @param $permissions
* @param array $permissions
* Array of permission names to assign to role.
* @param $name
* (optional) String for the name of the role. Defaults to a random string.
* @return
* @param string $rid
* (optional) The role ID (machine name). Defaults to a random name.
* @param string $name
* (optional) The label for the role. Defaults to a random string.
*
* @return string
* Role ID of newly created role, or FALSE if role creation failed.
*/
protected function drupalCreateRole(array $permissions, $name = NULL) {
// Generate random name if it was not passed.
if (!$name) {
$name = $this->randomName();
protected function drupalCreateRole(array $permissions, $rid = NULL, $name = NULL) {
// Generate a random, lowercase machine name if none was passed.
if (!isset($rid)) {
$rid = strtolower($this->randomName(8));
}
// Generate a random label.
if (!isset($name)) {
$name = $this->randomString(8);
}
// Check the all the permissions strings are valid.
@ -420,14 +427,29 @@ abstract class WebTestBase extends TestBase {
// Create new role.
$role = new stdClass();
$role->rid = $rid;
$role->name = $name;
user_role_save($role);
user_role_grant_permissions($role->rid, $permissions);
$result = user_role_save($role);
$this->assertTrue(isset($role->rid), t('Created role of name: @name, id: @rid', array('@name' => $name, '@rid' => (isset($role->rid) ? $role->rid : t('-n/a-')))), t('Role'));
if ($role && !empty($role->rid)) {
$count = db_query('SELECT COUNT(*) FROM {role_permission} WHERE rid = :rid', array(':rid' => $role->rid))->fetchField();
$this->assertTrue($count == count($permissions), t('Created permissions: @perms', array('@perms' => implode(', ', $permissions))), t('Role'));
$this->assertIdentical($result, SAVED_NEW, t('Created role ID @rid with name @name.', array(
'@name' => var_export($role->name, TRUE),
'@rid' => var_export($role->rid, TRUE),
)), t('Role'));
if ($result === SAVED_NEW) {
// Grant the specified permissions to the role, if any.
if (!empty($permissions)) {
user_role_grant_permissions($role->rid, $permissions);
$assigned_permissions = db_query('SELECT permission FROM {role_permission} WHERE rid = :rid', array(':rid' => $role->rid))->fetchCol();
$missing_permissions = array_diff($permissions, $assigned_permissions);
if (!$missing_permissions) {
$this->pass(t('Created permissions: @perms', array('@perms' => implode(', ', $permissions))), t('Role'));
}
else {
$this->fail(t('Failed to create permissions: @perms', array('@perms' => implode(', ', $missing_permissions))), t('Role'));
}
}
return $role->rid;
}
else {

View File

@ -635,7 +635,7 @@ class SimpleTestInstallationProfileModuleTestsTestCase extends WebTestBase {
* - but still install the drupal_system_listing_compatible_test.module
* contained in the Testing profile.
*
* @see DrupalSystemListingCompatibleTestCase
* @see Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest
*/
protected $profile = 'testing';
@ -661,10 +661,10 @@ class SimpleTestInstallationProfileModuleTestsTestCase extends WebTestBase {
$this->drupalGet('admin/config/development/testing');
$this->assertText('Installation profile module tests helper');
$edit = array(
'DrupalSystemListingCompatibleTestCase' => TRUE,
'Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest' => TRUE,
);
$this->drupalPost(NULL, $edit, t('Run tests'));
$this->assertText('DrupalSystemListingCompatibleTestCase test executed.');
$this->assertText('SystemListingCompatibleTest test executed.');
}
}
@ -681,7 +681,7 @@ class SimpleTestOtherInstallationProfileModuleTestsTestCase extends WebTestBase
* which should not be found.
*
* @see SimpleTestInstallationProfileModuleTestsTestCase
* @see DrupalSystemListingCompatibleTestCase
* @see Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest
*/
protected $profile = 'minimal';

View File

@ -25,7 +25,9 @@ function statistics_recent_hits() {
array('data' => t('Operations'))
);
$query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
$query = db_select('accesslog', 'a', array('target' => 'slave'))
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('TableSort');
$query->join('users', 'u', 'a.uid = u.uid');
$query
->fields('a', array('aid', 'timestamp', 'path', 'title', 'uid'))
@ -71,7 +73,9 @@ function statistics_top_pages() {
array('data' => t('Total page generation time'), 'field' => 'total_time')
);
$query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
$query = db_select('accesslog', 'a', array('target' => 'slave'))
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('TableSort');
$query->addExpression('COUNT(path)', 'hits');
// MAX(title) avoids having empty node titles which otherwise causes
// duplicates in the top pages list.
@ -124,7 +128,9 @@ function statistics_top_visitors() {
array('data' => t('Total page generation time'), 'field' => 'total'),
array('data' => user_access('block IP addresses') ? t('Operations') : '', 'colspan' => 2),
);
$query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
$query = db_select('accesslog', 'a', array('target' => 'slave'))
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('TableSort');
$query->leftJoin('blocked_ips', 'bl', 'a.hostname = bl.ip');
$query->leftJoin('users', 'u', 'a.uid = u.uid');
@ -184,7 +190,9 @@ function statistics_top_referrers() {
array('data' => t('Url'), 'field' => 'url'),
array('data' => t('Last visit'), 'field' => 'last'),
);
$query = db_select('accesslog', 'a')->extend('PagerDefault')->extend('TableSort');
$query = db_select('accesslog', 'a')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('TableSort');
$query->addExpression('COUNT(url)', 'hits');
$query->addExpression('MAX(timestamp)', 'last');

View File

@ -25,7 +25,9 @@ function statistics_node_tracker() {
array('data' => t('User'), 'field' => 'u.name'),
array('data' => t('Operations')));
$query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
$query = db_select('accesslog', 'a', array('target' => 'slave'))
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('TableSort');
$query->join('users', 'u', 'a.uid = u.uid');
$query
@ -79,7 +81,9 @@ function statistics_user_tracker() {
array('data' => t('Timestamp'), 'field' => 'timestamp', 'sort' => 'desc'),
array('data' => t('Page'), 'field' => 'path'),
array('data' => t('Operations')));
$query = db_select('accesslog', 'a', array('target' => 'slave'))->extend('PagerDefault')->extend('TableSort');
$query = db_select('accesslog', 'a', array('target' => 'slave'))
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('TableSort');
$query
->fields('a', array('aid', 'timestamp', 'path', 'title'))
->condition('uid', $account->uid)

View File

@ -222,7 +222,19 @@ function image_gd_desaturate(stdClass $image) {
function image_gd_load(stdClass $image) {
$extension = str_replace('jpg', 'jpeg', $image->info['extension']);
$function = 'imagecreatefrom' . $extension;
return (function_exists($function) && $image->resource = $function($image->source));
if (function_exists($function) && $image->resource = $function($image->source)) {
if (!imageistruecolor($image->resource)) {
// Convert indexed images to true color, so that filters work
// correctly and don't result in unnecessary dither.
$new_image = image_gd_create_tmp($image, $image->info['width'], $image->info['height']);
imagecopy($new_image, $image->resource, 0, 0, 0, 0, $image->info['width'], $image->info['height']);
imagedestroy($image->resource);
$image->resource = $new_image;
}
return (bool) $image->resource;
}
return FALSE;
}
/**

View File

@ -2922,7 +2922,9 @@ function system_actions_manage() {
array('data' => t('Label'), 'field' => 'label'),
array('data' => $instances_present ? t('Operations') : '', 'colspan' => '2')
);
$query = db_select('actions')->extend('PagerDefault')->extend('TableSort');
$query = db_select('actions')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('TableSort');
$result = $query
->fields('actions')
->limit(50)

View File

@ -36,3 +36,4 @@ files[] = tests/uuid.test
files[] = tests/xmlrpc.test
files[] = tests/upgrade/upgrade.test
files[] = tests/upgrade/upgrade.language.test
files[] = tests/upgrade/upgrade.roles.test

View File

@ -226,29 +226,38 @@ function system_requirements($phase) {
}
}
// Test settings.php file writability
// Test configuration files and directory for writability.
if ($phase == 'runtime') {
$conf_dir = drupal_verify_install_file(conf_path(), FILE_NOT_WRITABLE, 'dir');
$conf_file = drupal_verify_install_file(conf_path() . '/settings.php', FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE);
if (!$conf_dir || !$conf_file) {
$conf_errors = array();
$conf_path = conf_path();
if (!drupal_verify_install_file($conf_path, FILE_NOT_WRITABLE, 'dir')) {
$conf_errors[] = $t("The directory %file is not protected from modifications and poses a security risk. You must change the directory's permissions to be non-writable.", array('%file' => $conf_path));
}
foreach (array('settings.php', 'settings.local.php') as $conf_file) {
$full_path = $conf_path . '/' . $conf_file;
if (file_exists($full_path) && !drupal_verify_install_file($full_path, FILE_EXIST|FILE_READABLE|FILE_NOT_WRITABLE)) {
$conf_errors[] = $t("The file %file is not protected from modifications and poses a security risk. You must change the file's permissions to be non-writable.", array('%file' => $full_path));
}
}
if (!empty($conf_errors)) {
if (count($conf_errors) == 1) {
$description = $conf_errors[0];
}
else {
$description = theme('item_list', array('items' => $conf_errors));
}
$requirements['settings.php'] = array(
'value' => $t('Not protected'),
'severity' => REQUIREMENT_ERROR,
'description' => '',
'description' => $description,
);
if (!$conf_dir) {
$requirements['settings.php']['description'] .= $t('The directory %file is not protected from modifications and poses a security risk. You must change the directory\'s permissions to be non-writable. ', array('%file' => conf_path()));
}
if (!$conf_file) {
$requirements['settings.php']['description'] .= $t('The file %file is not protected from modifications and poses a security risk. You must change the file\'s permissions to be non-writable.', array('%file' => conf_path() . '/settings.php'));
}
}
else {
$requirements['settings.php'] = array(
'value' => $t('Protected'),
);
}
$requirements['settings.php']['title'] = $t('Configuration file');
$requirements['settings.php']['title'] = $t('Configuration files');
}
// Report cron status.

View File

@ -76,7 +76,7 @@ class CommonDrupalAlterTestCase extends WebTestBase {
* url() calls module_implements(), which may issue a db query, which requires
* inheriting from a web test case rather than a unit test case.
*/
class CommonURLUnitTestCase extends WebTestBase {
class CommonURLWebTestCase extends WebTestBase {
public static function getInfo() {
return array(
'name' => 'URL generation tests',
@ -280,6 +280,32 @@ class CommonURLUnitTestCase extends WebTestBase {
}
}
/**
* Tests for non-DB based URL generation functions.
*/
class CommonUrlUnitTestCase extends UnitTestBase {
public static function getInfo() {
return array(
'name' => 'URL generation tests',
'description' => 'Confirm that drupal_get_query_array() works correctly with various input.',
'group' => 'Common',
);
}
/**
* Tests drupal_get_query_array().
*/
function testDrupalGetQueryArray() {
$this->assertEqual(drupal_get_query_array('foo=bar'), array('foo' => 'bar'), 'Simple value works as expected.');
$this->assertEqual(drupal_get_query_array('foo=1'), array('foo' => '1'), 'Numeric value works as expected.');
$this->assertEqual(drupal_get_query_array('foo=1&bar=baz'), array('foo' => '1', 'bar' => 'baz'), 'Multiple values are parsed as well.');
$this->assertEqual(drupal_get_query_array('foo='), array('foo' => ''), 'An empty value is set as an empty string.');
$this->assertEqual(drupal_get_query_array('foo'), array('foo' => NULL), 'No value is set as a null value.');
}
}
/**
* Tests for check_plain(), filter_xss(), format_string(), and check_url().
*/

View File

@ -2087,7 +2087,7 @@ class DatabaseSelectComplexTestCase extends DatabaseTestCase {
function testHavingCountQuery() {
$query = db_select('test')
->extend('PagerDefault')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->groupBy('age')
->having('age + 1 > 0');
$query->addField('test', 'age');
@ -2352,7 +2352,8 @@ class DatabaseSelectPagerDefaultTestCase extends DatabaseTestCase {
* This is a regression test for #467984.
*/
function testInnerPagerQuery() {
$query = db_select('test', 't')->extend('PagerDefault');
$query = db_select('test', 't')
->extend('Drupal\Core\Database\Query\PagerSelectExtender');
$query
->fields('t', array('age'))
->orderBy('age')
@ -2373,7 +2374,8 @@ class DatabaseSelectPagerDefaultTestCase extends DatabaseTestCase {
* This is a regression test for #467984.
*/
function testHavingPagerQuery() {
$query = db_select('test', 't')->extend('PagerDefault');
$query = db_select('test', 't')
->extend('Drupal\Core\Database\Query\PagerSelectExtender');
$query
->fields('t', array('name'))
->orderBy('name')
@ -2393,7 +2395,8 @@ class DatabaseSelectPagerDefaultTestCase extends DatabaseTestCase {
function testElementNumbers() {
$_GET['page'] = '3, 2, 1, 0';
$name = db_select('test', 't')->extend('PagerDefault')
$name = db_select('test', 't')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->element(2)
->fields('t', array('name'))
->orderBy('age')
@ -2404,7 +2407,8 @@ class DatabaseSelectPagerDefaultTestCase extends DatabaseTestCase {
// Setting an element smaller than the previous one
// should not overwrite the pager $maxElement with a smaller value.
$name = db_select('test', 't')->extend('PagerDefault')
$name = db_select('test', 't')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->element(1)
->fields('t', array('name'))
->orderBy('age')
@ -2413,7 +2417,8 @@ class DatabaseSelectPagerDefaultTestCase extends DatabaseTestCase {
->fetchField();
$this->assertEqual($name, 'George', t('Pager query #2 with a specified element ID returned the correct results.'));
$name = db_select('test', 't')->extend('PagerDefault')
$name = db_select('test', 't')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->fields('t', array('name'))
->orderBy('age')
->limit(1)

View File

@ -345,7 +345,7 @@ class ImageToolkitGdTestCase extends WebTestBase {
'arguments' => array(90, 0xFF00FF), // Fuchsia background.
'width' => 20,
'height' => 40,
'corners' => array($this->fuchsia, $this->red, $this->green, $this->blue),
'corners' => array($this->transparent, $this->red, $this->green, $this->blue),
),
'rotate_transparent_5' => array(
'function' => 'rotate',
@ -379,7 +379,7 @@ class ImageToolkitGdTestCase extends WebTestBase {
array_fill(0, 3, 76) + array(3 => 0),
array_fill(0, 3, 149) + array(3 => 0),
array_fill(0, 3, 29) + array(3 => 0),
array_fill(0, 3, 0) + array(3 => 127)
array_fill(0, 3, 225) + array(3 => 127)
),
),
);
@ -394,11 +394,14 @@ class ImageToolkitGdTestCase extends WebTestBase {
continue 2;
}
// Transparent GIFs and the imagefilter function don't work together.
// There is a todo in image.gd.inc to correct this.
// All images should be converted to truecolor when loaded.
$image_truecolor = imageistruecolor($image->resource);
$this->assertTrue($image_truecolor, t('Image %file after load is a truecolor image.', array('%file' => $file)));
if ($image->info['extension'] == 'gif') {
if ($op == 'desaturate') {
$values['corners'][3] = $this->white;
// Transparent GIFs and the imagefilter function don't work together.
$values['corners'][3][3] = 0;
}
}
@ -424,30 +427,6 @@ class ImageToolkitGdTestCase extends WebTestBase {
if ($image->info['width'] != $values['width'] || $image->info['height'] != $values['height']) {
$correct_dimensions_object = FALSE;
}
// Now check each of the corners to ensure color correctness.
foreach ($values['corners'] as $key => $corner) {
// Get the location of the corner.
switch ($key) {
case 0:
$x = 0;
$y = 0;
break;
case 1:
$x = $values['width'] - 1;
$y = 0;
break;
case 2:
$x = $values['width'] - 1;
$y = $values['height'] - 1;
break;
case 3:
$x = 0;
$y = $values['height'] - 1;
break;
}
$color = $this->getPixelColor($image, $x, $y);
$correct_colors = $this->colorsAreEqual($color, $corner);
}
$directory = file_default_scheme() . '://imagetests';
file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
@ -455,9 +434,34 @@ class ImageToolkitGdTestCase extends WebTestBase {
$this->assertTrue($correct_dimensions_real, t('Image %file after %action action has proper dimensions.', array('%file' => $file, '%action' => $op)));
$this->assertTrue($correct_dimensions_object, t('Image %file object after %action action is reporting the proper height and width values.', array('%file' => $file, '%action' => $op)));
// JPEG colors will always be messed up due to compression.
if ($image->info['extension'] != 'jpg') {
$this->assertTrue($correct_colors, t('Image %file object after %action action has the correct color placement.', array('%file' => $file, '%action' => $op)));
// Now check each of the corners to ensure color correctness.
foreach ($values['corners'] as $key => $corner) {
// Get the location of the corner.
switch ($key) {
case 0:
$x = 0;
$y = 0;
break;
case 1:
$x = $values['width'] - 1;
$y = 0;
break;
case 2:
$x = $values['width'] - 1;
$y = $values['height'] - 1;
break;
case 3:
$x = 0;
$y = $values['height'] - 1;
break;
}
$color = $this->getPixelColor($image, $x, $y);
$correct_colors = $this->colorsAreEqual($color, $corner);
$this->assertTrue($correct_colors, t('Image %file object after %action action has the correct color placement at corner %corner.', array('%file' => $file, '%action' => $op, '%corner' => $key)));
}
}
}
}

View File

@ -105,7 +105,9 @@ function database_test_even_pager_query($limit) {
->orderBy('age');
// This should result in 2 pages of results.
$query = $query->extend('PagerDefault')->limit($limit);
$query = $query
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->limit($limit);
$names = $query->execute()->fetchCol();
@ -129,7 +131,9 @@ function database_test_odd_pager_query($limit) {
->orderBy('pid');
// This should result in 4 pages of results.
$query = $query->extend('PagerDefault')->limit($limit);
$query = $query
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->limit($limit);
$names = $query->execute()->fetchCol();
@ -213,7 +217,9 @@ function database_test_theme_tablesort($form, &$form_state) {
$count_query = clone $query;
$count_query->addExpression('COUNT(u.uid)');
$query = $query->extend('PagerDefault')->extend('TableSort');
$query = $query
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('TableSort');
$query
->fields('u', array('uid', 'name', 'status', 'created', 'access'))
->limit(50)

View File

@ -0,0 +1,63 @@
<?php
/**
* @file
* Database additions for role tests. Used in upgrade.roles.test.
*
* This dump only contains data and schema components relevant for role
* functionality. The drupal-7.bare.database.php file is imported before
* this dump, so the two form the database structure expected in tests
* altogether.
*/
db_insert('role')->fields(array(
'rid',
'name',
'weight',
))
// Adds a role with an umlaut in it.
->values(array(
'rid' => '4',
'name' => 'gärtner',
'weight' => '3',
))
// Adds a very long role name.
->values(array(
'rid' => '5',
'name' => 'very long role name that has exactly sixty-four characters in it',
'weight' => '4',
))
// Adds a very similar role name to test edge cases.
->values(array(
'rid' => '6',
'name' => 'very_long role name that has exactly sixty-four characters in it',
'weight' => '5',
))
->execute();
// Add the "Edit own comments" permission to the gärtner test role.
db_insert('role_permission')->fields(array(
'rid',
'permission',
'module',
))
->values(array(
'rid' => '4',
'permission' => 'edit own comments',
'module' => 'comment',
))
->execute();
// Adds some role visibility settings on the who's online block for the long
// role.
db_insert('block_role')->fields(array(
'module',
'delta',
'rid',
))
->values(array(
'module' => 'user',
'delta' => 'online',
'rid' => '5',
))
->execute();

View File

@ -0,0 +1,70 @@
<?php
/**
* @file
* Upgrade tests for the conversion of serial role IDs to role machine names.
*/
/**
* Tests upgrading a bare database with user role data.
*
* Loads a bare installation of Drupal 7 with role data and runs the
* upgrade process on it.
*/
class UserRoleUpgradePathTestCase extends UpgradePathTestCase {
public static function getInfo() {
return array(
'name' => 'Role upgrade test',
'description' => 'Upgrade tests with role data.',
'group' => 'Upgrade path',
);
}
public function setUp() {
$this->databaseDumpFiles = array(
drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.bare.standard_all.database.php.gz',
drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.roles.database.php',
);
parent::setUp();
}
/**
* Tests expected role ID conversions after a successful upgrade.
*/
public function testRoleUpgrade() {
$this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
// Check that "gärtner" has been converted to "4" and that the role
// edit page for it exists.
$this->drupalGet('admin/people/permissions/roles/edit/4');
$this->assertResponse(200, 'Role edit page for "gärtner" was found.');
// Check that the anonymous user role ID has been converted from "1" to
// "anonymous".
$this->drupalGet('admin/people/permissions/' . DRUPAL_ANONYMOUS_RID);
$this->assertResponse(200, 'Permission edit page for "anonymous" was found.');
// Check that the authenticated user role ID has been converted from "2" to
// "authenticated".
$this->drupalGet('admin/people/permissions/' . DRUPAL_AUTHENTICATED_RID);
$this->assertResponse(200, 'Permission edit page for "authenticated" was found.');
// Check that the permission for "gärtner" still exists.
$this->drupalGet('admin/people/permissions/4');
$this->assertFieldChecked('edit-4-edit-own-comments', 'Edit own comments permission for "gärtner" is set correctly.');
// Check that the role visibility setting for the who's online block still
// exists.
$this->drupalGet('admin/structure/block/manage/user/online/configure');
$this->assertFieldChecked('edit-roles-5', "Who's online block visibility setting is correctly set for the long role name.");
// Check that the role name is still displayed as expected.
$this->assertText('gärtner', 'Role name is displayed on block visibility settings.');
$this->assertText('very long role name that has exactly sixty-four characters in it', 'Role name is displayed on block visibility settings.');
$this->assertText('very_long role name that has exactly sixty-four characters in it', 'Role name is displayed on block visibility settings.');
// The administrative user role must still be assigned to the
// "administrator" role (rid 3).
$this->drupalGet('admin/config/people/accounts');
$this->assertFieldByName('user_admin_role', 3);
}
}

View File

@ -233,7 +233,7 @@ function taxonomy_select_nodes($tid, $pager = TRUE, $limit = FALSE, $order = arr
$count_query = clone $query;
$count_query->addExpression('COUNT(t.nid)');
$query = $query->extend('PagerDefault');
$query = $query->extend('Drupal\Core\Database\Query\PagerSelectExtender');
if ($limit !== FALSE) {
$query = $query->limit($limit);
}
@ -429,7 +429,7 @@ function taxonomy_term_access($op, $term) {
* Return the vocabulary name given the vocabulary object.
*/
function taxonomy_admin_vocabulary_title_callback(Vocabulary $vocabulary) {
return check_plain($vocabulary->name);
return $vocabulary->name;
}
/**

View File

@ -19,7 +19,8 @@
*/
function tracker_page($account = NULL, $set_title = FALSE) {
if ($account) {
$query = db_select('tracker_user', 't')->extend('PagerDefault');
$query = db_select('tracker_user', 't')
->extend('Drupal\Core\Database\Query\PagerSelectExtender');
$query->condition('t.uid', $account->uid);
if ($set_title) {
@ -30,7 +31,8 @@ function tracker_page($account = NULL, $set_title = FALSE) {
}
}
else {
$query = db_select('tracker_node', 't', array('target' => 'slave'))->extend('PagerDefault');
$query = db_select('tracker_node', 't', array('target' => 'slave'))
->extend('Drupal\Core\Database\Query\PagerSelectExtender');
}
// This array acts as a placeholder for the data selected later

View File

@ -55,7 +55,9 @@ class UserAdminTest extends WebTestBase {
$this->assertText($user_c->name, t('Found user C on filtered by perm admin users page'));
// Filter the users by role. Grab the system-generated role name for User C.
$edit['role'] = max(array_flip($user_c->roles));
$roles = $user_c->roles;
unset($roles[DRUPAL_AUTHENTICATED_RID]);
$edit['role'] = key($roles);
$this->drupalPost('admin/people', $edit, t('Refine'));
// Check if the correct users show up when filtered by role.

View File

@ -26,10 +26,10 @@ class UserPermissionsTest extends WebTestBase {
$this->admin_user = $this->drupalCreateUser(array('administer permissions', 'access user profiles', 'administer site configuration', 'administer modules', 'administer users'));
// Find the new role ID - it must be the maximum.
$all_rids = array_keys($this->admin_user->roles);
sort($all_rids);
$this->rid = array_pop($all_rids);
// Find the new role ID.
$all_rids = $this->admin_user->roles;
unset($all_rids[DRUPAL_AUTHENTICATED_RID]);
$this->rid = key($all_rids);
}
/**

View File

@ -37,38 +37,40 @@ class UserRoleAdminTest extends WebTestBase {
// correspond to an integer, to test that the role administration pages
// correctly distinguish between role names and IDs.)
$role_name = '123';
$edit = array('name' => $role_name);
$edit = array('role[name]' => $role_name, 'role[rid]' => $role_name);
$this->drupalPost('admin/people/permissions/roles', $edit, t('Add role'));
$this->assertText(t('The role has been added.'), t('The role has been added.'));
$role = user_role_load_by_name($role_name);
$role = user_role_load($role_name);
$this->assertTrue(is_object($role), t('The role was successfully retrieved from the database.'));
// Try adding a duplicate role.
$this->drupalPost(NULL, $edit, t('Add role'));
$this->assertRaw(t('The role name %name already exists. Choose another role name.', array('%name' => $role_name)), t('Duplicate role warning displayed.'));
$this->assertRaw(t('The machine-readable name is already in use. It must be unique.'), t('Duplicate role warning displayed.'));
// Test renaming a role.
$old_name = $role_name;
$role_name = '456';
$edit = array('name' => $role_name);
$edit = array('role[name]' => $role_name);
$this->drupalPost("admin/people/permissions/roles/edit/{$role->rid}", $edit, t('Save role'));
$this->assertText(t('The role has been renamed.'), t('The role has been renamed.'));
$this->assertFalse(user_role_load_by_name($old_name), t('The role can no longer be retrieved from the database using its old name.'));
$this->assertTrue(is_object(user_role_load_by_name($role_name)), t('The role can be retrieved from the database using its new name.'));
$new_role = user_role_load($old_name);
$this->assertEqual($new_role->name, $role_name, 'The role name has been successfully changed.');
// Test deleting a role.
$this->drupalPost("admin/people/permissions/roles/edit/{$role->rid}", NULL, t('Delete role'));
$this->drupalPost(NULL, NULL, t('Delete'));
$this->assertText(t('The role has been deleted.'), t('The role has been deleted'));
$this->assertNoLinkByHref("admin/people/permissions/roles/edit/{$role->rid}", t('Role edit link removed.'));
$this->assertFalse(user_role_load_by_name($role_name), t('A deleted role can no longer be loaded.'));
$this->assertFalse(user_role_load($role_name), t('A deleted role can no longer be loaded.'));
// Make sure that the system-defined roles cannot be edited via the user
// Make sure that the system-defined roles can be edited via the user
// interface.
$this->drupalGet('admin/people/permissions/roles/edit/' . DRUPAL_ANONYMOUS_RID);
$this->assertResponse(403, t('Access denied when trying to edit the built-in anonymous role.'));
$this->assertResponse(200, 'Access granted when trying to edit the built-in anonymous role.');
$this->assertNoText(t('Delete role'), 'Delete button for the anonymous role is not present.');
$this->drupalGet('admin/people/permissions/roles/edit/' . DRUPAL_AUTHENTICATED_RID);
$this->assertResponse(403, t('Access denied when trying to edit the built-in authenticated role.'));
$this->assertResponse(200, 'Access granted when trying to edit the built-in authenticated role.');
$this->assertNoText(t('Delete role'), 'Delete button for the authenticated role is not present.');
}
/**

View File

@ -4,12 +4,6 @@
padding-right: 1.5em;
}
#user-admin-roles .form-item-name {
float: right;
margin-left: 1em;
margin-right: 0;
}
/**
* Password strength indicator.
*/

View File

@ -158,7 +158,9 @@ function user_admin_account() {
$count_query = clone $query;
$count_query->addExpression('COUNT(u.uid)');
$query = $query->extend('PagerDefault')->extend('TableSort');
$query = $query
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('TableSort');
$query
->fields('u', array('uid', 'name', 'status', 'created', 'access'))
->limit(50)
@ -651,7 +653,7 @@ function user_admin_permissions($form, $form_state, $rid = NULL) {
// Retrieve role names for columns.
$role_names = user_roles();
if (is_numeric($rid)) {
if (isset($rid)) {
$role_names = array($rid => $role_names[$rid]);
}
// Fetch permissions for all roles or the one selected role.
@ -820,47 +822,62 @@ function theme_user_permission_description($variables) {
* @see theme_user_admin_roles()
*/
function user_admin_roles($form, $form_state) {
$roles = user_roles();
$roles = db_select('role', 'r')
->addTag('translatable')
->fields('r')
->orderBy('weight')
->orderBy('name')
->execute();
$form['roles'] = array(
'#tree' => TRUE,
);
$order = 0;
foreach ($roles as $rid => $name) {
$form['roles'][$rid]['#role'] = (object) array(
'rid' => $rid,
'name' => $name,
'weight' => $order,
$max_weight = 0;
foreach ($roles as $role) {
$max_weight = max($max_weight, $role->weight);
$form['roles'][$role->rid]['#role'] = $role;
$form['roles'][$role->rid]['#weight'] = $role->weight;
$form['roles'][$role->rid]['name'] = array(
'#markup' => check_plain($role->name),
);
$form['roles'][$rid]['#weight'] = $order;
$form['roles'][$rid]['weight'] = array(
$form['roles'][$role->rid]['weight'] = array(
'#type' => 'textfield',
'#title' => t('Weight for @title', array('@title' => $name)),
'#title' => t('Weight for @title', array('@title' => $role->name)),
'#title_display' => 'invisible',
'#size' => 4,
'#default_value' => $order,
'#default_value' => $role->weight,
'#attributes' => array('class' => array('role-weight')),
);
$order++;
$form['roles'][$role->rid]['edit'] = array(
'#type' => 'link',
'#title' => t('edit role'),
'#href' => 'admin/people/permissions/roles/edit/' . $role->rid,
);
$form['roles'][$role->rid]['permissions'] = array(
'#type' => 'link',
'#title' => t('edit permissions'),
'#href' => 'admin/people/permissions/' . $role->rid,
);
}
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#title_display' => 'invisible',
'#size' => 32,
'#maxlength' => 64,
// Embed the role add form.
$add_role = (object) array(
'rid' => NULL,
'name' => NULL,
'weight' => $max_weight + 1,
);
$form['add'] = array(
'#type' => 'submit',
'#value' => t('Add role'),
'#validate' => array('user_admin_role_validate'),
'#submit' => array('user_admin_role_submit'),
);
$form['actions'] = array('#type' => 'actions');
$add_form = user_admin_role(array(), $form_state, $add_role);
$add_form['actions']['submit']['#submit'] = array('user_admin_role_submit');
$add_form['role']['actions'] = $add_form['actions'];
unset($add_form['actions']);
$form += $add_form;
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save order'),
// Do not validate the add form when saving the order.
'#limit_validation_errors' => array(array('roles')),
'#submit' => array('user_admin_roles_order_submit'),
);
@ -893,23 +910,27 @@ function theme_user_admin_roles($variables) {
$header = array(t('Name'), t('Weight'), array('data' => t('Operations'), 'colspan' => 2));
foreach (element_children($form['roles']) as $rid) {
$name = $form['roles'][$rid]['#role']->name;
$row = array();
if (in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) {
$row[] = t('@name <em>(locked)</em>', array('@name' => $name));
$row[] = drupal_render($form['roles'][$rid]['weight']);
$row[] = '';
$row[] = l(t('edit permissions'), 'admin/people/permissions/' . $rid);
}
else {
$row[] = check_plain($name);
$row[] = drupal_render($form['roles'][$rid]['weight']);
$row[] = l(t('edit role'), 'admin/people/permissions/roles/edit/' . $rid);
$row[] = l(t('edit permissions'), 'admin/people/permissions/' . $rid);
foreach (element_children($form['roles'][$rid]) as $column) {
$row[] = drupal_render($form['roles'][$rid][$column]);
}
$rows[] = array('data' => $row, 'class' => array('draggable'));
}
$rows[] = array(array('data' => drupal_render($form['name']) . drupal_render($form['add']), 'colspan' => 4, 'class' => 'edit-name'));
// Distribute the role add form into table columns.
$form['role']['name']['#title_display'] = 'invisible';
unset($form['role']['name']['#description']);
unset($form['role']['rid']['#description']);
$actions = $form['role']['actions'];
unset($form['role']['actions']);
unset($form['role']['weight']);
$row = array();
$row[] = drupal_render($form['role']);
// Empty placeholder for the weight column.
$row[] = '';
$row[] = array('data' => drupal_render($actions), 'colspan' => 2);
$rows[] = array('data' => $row);
drupal_add_tabledrag('user-roles', 'order', 'sibling', 'role-weight');
@ -923,90 +944,74 @@ function theme_user_admin_roles($variables) {
* Form to configure a single role.
*
* @ingroup forms
* @see user_admin_role_validate()
* @see user_admin_role_submit()
*/
function user_admin_role($form, $form_state, $role) {
if ($role->rid == DRUPAL_ANONYMOUS_RID || $role->rid == DRUPAL_AUTHENTICATED_RID) {
drupal_goto('admin/people/permissions/roles');
}
$form['role'] = array(
'#tree' => TRUE,
'#parents' => array('role'),
);
// Display the edit role form.
$form['name'] = array(
$form['role']['name'] = array(
'#type' => 'textfield',
'#title' => t('Role name'),
'#default_value' => $role->name,
'#size' => 30,
'#required' => TRUE,
'#maxlength' => 64,
'#description' => t('The name for this role. Example: "moderator", "editorial board", "site architect".'),
'#description' => t('The name for this role. Example: "Moderator", "Editorial board", "Site architect".'),
);
$form['rid'] = array(
'#type' => 'value',
'#value' => $role->rid,
$form['role']['rid'] = array(
'#type' => 'machine_name',
'#default_value' => $role->rid,
'#required' => TRUE,
'#disabled' => !empty($role->rid),
'#size' => 30,
'#maxlength' => 64,
'#machine_name' => array(
'exists' => 'user_role_load',
'source' => array('role', 'name'),
),
);
$form['weight'] = array(
$form['role']['weight'] = array(
'#type' => 'value',
'#value' => $role->weight,
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save role'),
'#value' => !empty($role->rid) ? t('Save role') : t('Add role'),
);
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete role'),
'#access' => !empty($role->rid) && !in_array($role->rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID)),
'#submit' => array('user_admin_role_delete_submit'),
);
return $form;
}
/**
* Form validation handler for the user_admin_role() form.
*/
function user_admin_role_validate($form, &$form_state) {
if (!empty($form_state['values']['name'])) {
if ($form_state['values']['op'] == t('Save role')) {
$role = user_role_load_by_name($form_state['values']['name']);
if ($role && $role->rid != $form_state['values']['rid']) {
form_set_error('name', t('The role name %name already exists. Choose another role name.', array('%name' => $form_state['values']['name'])));
}
}
elseif ($form_state['values']['op'] == t('Add role')) {
if (user_role_load_by_name($form_state['values']['name'])) {
form_set_error('name', t('The role name %name already exists. Choose another role name.', array('%name' => $form_state['values']['name'])));
}
}
}
else {
form_set_error('name', t('You must specify a valid role name.'));
}
}
/**
* Form submit handler for the user_admin_role() form.
*/
function user_admin_role_submit($form, &$form_state) {
$role = (object) $form_state['values'];
if ($form_state['values']['op'] == t('Save role')) {
user_role_save($role);
$role = (object) $form_state['values']['role'];
$status = user_role_save($role);
if ($status === SAVED_UPDATED) {
drupal_set_message(t('The role has been renamed.'));
}
elseif ($form_state['values']['op'] == t('Add role')) {
user_role_save($role);
else {
drupal_set_message(t('The role has been added.'));
}
$form_state['redirect'] = 'admin/people/permissions/roles';
return;
}
/**
* Form submit handler for the user_admin_role() form.
*/
function user_admin_role_delete_submit($form, &$form_state) {
$form_state['redirect'] = 'admin/people/permissions/roles/delete/' . $form_state['values']['rid'];
$form_state['redirect'] = 'admin/people/permissions/roles/delete/' . $form_state['values']['role']['rid'];
}
/**
@ -1024,7 +1029,7 @@ function user_admin_role_delete_confirm($form, &$form_state, $role) {
* Form submit handler for user_admin_role_delete_confirm().
*/
function user_admin_role_delete_confirm_submit($form, &$form_state) {
user_role_delete((int) $form_state['values']['rid']);
user_role_delete($form_state['values']['rid']);
drupal_set_message(t('The role has been deleted.'));
$form_state['redirect'] = 'admin/people/permissions/roles';
}

View File

@ -14,18 +14,6 @@
padding-bottom: .5em;
}
/**
* Override default textfield float to put the "Add role" button next to
* the input textfield.
*/
#user-admin-roles td.edit-name {
clear: both;
}
#user-admin-roles .form-item-name {
float: left; /* LTR */
margin-right: 1em; /* LTR */
}
/**
* Password strength indicator.
*/

View File

@ -55,8 +55,8 @@ function user_schema() {
'description' => 'Stores the permissions assigned to user roles.',
'fields' => array(
'rid' => array(
'type' => 'int',
'unsigned' => TRUE,
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'description' => 'Foreign Key: {role}.rid.',
),
@ -81,7 +81,7 @@ function user_schema() {
),
'foreign keys' => array(
'role' => array(
'table' => 'roles',
'table' => 'role',
'columns' => array('rid' => 'rid'),
),
),
@ -91,17 +91,20 @@ function user_schema() {
'description' => 'Stores user roles.',
'fields' => array(
'rid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'type' => 'varchar',
// The role ID is often used as part of a compound index; at least MySQL
// has a maximum index length of 1000 characters (333 on utf8), so we
// limit the maximum length.
'length' => 64,
'not null' => TRUE,
'description' => 'Primary Key: Unique role ID.',
),
'name' => array(
'type' => 'varchar',
'length' => 64,
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Unique role name.',
'description' => 'Role label.',
'translatable' => TRUE,
),
'weight' => array(
@ -111,9 +114,6 @@ function user_schema() {
'description' => 'The weight of this role in listings and the user interface.',
),
),
'unique keys' => array(
'name' => array('name'),
),
'primary key' => array('rid'),
'indexes' => array(
'name_weight' => array('name', 'weight'),
@ -268,10 +268,9 @@ function user_schema() {
'description' => 'Primary Key: {users}.uid for user.',
),
'rid' => array(
'type' => 'int',
'unsigned' => TRUE,
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => 0,
'description' => 'Primary Key: {role}.rid for role.',
),
),
@ -285,7 +284,7 @@ function user_schema() {
'columns' => array('uid' => 'uid'),
),
'role' => array(
'table' => 'roles',
'table' => 'role',
'columns' => array('rid' => 'rid'),
),
),
@ -321,29 +320,12 @@ function user_install() {
))
->execute();
// Built-in roles.
$rid_anonymous = db_insert('role')
->fields(array('name' => 'anonymous user', 'weight' => 0))
// Insert built-in roles.
db_insert('role')
->fields(array('rid', 'name', 'weight'))
->values(array(DRUPAL_ANONYMOUS_RID, 'Anonymous user', 0))
->values(array(DRUPAL_AUTHENTICATED_RID, 'Authenticated user', 1))
->execute();
$rid_authenticated = db_insert('role')
->fields(array('name' => 'authenticated user', 'weight' => 1))
->execute();
// Sanity check to ensure the anonymous and authenticated role IDs are the
// same as the drupal defined constants. In certain situations, this will
// not be true.
if ($rid_anonymous != DRUPAL_ANONYMOUS_RID) {
db_update('role')
->fields(array('rid' => DRUPAL_ANONYMOUS_RID))
->condition('rid', $rid_anonymous)
->execute();
}
if ($rid_authenticated != DRUPAL_AUTHENTICATED_RID) {
db_update('role')
->fields(array('rid' => DRUPAL_AUTHENTICATED_RID))
->condition('rid', $rid_authenticated)
->execute();
}
}
/**
@ -398,6 +380,67 @@ function user_update_8001() {
db_update('users')->expression('langcode', 'preferred_langcode')->execute();
}
/**
* Replace serial role IDs with machine name strings.
*/
function user_update_8002() {
// Change serial rid columns into strings.
$column = array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'description' => 'Primary Key: Unique role ID.',
);
db_change_field('role', 'rid', 'rid', $column);
$column['description'] = 'Foreign Key: {role}.rid.';
db_change_field('role_permission', 'rid', 'rid', $column);
$column['description'] = 'Primary Key: {role}.rid for role.';
db_change_field('users_roles', 'rid', 'rid', $column);
// Enlarge the role name (label) column.
$column = array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Role label.',
'translatable' => TRUE,
);
db_change_field('role', 'name', 'name', $column);
// Remove unique index.
db_drop_unique_key('role', 'name');
// Rename the built-in serial role IDs into the hardcoded machine names.
db_update('role')
->fields(array('rid' => DRUPAL_ANONYMOUS_RID))
->condition('rid', 1)
->execute();
db_update('role')
->fields(array('rid' => DRUPAL_AUTHENTICATED_RID))
->condition('rid', 2)
->execute();
db_update('role_permission')
->fields(array('rid' => DRUPAL_ANONYMOUS_RID))
->condition('rid', 1)
->execute();
db_update('role_permission')
->fields(array('rid' => DRUPAL_AUTHENTICATED_RID))
->condition('rid', 2)
->execute();
db_update('users_roles')
->fields(array('rid' => DRUPAL_ANONYMOUS_RID))
->condition('rid', 1)
->execute();
db_update('users_roles')
->fields(array('rid' => DRUPAL_AUTHENTICATED_RID))
->condition('rid', 2)
->execute();
}
/**
* @} End of "addtogroup updates-7.x-to-8.x".
*/

View File

@ -641,7 +641,8 @@ function user_search_execute($keys = NULL, $conditions = NULL) {
$find = array();
// Replace wildcards with MySQL/PostgreSQL wildcards.
$keys = preg_replace('!\*+!', '%', $keys);
$query = db_select('users')->extend('PagerDefault');
$query = db_select('users')
->extend('Drupal\Core\Database\Query\PagerSelectExtender');
$query->fields('users', array('uid'));
if (user_access('administer users')) {
// Administrators can also search in the otherwise private email field.
@ -1568,14 +1569,13 @@ function user_menu() {
$items['admin/people/permissions/roles/edit/%user_role'] = array(
'title' => 'Edit role',
'page arguments' => array('user_admin_role', 5),
'access callback' => 'user_role_edit_access',
'access arguments' => array(5),
'access arguments' => array('administer permissions'),
);
$items['admin/people/permissions/roles/delete/%user_role'] = array(
'title' => 'Delete role',
'page callback' => 'drupal_get_form',
'page arguments' => array('user_admin_role_delete_confirm', 5),
'access callback' => 'user_role_edit_access',
'access callback' => 'user_role_delete_access',
'access arguments' => array(5),
'file' => 'user.admin.inc',
);
@ -2655,24 +2655,10 @@ function user_roles($membersonly = FALSE, $permission = NULL) {
$query->innerJoin('role_permission', 'p', 'r.rid = p.rid');
$query->condition('p.permission', $permission);
}
$result = $query->execute();
$roles = array();
foreach ($result as $role) {
switch ($role->rid) {
// We only translate the built in role names
case DRUPAL_ANONYMOUS_RID:
if (!$membersonly) {
$roles[$role->rid] = t($role->name);
}
break;
case DRUPAL_AUTHENTICATED_RID:
$roles[$role->rid] = t($role->name);
break;
default:
$roles[$role->rid] = $role->name;
}
if ($membersonly) {
$query->condition('r.rid', DRUPAL_ANONYMOUS_RID, '!=');
}
$roles = $query->execute()->fetchAllKeyed();
if (empty($permission)) {
$user_roles[$cid] = $roles;
@ -2686,13 +2672,11 @@ function user_roles($membersonly = FALSE, $permission = NULL) {
* Fetches a user role by role ID.
*
* @param $rid
* An integer representing the role ID.
* A string representing the role ID.
*
* @return
* A fully-loaded role object if a role with the given ID exists, or FALSE
* otherwise.
*
* @see user_role_load_by_name()
*/
function user_role_load($rid) {
return db_select('role', 'r')
@ -2702,35 +2686,15 @@ function user_role_load($rid) {
->fetchObject();
}
/**
* Fetches a user role by role name.
*
* @param $role_name
* A string representing the role name.
*
* @return
* A fully-loaded role object if a role with the given name exists, or FALSE
* otherwise.
*
* @see user_role_load()
*/
function user_role_load_by_name($role_name) {
return db_select('role', 'r')
->fields('r')
->condition('name', $role_name)
->execute()
->fetchObject();
}
/**
* Save a user role to the database.
*
* @param $role
* A role object to modify or add. If $role->rid is not specified, a new
* role will be created.
* A role object to modify or add.
*
* @return
* Status constant indicating if role was created or updated.
* Failure to write the user role record will return FALSE. Otherwise.
* Failure to write the user role record will return FALSE. Otherwise
* SAVED_NEW or SAVED_UPDATED is returned depending on the operation
* performed.
*/
@ -2749,14 +2713,20 @@ function user_role_save($role) {
// Let modules modify the user role before it is saved to the database.
module_invoke_all('user_role_presave', $role);
if (!empty($role->rid) && $role->name) {
$status = drupal_write_record('role', $role, 'rid');
module_invoke_all('user_role_update', $role);
}
else {
$exists = db_select('role', 'r')
->fields('r', array('rid'))
->condition('rid', $role->rid)
->execute()
->fetchAll();
if (empty($exists)) {
$status = drupal_write_record('role', $role);
module_invoke_all('user_role_insert', $role);
}
else {
$status = drupal_write_record('role', $role, 'rid');
module_invoke_all('user_role_update', $role);
}
// Clear the user access cache.
drupal_static_reset('user_access');
@ -2769,15 +2739,10 @@ function user_role_save($role) {
* Delete a user role from database.
*
* @param $role
* A string with the role name, or an integer with the role ID.
* A string with the role ID.
*/
function user_role_delete($role) {
if (is_int($role)) {
$role = user_role_load($role);
}
else {
$role = user_role_load_by_name($role);
}
$role = user_role_load($role);
db_delete('role')
->condition('rid', $role->rid)
@ -2798,10 +2763,10 @@ function user_role_delete($role) {
}
/**
* Menu access callback for user role editing.
* Menu access callback for user role deletion.
*/
function user_role_edit_access($role) {
// Prevent the system-defined roles from being altered or removed.
function user_role_delete_access($role) {
// Prevent the system-defined roles from being removed.
if ($role->rid == DRUPAL_ANONYMOUS_RID || $role->rid == DRUPAL_AUTHENTICATED_RID) {
return FALSE;
}

View File

@ -32,12 +32,12 @@ Drupal.behaviors.permissions = {
.attr('title', Drupal.t("This permission is inherited from the authenticated user role."))
.hide();
$table.find('input[type=checkbox]').not('.rid-2, .rid-1').addClass('real-checkbox').each(function () {
$table.find('input[type=checkbox]').not('.rid-anonymous, .rid-authenticated').addClass('real-checkbox').each(function () {
$dummy.clone().insertAfter(this);
});
// Initialize the authenticated user checkbox.
$table.find('input[type=checkbox].rid-2')
$table.find('input[type=checkbox].rid-authenticated')
.bind('click.permissions', self.toggle)
// .triggerHandler() cannot be used here, as it only affects the first
// element.

View File

@ -409,7 +409,8 @@ function standard_install() {
// Create a default role for site administrators, with all available permissions assigned.
$admin_role = new stdClass();
$admin_role->name = 'administrator';
$admin_role->rid = 'administrator';
$admin_role->name = 'Administrator';
$admin_role->weight = 2;
user_role_save($admin_role);
user_role_grant_permissions($admin_role->rid, array_keys(module_invoke_all('permission')));

View File

@ -4,4 +4,3 @@ package = Testing
version = VERSION
core = 8.x
hidden = TRUE
files[] = drupal_system_listing_compatible_test.test

View File

@ -1,12 +1,17 @@
<?php
/**
* Definition of Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest.
*/
namespace Drupal\drupal_system_listing_compatible_test\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Helper to verify tests in installation profile modules.
*/
class DrupalSystemListingCompatibleTestCase extends WebTestBase {
class SystemListingCompatibleTest extends WebTestBase {
/**
* Use the Minimal profile.
*
@ -34,7 +39,7 @@ class DrupalSystemListingCompatibleTestCase extends WebTestBase {
/**
* Non-empty test* method required to executed the test case class.
*/
function testDrupalSystemListing() {
function testSystemListing() {
$this->pass(__CLASS__ . ' test executed.');
}
}