Commit e81a2d35 authored by Dries's avatar Dries

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

parents 6ef87658 bd07cedb
......@@ -2564,7 +2564,7 @@ function drupal_fast_404() {
$fast_paths = variable_get('404_fast_paths', FALSE);
if ($fast_paths && preg_match($fast_paths, request_path())) {
drupal_add_http_header('Status', '404 Not Found');
$fast_404_html = variable_get('404_fast_html', '<html xmlns="http://www.w3.org/1999/xhtml"><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>');
$fast_404_html = variable_get('404_fast_html', '<!DOCTYPE html><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>');
// Replace @path in the variable with the page path.
print strtr($fast_404_html, array('@path' => check_plain(request_uri())));
exit;
......
......@@ -76,6 +76,11 @@
*/
const CSS_THEME = 100;
/**
* The default group for JavaScript settings added to the page.
*/
const JS_SETTING = -200;
/**
* The default group for JavaScript and jQuery libraries added to the page.
*/
......@@ -91,11 +96,6 @@
*/
const JS_THEME = 100;
/**
* The default group for JavaScript settings added to the page.
*/
const JS_SETTING = 200;
/**
* Error code indicating that the request exceeded the specified timeout.
*
......@@ -3528,7 +3528,8 @@ function drupal_html_id($id) {
// requested id. $_POST['ajax_html_ids'] contains the ids as they were
// returned by this function, potentially with the appended counter, so
// we parse that to reconstruct the $seen_ids array.
foreach ($_POST['ajax_html_ids'] as $seen_id) {
$ajax_html_ids = explode(' ', $_POST['ajax_html_ids']);
foreach ($ajax_html_ids as $seen_id) {
// We rely on '--' being used solely for separating a base id from the
// counter, which this function ensures when returning an id.
$parts = explode('--', $seen_id, 2);
......@@ -4037,7 +4038,7 @@ function drupal_pre_render_scripts($elements) {
switch ($item['type']) {
case 'setting':
$element['#value_prefix'] = $embed_prefix;
$element['#value'] = 'jQuery.extend(Drupal.settings, ' . drupal_json_encode(drupal_array_merge_deep_array($item['data'])) . ");";
$element['#value'] = 'var drupalSettings = ' . drupal_json_encode(drupal_array_merge_deep_array($item['data'])) . ";";
$element['#value_suffix'] = $embed_suffix;
break;
......
......@@ -4590,7 +4590,7 @@ function _form_set_class(&$element, $class = array()) {
$element['#attributes']['required'] = 'required';
$element['#attributes']['aria-required'] = 'true';
}
if (isset($element['#parents']) && form_get_error($element)) {
if (isset($element['#parents']) && form_get_error($element) !== NULL) {
$element['#attributes']['class'][] = 'error';
}
}
......
......@@ -284,10 +284,13 @@ Drupal.ajax.prototype.beforeSerialize = function (element, options) {
// Prevent duplicate HTML ids in the returned markup.
// @see drupal_html_id()
options.data['ajax_html_ids[]'] = [];
$('[id]').each(function () {
options.data['ajax_html_ids[]'].push(this.id);
});
var ids = document.querySelectorAll('[id]');
var ajaxHtmlIds = [];
for (var i = 0, il = ids.length; i < il; i++) {
ajaxHtmlIds.push(ids[i].id);
}
// Join IDs to minimize request size.
options.data.ajax_html_ids = ajaxHtmlIds.join(' ');
// Allow Drupal to return new JavaScript and CSS files to load without
// returning the ones already loaded.
......
var Drupal = Drupal || { 'settings': {}, 'behaviors': {}, 'locale': {} };
var Drupal = Drupal || { 'behaviors': {}, 'locale': {} };
// Allow other JavaScript libraries to use $.
jQuery.noConflict();
// JavaScript should be made compatible with libraries other than jQuery by
// wrapping it in an anonymous closure.
(function ($, Drupal, window, document, undefined) {
(function ($, Drupal, drupalSettings) {
"use strict";
// Populate Drupal.settings with the drupalSettings variable.
Drupal.settings = drupalSettings;
/**
* Custom error type thrown after attach/detach if one or more behaviors failed.
*
......@@ -71,7 +74,7 @@ DrupalBehaviorError.prototype = new Error();
*/
Drupal.attachBehaviors = function (context, settings) {
context = context || document;
settings = settings || Drupal.settings;
settings = settings || drupalSettings;
var i, errors = [], behaviors = Drupal.behaviors;
// Execute all of them.
for (i in behaviors) {
......@@ -133,7 +136,7 @@ Drupal.attachBehaviors = function (context, settings) {
*/
Drupal.detachBehaviors = function (context, settings, trigger) {
context = context || document;
settings = settings || Drupal.settings;
settings = settings || drupalSettings;
trigger = trigger || 'unload';
var i, errors = [], behaviors = Drupal.behaviors;
// Execute all of them.
......@@ -159,7 +162,7 @@ Drupal.detachBehaviors = function (context, settings, trigger) {
* @todo Temporary solution for the mobile initiative.
*/
Drupal.checkWidthBreakpoint = function (width) {
width = width || Drupal.settings.widthBreakpoint || 640;
width = width || drupalSettings.widthBreakpoint || 640;
return (document.documentElement.clientWidth > width);
};
......@@ -259,7 +262,7 @@ Drupal.t = function (str, args, options) {
* Returns the URL to a Drupal page.
*/
Drupal.url = function (path) {
return Drupal.settings.basePath + Drupal.settings.scriptPath + path;
return drupalSettings.basePath + drupalSettings.scriptPath + path;
};
/**
......@@ -434,7 +437,7 @@ $('html').addClass('js');
//Attach all behaviors.
$(function () {
Drupal.attachBehaviors(document, Drupal.settings);
Drupal.attachBehaviors(document, drupalSettings);
});
/**
......@@ -455,4 +458,4 @@ $.extend(Drupal.theme, {
}
});
})(jQuery, Drupal, this, this.document);
})(jQuery, Drupal, window.drupalSettings);
......@@ -285,7 +285,8 @@ function block_admin_configure($form, &$form_state, $module, $delta) {
$form['settings']['title'] = array(
'#type' => 'textfield',
'#title' => t('Block title'),
'#maxlength' => 64,
'#maxlength' => 255,
'#size' => 60,
'#description' => $block->module == 'block' ? t('The title of the block as shown to the user.') : t('Override the default title for the block. Use <em>!placeholder</em> to display no title, or leave blank to use the default block title.', array('!placeholder' => '&lt;none&gt;')),
'#default_value' => isset($block->title) ? $block->title : '',
'#weight' => -19,
......
......@@ -79,7 +79,7 @@ function block_schema() {
),
'title' => array(
'type' => 'varchar',
'length' => 64,
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Custom title for the block. (Empty string will use block default title, <none> will remove the title, text will cause block to use specified title.)',
......@@ -311,6 +311,21 @@ function block_update_8002() {
->execute();
}
/**
* Increase {block}.title length to 255 characters.
*/
function block_update_8003() {
db_change_field('block', 'title', 'title', array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Custom title for the block. (Empty string will use block default title, <none> will remove the title, text will cause block to use specified title.)',
'translatable' => TRUE,
)
);
}
/**
* @} End of "addtogroup updates-7.x-to-8.x".
* The next series of updates should start at 9000.
......
......@@ -771,7 +771,7 @@ function color_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
array('system', 'jquery.once'),
),
);
......
......@@ -397,7 +397,7 @@ function field_ui_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
array('system', 'jquery.once'),
),
);
......
......@@ -1710,7 +1710,7 @@ function file_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
),
);
......
......@@ -466,7 +466,7 @@ function locale_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
),
);
......
......@@ -62,24 +62,24 @@ public function testCommentPager() {
// View the node page. With the default 50 comments per page there should
// be two pages (0, 1) but no third (2) page.
$this->drupalGet('node/' . $node->nid);
$this->assertText($node->label(), t('Node title found.'));
$this->assertText(t('Comments'), t('Has a comments section.'));
$this->assertRaw('page=1', t('Secound page exists.'));
$this->assertNoRaw('page=2', t('No third page exists.'));
$this->assertText($node->label());
$this->assertText(t('Comments'));
$this->assertRaw('page=1');
$this->assertNoRaw('page=2');
}
/**
* Tests the forum node pager for nodes with multiple grants per realm.
*/
public function testForumPager() {
// Lookup the forums vocabulary vid.
// Look up the forums vocabulary ID.
$vid = config('forum.settings')->get('vocabulary');
$this->assertTrue($vid, t('Forum navigation vocabulary found.'));
$this->assertTrue($vid, 'Forum navigation vocabulary ID is set.');
// Lookup the general discussion term.
// Look up the general discussion term.
$tree = taxonomy_get_tree($vid, 0, 1);
$tid = reset($tree)->tid;
$this->assertTrue($tid, t('General discussion term found.'));
$this->assertTrue($tid, 'General discussion term is found in the forum vocabulary.');
// Create 30 nodes.
for ($i = 0; $i < 30; $i++) {
......@@ -98,7 +98,7 @@ public function testForumPager() {
// page there should be two pages for 30 nodes, no more.
$this->drupalLogin($this->web_user);
$this->drupalGet('forum/' . $tid);
$this->assertRaw('page=1', t('Secound page exists.'));
$this->assertNoRaw('page=2', t('No third page exists.'));
$this->assertRaw('page=1');
$this->assertNoRaw('page=2');
}
}
......@@ -4054,7 +4054,7 @@ function node_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
array('system', 'drupal.form'),
),
);
......
......@@ -213,7 +213,7 @@ function overlay_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
array('system', 'jquery.ui.core'),
array('system', 'jquery.bbq'),
),
......@@ -232,7 +232,7 @@ function overlay_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
array('system', 'jquery.once'),
),
);
......
......@@ -1284,9 +1284,12 @@ protected function drupalPostAJAX($path, $edit, $triggering_element, $ajax_path
$extra_post .= '&' . urlencode($key) . '=' . urlencode($value);
}
}
$ajax_html_ids = array();
foreach ($this->xpath('//*[@id]') as $element) {
$id = (string) $element['id'];
$extra_post .= '&' . urlencode('ajax_html_ids[]') . '=' . urlencode($id);
$ajax_html_ids[] = (string) $element['id'];
}
if (!empty($ajax_html_ids)) {
$extra_post .= '&' . urlencode('ajax_html_ids') . '=' . urlencode(implode(' ', $ajax_html_ids));
}
if (isset($drupal_settings['ajaxPageState'])) {
$extra_post .= '&' . urlencode('ajax_page_state[theme]') . '=' . urlencode($drupal_settings['ajaxPageState']['theme']);
......@@ -1985,7 +1988,7 @@ protected function drupalSetContent($content, $url = 'internal:') {
$this->plainTextContent = FALSE;
$this->elements = FALSE;
$this->drupalSettings = array();
if (preg_match('/jQuery\.extend\(Drupal\.settings, (.*?)\);/', $content, $matches)) {
if (preg_match('/var drupalSettings = (.*?);/', $content, $matches)) {
$this->drupalSettings = drupal_json_decode($matches[1]);
}
}
......
......@@ -551,7 +551,7 @@ function simpletest_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
array('system', 'jquery.once'),
array('system', 'drupal.tableselect'),
),
......
......@@ -474,7 +474,7 @@ function statistics_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
),
);
......
......@@ -76,7 +76,7 @@ function testAddFile() {
*/
function testAddSetting() {
// Add a file in order to test default settings.
drupal_add_library('system', 'drupal.settings');
drupal_add_library('system', 'drupalSettings');
$javascript = drupal_add_js();
$last_settings = reset($javascript['settings']['data']);
$this->assertTrue($last_settings['currentPath'], 'The current path JavaScript setting is set correctly.');
......@@ -136,15 +136,13 @@ function testDeferAttribute() {
* Test drupal_get_js() for JavaScript settings.
*/
function testHeaderSetting() {
drupal_add_library('system', 'drupal.settings');
drupal_add_library('system', 'drupalSettings');
$javascript = drupal_get_js('header');
$this->assertTrue(strpos($javascript, 'basePath') > 0, 'Rendered JavaScript header returns basePath setting.');
$this->assertTrue(strpos($javascript, 'scriptPath') > 0, 'Rendered JavaScript header returns scriptPath setting.');
$this->assertTrue(strpos($javascript, 'pathPrefix') > 0, 'Rendered JavaScript header returns pathPrefix setting.');
$this->assertTrue(strpos($javascript, 'currentPath') > 0, 'Rendered JavaScript header returns currentPath setting.');
$this->assertTrue(strpos($javascript, 'core/misc/drupal.js') > 0, 'Rendered JavaScript header includes Drupal.js.');
$this->assertTrue(strpos($javascript, 'core/misc/jquery.js') > 0, 'Rendered JavaScript header includes jQuery.');
// Only the second of these two entries should appear in Drupal.settings.
drupal_add_js(array('commonTest' => 'commonTestShouldNotAppear'), 'setting');
......@@ -173,11 +171,11 @@ function testHeaderSetting() {
$this->assertTrue($associative_array_override, t('drupal_add_js() correctly overrides settings within an associative array.'));
// Check in a rendered page.
$this->drupalGet('common-test/query-string');
$this->assertPattern('@<script>.+Drupal\.settings.+"currentPath":"common-test\\\/query-string"@s', 'currentPath is in the JS settings');
$this->assertPattern('@<script>.+drupalSettings.+"currentPath":"common-test\\\/query-string"@s', 'currentPath is in the JS settings');
$path = array('source' => 'common-test/query-string', 'alias' => 'common-test/currentpath-check');
path_save($path);
$this->drupalGet('common-test/currentpath-check');
$this->assertPattern('@<script>.+Drupal\.settings.+"currentPath":"common-test\\\/query-string"@s', 'currentPath is in the JS settings for an aliased path');
$this->assertPattern('@<script>.+drupalSettings.+"currentPath":"common-test\\\/query-string"@s', 'currentPath is in the JS settings for an aliased path');
}
/**
......
......@@ -219,6 +219,38 @@ function testRequiredCheckboxesRadio() {
$this->assertRaw("The form_test_validate_required_form form was submitted successfully.", 'Validation form submitted successfully.');
}
/**
* Tests validation for required textfield element without title.
*
* Submits a test form containing a textfield form element without title.
* The form is submitted twice, first without value for the required field
* and then with value. Each submission is checked for relevant error
* messages.
*
* @see form_test_validate_required_form_no_title()
*/
function testRequiredTextfieldNoTitle() {
$form = $form_state = array();
$form = form_test_validate_required_form_no_title($form, $form_state);
// Attempt to submit the form with no required field set.
$edit = array();
$this->drupalPost('form-test/validate-required-no-title', $edit, 'Submit');
$this->assertNoRaw("The form_test_validate_required_form_no_title form was submitted successfully.", 'Validation form submitted successfully.');
// Check the page for the error class on the textfield.
$this->assertFieldByXPath('//input[contains(@class, "error")]', FALSE, 'Error input form element class found.');
// Submit again with required fields set and verify that there are no
// error messages.
$edit = array(
'textfield' => $this->randomString(),
);
$this->drupalPost(NULL, $edit, 'Submit');
$this->assertNoFieldByXpath('//input[contains(@class, "error")]', FALSE, 'No error input form element class found.');
$this->assertRaw("The form_test_validate_required_form_no_title form was submitted successfully.", 'Validation form submitted successfully.');
}
/**
* Test default value handling for checkboxes.
*
......
......@@ -1187,16 +1187,12 @@ function system_library_info() {
);
// Drupal settings.
$libraries['drupal.settings'] = array(
$libraries['drupalSettings'] = array(
'title' => 'Drupal Settings',
'version' => VERSION,
'js' => array(
array('type' => 'setting', 'data' => array()),
),
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
),
);
// Drupal's Ajax framework.
......@@ -1210,7 +1206,7 @@ function system_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
array('system', 'drupal.progress'),
),
);
......@@ -1225,7 +1221,7 @@ function system_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
array('system', 'drupal.progress'),
array('system', 'jquery.once'),
),
......@@ -1241,7 +1237,7 @@ function system_library_info() {
'dependencies' => array(
array('system', 'drupal'),
array('system', 'jquery'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
),
);
......@@ -1270,7 +1266,7 @@ function system_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
array('system', 'jquery.once'),
),
);
......@@ -1285,7 +1281,7 @@ function system_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
array('system', 'jquery.once'),
array('system', 'jquery.cookie'),
),
......@@ -1384,7 +1380,7 @@ function system_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
// Vertical tabs relies on drupalGetSummary in form.js
array('system', 'drupal.form'),
),
......@@ -1891,7 +1887,7 @@ function system_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
array('system', 'jquery.once'),
),
);
......@@ -1916,7 +1912,7 @@ function system_library_info() {
array('system', 'jquery'),
array('system', 'jquery.once'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
),
);
......@@ -1929,7 +1925,7 @@ function system_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
),
);
$libraries['drupal.system.cron'] = array(
......@@ -1941,7 +1937,7 @@ function system_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
array('system', 'jquery.once'),
),
);
......
......@@ -272,7 +272,7 @@ function common_test_library_info() {
* Adds a JavaScript file and a CSS file with a query string appended.
*/
function common_test_js_and_css_querystring() {
drupal_add_library('system', 'drupal.settings');
drupal_add_library('system', 'drupalSettings');
drupal_add_js(drupal_get_path('module', 'node') . '/node.js');
drupal_add_css(drupal_get_path('module', 'node') . '/node.admin.css');
// A relative URI may have a query string.
......
......@@ -30,6 +30,13 @@ function form_test_menu() {
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items['form-test/validate-required-no-title'] = array(
'title' => 'Form #required validation without #title',
'page callback' => 'drupal_get_form',
'page arguments' => array('form_test_validate_required_form_no_title'),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
$items['form-test/limit-validation-errors'] = array(
'title' => 'Form validation with some error suppression',
'page callback' => 'drupal_get_form',
......@@ -488,6 +495,26 @@ function form_test_validate_required_form_submit($form, &$form_state) {
drupal_set_message('The form_test_validate_required_form form was submitted successfully.');
}
/**
* Form constructor to test the #required property without #title.
*/
function form_test_validate_required_form_no_title($form, &$form_state) {
$form['textfield'] = array(
'#type' => 'textfield',
'#required' => TRUE,
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array('#type' => 'submit', '#value' => 'Submit');
return $form;
}
/**
* Form submission handler for form_test_validate_required_form_no_title().
*/
function form_test_validate_required_form_no_title_submit($form, &$form_state) {
drupal_set_message('The form_test_validate_required_form_no_title form was submitted successfully.');
}
/**
* Builds a simple form with a button triggering partial validation.
*/
......
......@@ -1798,7 +1798,7 @@ function taxonomy_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
array('system', 'drupal.tabledrag'),
),
);
......
......@@ -374,7 +374,7 @@ function toolbar_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
array('system', 'jquery.once'),
array('system', 'jquery.cookie'),
),
......
......@@ -3147,7 +3147,7 @@ function user_library_info() {
'dependencies' => array(
array('system', 'jquery'),
array('system', 'drupal'),
array('system', 'drupal.settings'),
array('system', 'drupalSettings'),
),
);
......
......@@ -519,7 +519,7 @@
*/
$conf['404_fast_paths_exclude'] = '/\/(?:styles)\//';
$conf['404_fast_paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i';
$conf['404_fast_html'] = '<!DOCTYPE html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>';
$conf['404_fast_html'] = '<!DOCTYPE html><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>';
/**
* By default, fast 404s are returned as part of the normal page request
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment