core/authorize.php | 2 +- core/includes/actions.inc | 11 +- core/includes/ajax.inc | 11 +- core/includes/authorize.inc | 7 +- core/includes/batch.inc | 22 ++- core/includes/bootstrap.inc | 53 ++++--- core/includes/cache.inc | 1 + core/includes/common.inc | 82 ++++++----- core/includes/database/database.inc | 8 +- core/includes/database/select.inc | 7 +- core/includes/errors.inc | 6 +- core/includes/file.inc | 17 ++- core/includes/filetransfer/ftp.inc | 7 +- core/includes/form.inc | 34 +++-- core/includes/gettext.inc | 4 +- core/includes/image.inc | 4 +- core/includes/install.core.inc | 16 +- core/includes/install.inc | 6 +- core/includes/language.inc | 10 +- core/includes/lock.inc | 2 +- core/includes/mail.inc | 15 +- core/includes/menu.inc | 28 ++-- core/includes/module.inc | 28 ++-- core/includes/path.inc | 4 +- core/includes/session.inc | 2 +- core/includes/stream_wrappers.inc | 4 +- core/includes/theme.inc | 44 +++--- core/includes/theme.maintenance.inc | 2 +- core/includes/token.inc | 2 +- core/includes/unicode.inc | 8 +- core/includes/update.inc | 12 +- core/includes/updater.inc | 5 +- core/includes/uuid.inc | 2 +- core/includes/xmlrpc.inc | 4 +- core/includes/xmlrpcs.inc | 2 +- core/modules/aggregator/aggregator.admin.inc | 6 +- core/modules/aggregator/aggregator.module | 2 +- core/modules/aggregator/aggregator.parser.inc | 4 +- core/modules/aggregator/aggregator.processor.inc | 6 +- core/modules/block/block.admin.inc | 6 +- core/modules/book/book.module | 2 +- core/modules/book/book.pages.inc | 2 +- core/modules/color/color.module | 2 +- core/modules/entity/entity.class.inc | 21 ++- core/modules/entity/entity.controller.inc | 13 +- core/modules/entity/entity.module | 11 +- core/modules/entity/entity.query.inc | 7 +- .../entity/tests/entity_crud_hook_test.test | 168 ++++++++++---------- core/modules/entity/tests/entity_query.test | 4 +- core/modules/field/field.attach.inc | 18 +- core/modules/field/field.crud.inc | 4 +- core/modules/field/field.default.inc | 4 +- core/modules/field/field.form.inc | 8 +- core/modules/field/field.module | 8 +- .../field_sql_storage/field_sql_storage.module | 6 +- core/modules/field/modules/list/list.module | 4 +- core/modules/field/modules/number/number.module | 4 +- core/modules/field/tests/field.test | 6 +- core/modules/field/tests/field_test.entity.inc | 2 +- core/modules/field/tests/field_test.storage.inc | 2 +- core/modules/field_ui/field_ui.admin.inc | 12 +- core/modules/field_ui/field_ui.module | 2 +- core/modules/file/file.field.inc | 2 +- core/modules/filter/filter.admin.inc | 6 +- core/modules/filter/filter.module | 15 +- core/modules/filter/filter.test | 6 +- core/modules/help/help.test | 2 +- core/modules/image/image.admin.inc | 2 +- core/modules/image/image.module | 7 +- core/modules/locale/locale.module | 1 + core/modules/locale/locale.test | 14 +- core/modules/node/node.admin.inc | 4 +- core/modules/node/node.module | 12 +- core/modules/node/node.pages.inc | 6 +- core/modules/openid/openid.inc | 3 +- core/modules/openid/openid.module | 3 +- core/modules/openid/tests/openid_test.module | 2 +- core/modules/overlay/overlay.module | 10 +- core/modules/poll/poll.module | 2 +- core/modules/rdf/rdf.module | 4 +- core/modules/search/search.module | 16 +- core/modules/search/search.pages.inc | 2 +- core/modules/simpletest/drupal_web_test_case.php | 4 +- core/modules/simpletest/files/php-2.php | 1 - core/modules/simpletest/simpletest.module | 9 +- core/modules/simpletest/simpletest.pages.inc | 8 +- core/modules/simpletest/tests/batch_test.module | 2 +- core/modules/simpletest/tests/common.test | 24 ++-- core/modules/simpletest/tests/database_test.test | 2 +- core/modules/simpletest/tests/error.test | 10 +- core/modules/simpletest/tests/file.test | 8 +- core/modules/simpletest/tests/image.test | 4 +- core/modules/simpletest/tests/module.test | 2 +- core/modules/simpletest/tests/system_test.module | 4 +- .../tests/upgrade/drupal-7.bare.database.php.gz | Bin 59294 -> 57429 bytes .../tests/upgrade/drupal-7.filled.database.php.gz | Bin 78373 -> 75472 bytes core/modules/system/system.admin.inc | 34 ++-- core/modules/system/system.api.php | 4 +- core/modules/system/system.install | 2 +- core/modules/system/system.module | 2 +- core/modules/system/system.queue.inc | 3 +- core/modules/taxonomy/taxonomy.admin.inc | 2 +- core/modules/taxonomy/taxonomy.module | 2 +- core/modules/tracker/tracker.pages.inc | 2 +- core/modules/update/update.install | 2 +- core/modules/update/update.manager.inc | 2 +- core/modules/user/user.admin.inc | 6 +- core/modules/user/user.module | 8 +- core/scripts/password-hash.sh | 1 + core/themes/seven/maintenance-page.tpl.php | 3 + core/themes/seven/page.tpl.php | 3 + core/update.php | 2 +- sites/default/default.settings.php | 3 +- 113 files changed, 575 insertions(+), 509 deletions(-) diff --git a/core/authorize.php b/core/authorize.php index f0b95c8..829c385 100644 --- a/core/authorize.php +++ b/core/authorize.php @@ -36,7 +36,7 @@ define('ROOT', getcwd()); * solve some theming issues. This flag is checked on several places * in Drupal code (not just authorize.php). */ -const MAINTENANCE_MODE = 'update'; +define('MAINTENANCE_MODE', 'update'); /** * Renders a 403 access denied page for authorize.php. diff --git a/core/includes/actions.inc b/core/includes/actions.inc index 08f56f5..5c22fd5 100644 --- a/core/includes/actions.inc +++ b/core/includes/actions.inc @@ -100,7 +100,7 @@ function actions_do($action_ids, $object = NULL, $context = NULL, $a1 = NULL, $a foreach ($actions as $action_id => $params) { // Configurable actions need parameters. if (is_numeric($action_id)) { - $function = $params['callback']; + $function = 'drupal\\' . $params['callback']; if (function_exists($function)) { $context = array_merge($context, $params); $actions_result[$action_id] = $function($object, $context, $a1, $a2); @@ -111,7 +111,7 @@ function actions_do($action_ids, $object = NULL, $context = NULL, $a1 = NULL, $a } // Singleton action; $action_id is the function name. else { - $actions_result[$action_id] = $action_id($object, $context, $a1, $a2); + $actions_result[$action_id] = call_user_func('drupal\\' . $action_id, $object, $context, $a1, $a2); } } } @@ -120,7 +120,7 @@ function actions_do($action_ids, $object = NULL, $context = NULL, $a1 = NULL, $a // If it's a configurable action, retrieve stored parameters. if (is_numeric($action_ids)) { $action = db_query("SELECT callback, parameters FROM {actions} WHERE aid = :aid", array(':aid' => $action_ids))->fetchObject(); - $function = $action->callback; + $function = 'drupal\\' . $action->callback; if (function_exists($function)) { $context = array_merge($context, unserialize($action->parameters)); $actions_result[$action_ids] = $function($object, $context, $a1, $a2); @@ -131,8 +131,9 @@ function actions_do($action_ids, $object = NULL, $context = NULL, $a1 = NULL, $a } // Singleton action; $action_ids is the function name. else { - if (function_exists($action_ids)) { - $actions_result[$action_ids] = $action_ids($object, $context, $a1, $a2); + $function = 'drupal\\' . $action_ids; + if (function_exists($function)) { + $actions_result[$action_ids] = $function($object, $context, $a1, $a2); } else { // Set to avoid undefined index error messages later. diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc index d930c52..d5eee19 100644 --- a/core/includes/ajax.inc +++ b/core/includes/ajax.inc @@ -245,7 +245,7 @@ function ajax_render($commands = array()) { $items[$type] = array(); } else { - $function = 'drupal_add_' . $type; + $function = 'drupal\add_' . $type; $items[$type] = $function(); alter($type, $items[$type]); // @todo Inline CSS and JS items are indexed numerically. These can't be @@ -381,8 +381,11 @@ function ajax_form_callback() { if (!empty($form_state['triggering_element'])) { $callback = $form_state['triggering_element']['#ajax']['callback']; } - if (!empty($callback) && function_exists($callback)) { - return $callback($form, $form_state); + if (!empty($callback)) { + $function = 'drupal\\' . $callback; + if (function_exists($function)) { + return $function($form, $form_state); + } } } @@ -578,7 +581,7 @@ function ajax_footer() { // Commit the user session. See above comment about the possibility of this // function running without session.inc loaded. - if (function_exists('session_commit')) { + if (function_exists('drupal\session_commit')) { session_commit(); } } diff --git a/core/includes/authorize.inc b/core/includes/authorize.inc index a679349..0532330 100644 --- a/core/includes/authorize.inc +++ b/core/includes/authorize.inc @@ -303,7 +303,7 @@ function authorize_run_operation($filetransfer) { } require_once ROOT . '/' . $operation['file']; - call_user_func_array($operation['callback'], array_merge(array($filetransfer), $operation['arguments'])); + call_user_func_array('drupal\\' . $operation['callback'], array_merge(array($filetransfer), $operation['arguments'])); } /** @@ -326,8 +326,9 @@ function authorize_get_filetransfer($backend, $settings = array()) { $file = $backend_info['file path'] . '/' . $backend_info['file']; require_once $file; } - if (class_exists($backend_info['class'])) { - $filetransfer = $backend_info['class']::factory(ROOT, $settings); + $class = 'drupal\\' . $backend_info['class']; + if (class_exists($class)) { + $filetransfer = $class::factory(ROOT, $settings); } } return $filetransfer; diff --git a/core/includes/batch.inc b/core/includes/batch.inc index e2268c3..9956dc8 100644 --- a/core/includes/batch.inc +++ b/core/includes/batch.inc @@ -58,7 +58,7 @@ function _batch_page() { } // Register database update for the end of processing. - drupal_register_shutdown_function('_batch_shutdown'); + drupal_register_shutdown_function('drupal\_batch_shutdown'); // Add batch-specific CSS. foreach ($batch['sets'] as $batch_set) { @@ -282,7 +282,7 @@ function _batch_process() { 'finished' => &$finished, 'message' => &$task_message, ); - call_user_func_array($function, array_merge($args, array(&$batch_context))); + call_user_func_array('drupal\\' . $function, array_merge($args, array(&$batch_context))); if ($finished >= 1) { // Make sure this step is not counted twice when computing $current. @@ -436,10 +436,13 @@ function _batch_next_set() { if (isset($batch['sets'][$batch['current_set'] + 1])) { $batch['current_set']++; $current_set = &_batch_current_set(); - if (isset($current_set['form_submit']) && ($function = $current_set['form_submit']) && function_exists($function)) { - // We use our stored copies of $form and $form_state to account for - // possible alterations by previous form submit handlers. - $function($batch['form_state']['complete_form'], $batch['form_state']); + if (isset($current_set['form_submit'])) { + $function = 'drupal\\' . $current_set['form_submit']; + if (function_exists($function)) { + // We use our stored copies of $form and $form_state to account for + // possible alterations by previous form submit handlers. + $function($batch['form_state']['complete_form'], $batch['form_state']); + } } return TRUE; } @@ -461,10 +464,11 @@ function _batch_finished() { if (isset($batch_set['file']) && is_file($batch_set['file'])) { include_once ROOT . '/' . $batch_set['file']; } - if (function_exists($batch_set['finished'])) { + $function = 'drupal\\' . $batch_set['finished']; + if (function_exists($function)) { $queue = _batch_queue($batch_set); $operations = $queue->getAllItems(); - $batch_set['finished']($batch_set['success'], $batch_set['results'], $operations, format_interval($batch_set['elapsed'] / 1000)); + $function($batch_set['success'], $batch_set['results'], $operations, format_interval($batch_set['elapsed'] / 1000)); } } } @@ -517,7 +521,7 @@ function _batch_finished() { if (!empty($_batch['form_state']['rebuild'])) { $_SESSION['batch_form_state'] = $_batch['form_state']; } - $function = $_batch['redirect_callback']; + $function = 'drupal\\' . $_batch['redirect_callback']; if (function_exists($function)) { $function($_batch['source_url'], array('query' => array('op' => 'finish', 'id' => $_batch['id']))); } diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index d1a7608..7f13284 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -1,6 +1,7 @@ $name, ':type' => $type))->fetchField(); if (file_exists(ROOT . '/' . $file)) { $files[$type][$name] = $file; @@ -941,7 +942,7 @@ function get_filename($type, $name, $filename = NULL) { if (!isset($dirs[$dir][$extension])) { $dirs[$dir][$extension] = TRUE; - if (!function_exists('system_listing')) { + if (!function_exists('drupal\system_listing')) { require_once ROOT . '/core/includes/common.inc'; } // Scan the appropriate directories for all files with the requested @@ -1544,7 +1545,7 @@ function t($string, array $args = array(), array $options = array()) { $string = $custom_strings[$options['langcode']][$options['context']][$string]; } // Translate with locale module if enabled. - elseif ($options['langcode'] != LANGUAGE_SYSTEM && ($options['langcode'] != 'en' || variable_get('locale_translate_english', FALSE)) && function_exists('locale')) { + elseif ($options['langcode'] != LANGUAGE_SYSTEM && ($options['langcode'] != 'en' || variable_get('locale_translate_english', FALSE)) && function_exists('drupal\locale')) { $string = locale($string, $options['context'], $options['langcode']); } if (empty($args)) { @@ -1693,14 +1694,14 @@ function request_uri() { * information about the passed-in exception is used. * @param $variables * Array of variables to replace in the message on display. Defaults to the - * return value of decode_exception(). + * return value of _decode_exception(). * @param $severity * The severity of the message, as per RFC 3164. * @param $link * A link to associate with the message. * * @see watchdog() - * @see decode_exception() + * @see _decode_exception() */ function watchdog_exception($type, Exception $exception, $message = NULL, $variables = array(), $severity = WATCHDOG_ERROR, $link = NULL) { @@ -1751,7 +1752,7 @@ function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NO // It is possible that the error handling will itself trigger an error. In that case, we could // end up in an infinite loop. To avoid that, we implement a simple static semaphore. - if (!$in_error_state && function_exists('module_implements')) { + if (!$in_error_state && function_exists('drupal\module_implements')) { $in_error_state = TRUE; // Prepare the fields to be logged @@ -1861,7 +1862,7 @@ function get_title() { $title = set_title(); // During a bootstrap, menu.inc is not included and thus we cannot provide a title. - if (!isset($title) && function_exists('menu_get_active_title')) { + if (!isset($title) && function_exists('drupal\menu_get_active_title')) { $title = check_plain(menu_get_active_title()); } @@ -2280,9 +2281,10 @@ function _exception_handler($exception) { * Sets up the script environment and loads settings.php. */ function _bootstrap_configuration() { + global $hash_salt; // Set the Drupal custom error handler. - set_error_handler('_error_handler'); - set_exception_handler('_exception_handler'); + set_error_handler('drupal\_error_handler'); + set_exception_handler('drupal\_exception_handler'); environment_initialize(); // Start a page timer: @@ -2301,7 +2303,7 @@ function _bootstrap_configuration() { case 'apc': if (function_exists('apc_store')) { require_once(ROOT . '/core/includes/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php'); - $loader = new \Symfony\Component\ClassLoader\ApcUniversalClassLoader('drupal.' . $GLOBALS['hash_salt']); + $loader = new ClassLoader\ApcUniversalClassLoader('drupal.' . $hash_salt); break; } // If APC was not loaded, fall through to the default loader so that @@ -2309,7 +2311,7 @@ function _bootstrap_configuration() { case 'dev': case 'default': default: - $loader = new \Symfony\Component\ClassLoader\UniversalClassLoader(); + $loader = new ClassLoader\UniversalClassLoader(); break; } @@ -2317,8 +2319,9 @@ function _bootstrap_configuration() { $loader->registerNamespaces(array( // All Symfony-borrowed code lives in /core/includes/Symfony. 'Symfony' => ROOT . '/core/includes', - // All Drupal-namespaced code in core lives in /core/includes/Drupal. - 'Drupal' => ROOT . '/core/includes', + // All Drupal-namespaced code in core to be autoloaded lives in + // /core/includes/drupal. + 'drupal' => ROOT . '/core/includes', )); // Activate the autoloader. @@ -2429,8 +2432,8 @@ function _bootstrap_database() { // The database autoload routine comes first so that we can load the database // system without hitting the database. That is especially important during // the install or upgrade process. - spl_autoload_register('autoload_class'); - spl_autoload_register('autoload_interface'); + spl_autoload_register('drupal\autoload_class'); + spl_autoload_register('drupal\autoload_interface'); } /** @@ -2607,7 +2610,7 @@ function get_t() { // This is not converted to drupal_static because there is no point in // resetting this as it can not change in the course of a request. if (!isset($t)) { - $t = installation_attempted() ? 'st' : 't'; + $t = installation_attempted() ? 'drupal\st' : 'drupal\t'; } return $t; } @@ -2629,7 +2632,7 @@ function language_initialize() { if (language_multilingual()) { include_once ROOT . '/core/includes/language.inc'; foreach ($types as $type) { - $GLOBALS[$type] = language_initialize($type); + $GLOBALS[$type] = _language_initialize($type); } // Allow modules to react on language system initialization in multilingual // environments. @@ -2644,7 +2647,7 @@ function language_initialize() { * An array of key-values pairs where the key is the language type and the * value is its configurability. */ -function language_types() { +function _language_types() { return array( LANGUAGE_TYPE_INTERFACE => TRUE, LANGUAGE_TYPE_CONTENT => FALSE, @@ -2666,7 +2669,7 @@ function language_multilingual() { * Returns an array of the available language types. */ function language_types() { - return array_keys(variable_get('language_types', language_types())); + return array_keys(variable_get('language_types', _language_types())); } /** @@ -2979,7 +2982,7 @@ function get_complete_schema($rebuild = FALSE) { // Load the .install files to get hook_schema. // On some databases this function may be called before bootstrap has // been completed, so we force the functions we need to load just in case. - if (function_exists('module_load_all_includes')) { + if (function_exists('drupal\module_load_all_includes')) { // This function can be called very early in the bootstrap process, so // we force the module_list() cache to be refreshed to ensure that it // contains the complete list of modules before we go on to call @@ -3076,6 +3079,11 @@ function autoload_class($class) { function _registry_check_code($type, $name = NULL) { static $lookup_cache, $cache_update_needed; + // We only deal with classes and interfaces prefixed with drupal\. + if (($type == 'class' || $type == 'interface') && substr($name, 0, 7) != 'drupal\\') { + return FALSE; + } + if ($type == 'class' && class_exists($name) || $type == 'interface' && interface_exists($name)) { return TRUE; } @@ -3104,6 +3112,9 @@ function _registry_check_code($type, $name = NULL) { return; } + // Remove drupal\ prefix. + $name = substr($name, 7); + // $type is either 'interface' or 'class', so we only need the first letter to // keep the cache key unique. $cache_key = $type[0] . $name; @@ -3376,7 +3387,7 @@ function &drupal_register_shutdown_function($callback = NULL) { if (isset($callback)) { // Only register the internal shutdown function once. if (empty($callbacks)) { - register_shutdown_function('_shutdown_function'); + register_shutdown_function('drupal\_shutdown_function'); } $args = func_get_args(); array_shift($args); diff --git a/core/includes/cache.inc b/core/includes/cache.inc index 13bcedf..5534689 100644 --- a/core/includes/cache.inc +++ b/core/includes/cache.inc @@ -36,6 +36,7 @@ function cache($bin = 'cache') { if (!isset($class)) { $class = variable_get('cache_default_class', 'DatabaseCache'); } + $class = 'drupal\\' . $class; $cache_objects[$bin] = new $class($bin); } return $cache_objects[$bin]; diff --git a/core/includes/common.inc b/core/includes/common.inc index 84611a1..4dbf568 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -1030,7 +1030,7 @@ function http_request($url, array $options = array()) { */ function _fix_gpc_magic(&$item) { if (is_array($item)) { - array_walk($item, '_fix_gpc_magic'); + array_walk($item, 'drupal\_fix_gpc_magic'); } else { $item = stripslashes($item); @@ -1055,7 +1055,7 @@ function _fix_gpc_magic(&$item) { function _fix_gpc_magic_files(&$item, $key) { if ($key != 'tmp_name') { if (is_array($item)) { - array_walk($item, '_fix_gpc_magic_files'); + array_walk($item, 'drupal\_fix_gpc_magic_files'); } else { $item = stripslashes($item); @@ -1072,11 +1072,11 @@ function _fix_gpc_magic_files(&$item, $key) { function fix_gpc_magic() { static $fixed = FALSE; if (!$fixed && ini_get('magic_quotes_gpc')) { - array_walk($_GET, '_fix_gpc_magic'); - array_walk($_POST, '_fix_gpc_magic'); - array_walk($_COOKIE, '_fix_gpc_magic'); - array_walk($_REQUEST, '_fix_gpc_magic'); - array_walk($_FILES, '_fix_gpc_magic_files'); + array_walk($_GET, 'drupal\_fix_gpc_magic'); + array_walk($_POST, 'drupal\_fix_gpc_magic'); + array_walk($_COOKIE, 'drupal\_fix_gpc_magic'); + array_walk($_REQUEST, 'drupal\_fix_gpc_magic'); + array_walk($_FILES, 'drupal\_fix_gpc_magic_files'); } $fixed = TRUE; } @@ -1375,7 +1375,7 @@ function filter_xss($string, $allowed_tags = array('a', 'em', 'strong', 'cite', <[^>]*(>|$) # a string that starts with a <, up until the > or the end of the string | # or > # just a > - )%x', '_filter_xss_split', $string); + )%x', 'drupal\_filter_xss_split', $string); } /** @@ -1573,7 +1573,7 @@ function filter_xss_bad_protocol($string, $decode = TRUE) { // @todo Remove the $decode parameter in Drupal 8, and always assume an HTML // string that needs decoding. if ($decode) { - if (!function_exists('decode_entities')) { + if (!function_exists('drupal\decode_entities')) { require_once ROOT . '/core/includes/unicode.inc'; } @@ -1724,7 +1724,7 @@ function format_plural($count, $singular, $plural, array $args = array(), array } // Get the plural index through the gettext formula. - $index = (function_exists('locale_get_plural')) ? locale_get_plural($count, isset($options['langcode']) ? $options['langcode'] : NULL) : -1; + $index = (function_exists('drupal\locale_get_plural')) ? locale_get_plural($count, isset($options['langcode']) ? $options['langcode'] : NULL) : -1; // Backwards compatibility. if ($index < 0) { return t($plural, $args, $options); @@ -1941,7 +1941,7 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL _format_date_callback(NULL, $langcode); // Translate the marked sequences. - return preg_replace_callback('/\xEF([AaeDlMTF]?)(.*?)\xFF/', '_format_date_callback', $format); + return preg_replace_callback('/\xEF([AaeDlMTF]?)(.*?)\xFF/', 'drupal\_format_date_callback', $format); } /** @@ -2333,7 +2333,7 @@ function l($text, $path, array $options = array()) { // benchmarks indicate that invoking theme() can slow down the l() function // by 20% or more, and that some of the link-heavy Drupal pages spend more // than 10% of the total page request time in the l() function. - if (!isset($use_theme) && function_exists('theme')) { + if (!isset($use_theme) && function_exists('drupal\theme')) { // Allow edge cases to prevent theme initialization and force inline link // rendering. if (variable_get('theme_link', TRUE)) { @@ -2434,8 +2434,9 @@ function deliver_page($page_callback_result, $default_delivery_callback = NULL) // Give modules a chance to alter the delivery callback used, based on // request-time context (e.g., HTTP request headers). alter('page_delivery_callback', $delivery_callback); - if (function_exists($delivery_callback)) { - $delivery_callback($page_callback_result); + $function = 'drupal\\' . $delivery_callback; + if (function_exists($function)) { + $function($page_callback_result); } else { // If a delivery callback is specified, but doesn't exist as a function, @@ -2935,7 +2936,7 @@ function get_css($css = NULL, $skip_alter = FALSE) { } // Sort CSS items, so that they appear in the correct order. - uasort($css, 'sort_css_js'); + uasort($css, 'drupal\sort_css_js'); // Remove the overridden CSS files. Later CSS files override former ones. $previous_item = array(); @@ -3223,10 +3224,12 @@ function aggregate_css(&$css_groups) { function pre_render_styles($elements) { // Group and aggregate the items. if (isset($elements['#group_callback'])) { - $elements['#groups'] = $elements['#group_callback']($elements['#items']); + $function = 'drupal\\' . $elements['#group_callback']; + $elements['#groups'] = $function($elements['#items']); } if (isset($elements['#aggregate_callback'])) { - $elements['#aggregate_callback']($elements['#groups']); + $function = 'drupal\\' . $elements['#aggregate_callback']; + $function($elements['#groups']); } // A dummy query-string is added to filenames, to gain control over @@ -3431,7 +3434,7 @@ function build_css_cache($css) { _build_css_path(NULL, $css_base_url . '/'); // Anchor all paths in the CSS with its base URL, ignoring external and absolute paths. - $data .= preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', '_build_css_path', $contents); + $data .= preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', 'drupal\_build_css_path', $contents); } } @@ -3598,7 +3601,7 @@ function load_stylesheet_content($contents, $optimize = FALSE) { // Replaces @import commands with the actual stylesheet content. // This happens recursively but omits external files. - $contents = preg_replace_callback('/@import\s*(?:url\(\s*)?[\'"]?(?![a-z]+:)([^\'"\()]+)[\'"]?\s*\)?\s*;/', '_load_stylesheet', $contents); + $contents = preg_replace_callback('/@import\s*(?:url\(\s*)?[\'"]?(?![a-z]+:)([^\'"\()]+)[\'"]?\s*\)?\s*;/', 'drupal\_load_stylesheet', $contents); return $contents; } @@ -4124,7 +4127,7 @@ function get_js($scope = 'header', $javascript = NULL, $skip_alter = FALSE) { } // Sort the JavaScript so that it appears in the correct order. - uasort($items, 'sort_css_js'); + uasort($items, 'drupal\sort_css_js'); // Provide the page with information about the individual JavaScript files // used, information not otherwise available when aggregation is enabled. @@ -4178,10 +4181,12 @@ function get_js($scope = 'header', $javascript = NULL, $skip_alter = FALSE) { function pre_render_scripts($elements) { // Group and aggregate the items. if (isset($elements['#group_callback'])) { - $elements['#groups'] = $elements['#group_callback']($elements['#items']); + $function = 'drupal\\' . $elements['#group_callback']; + $elements['#groups'] = $function($elements['#items']); } if (isset($elements['#aggregate_callback'])) { - $elements['#aggregate_callback']($elements['#groups']); + $function = 'drupal\\' . $elements['#aggregate_callback']; + $function($elements['#groups']); } // A dummy query-string is added to filenames, to gain control over @@ -4482,7 +4487,7 @@ function process_attached($elements, $group = JS_DEFAULT, $dependency_check = FA if (isset($every_page)) { $options['every_page'] = $every_page; } - call_user_func('drupal_add_' . $type, $data, $options); + call_user_func('drupal\add_' . $type, $data, $options); } unset($elements['#attached'][$type]); } @@ -4492,7 +4497,7 @@ function process_attached($elements, $group = JS_DEFAULT, $dependency_check = FA // special handling. foreach ($elements['#attached'] as $callback => $options) { foreach ($elements['#attached'][$callback] as $args) { - call_user_func_array($callback, $args); + call_user_func_array('drupal\\' . $callback, $args); } } @@ -5195,7 +5200,7 @@ function cron_run() { Queue::get($queue_name)->createQueue(); } // Register shutdown callback. - drupal_register_shutdown_function('cron_cleanup'); + drupal_register_shutdown_function('drupal\cron_cleanup'); // Iterate through the modules calling their cron handlers (if any): foreach (module_implements('cron') as $module) { @@ -5220,7 +5225,7 @@ function cron_run() { } foreach ($queues as $queue_name => $info) { - $function = $info['worker callback']; + $function = 'drupal\\' . $info['worker callback']; $end = time() + (isset($info['time']) ? $info['time'] : 15); $queue = Queue::get($queue_name); while (time() < $end && ($item = $queue->claimItem())) { @@ -5324,7 +5329,7 @@ function system_listing($mask, $directory, $key = 'name', $min_depth = 1) { } // Get current list of items. - if (!function_exists('file_scan_directory')) { + if (!function_exists('drupal\file_scan_directory')) { require_once ROOT . '/core/includes/file.inc'; } foreach ($searchdir as $dir) { @@ -5658,7 +5663,7 @@ function render_page($page) { // Modules can add elements to $page as needed in hook_page_build(). foreach (module_implements('page_build') as $module) { - $function = $module . '_page_build'; + $function = 'drupal\\' . $module . '_page_build'; $function($page); } // Modules alter the $page as needed. Blocks are populated into regions like @@ -5784,6 +5789,7 @@ function drupal_render(&$elements) { // element is rendered into the final text. if (isset($elements['#pre_render'])) { foreach ($elements['#pre_render'] as $function) { + $function = 'drupal\\' . $function; $elements = $function($elements); } } @@ -5828,6 +5834,7 @@ function drupal_render(&$elements) { // which allows the output'ed text to be filtered. if (isset($elements['#post_render'])) { foreach ($elements['#post_render'] as $function) { + $function = 'drupal\\' . $function; $elements['#children'] = $function($elements['#children'], $elements); } } @@ -6326,7 +6333,7 @@ function element_property($key) { * Gets properties of a structured array element (keys beginning with '#'). */ function element_properties($element) { - return array_filter(array_keys((array) $element), 'element_property'); + return array_filter(array_keys((array) $element), 'drupal\element_property'); } /** @@ -6374,7 +6381,7 @@ function element_children(&$elements, $sort = FALSE) { } // Sort the children if necessary. if ($sort && $sortable) { - uasort($children, 'element_sort'); + uasort($children, 'drupal\element_sort'); // Put the sorted children back into $elements in the correct order, to // preserve sorting if the same element is passed through // element_children() twice. @@ -7267,8 +7274,8 @@ function parse_info_format($data) { } // Handle PHP constants. - if (isset($constants[$value])) { - $value = $constants[$value]; + if (isset($constants['drupal\\' . $value])) { + $value = $constants['drupal\\' . $value]; } // Insert actual value. @@ -7557,7 +7564,7 @@ function archiver_get_info() { // Rebuild the cache and save it. $archiver_info = module_invoke_all('archiver_info'); alter('archiver_info', $archiver_info); - uasort($archiver_info, 'sort_weight'); + uasort($archiver_info, 'drupal\sort_weight'); cache()->set('archiver_info', $archiver_info); } else { @@ -7617,7 +7624,8 @@ function archiver_get_archiver($file) { // Also note that the file may not yet exist, so we cannot rely // on fileinfo() or other disk-level utilities. if (strrpos($filepath, '.' . $extension) === strlen($filepath) - strlen('.' . $extension)) { - return new $implementation['class']($filepath); + $class = 'drupal\\' . $implementation['class']; + return new $class($filepath); } } } @@ -7641,7 +7649,7 @@ function get_updaters() { if (!isset($updaters)) { $updaters = module_invoke_all('updater_info'); alter('updater_info', $updaters); - uasort($updaters, 'sort_weight'); + uasort($updaters, 'drupal\sort_weight'); } return $updaters; } @@ -7663,7 +7671,7 @@ function get_filetransfer_info() { // module separately, we can't use module_invoke_all(). $info = array(); foreach (module_implements('filetransfer_info') as $module) { - $function = $module . '_filetransfer_info'; + $function = 'drupal\\' . $module . '_filetransfer_info'; $result = $function(); if (isset($result) && is_array($result)) { foreach ($result as &$values) { @@ -7675,7 +7683,7 @@ function get_filetransfer_info() { } } alter('filetransfer_info', $info); - uasort($info, 'sort_weight'); + uasort($info, 'drupal\sort_weight'); } return $info; } diff --git a/core/includes/database/database.inc b/core/includes/database/database.inc index eee6db9..d7472db 100644 --- a/core/includes/database/database.inc +++ b/core/includes/database/database.inc @@ -307,7 +307,7 @@ abstract class DatabaseConnection extends PDO { // Set a specific PDOStatement class if the driver requires that. if (!empty($this->statementClass)) { - $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this))); + $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('drupal\\' . $this->statementClass, array($this))); } } @@ -763,10 +763,10 @@ abstract class DatabaseConnection extends PDO { public function getDriverClass($class, array $files = array(), $use_autoload = FALSE) { if (empty($this->driverClasses[$class])) { $driver = $this->driver(); - $this->driverClasses[$class] = $class . '_' . $driver; + $this->driverClasses[$class] = 'drupal\\' . $class . '_' . $driver; Database::loadDriverFile($driver, $files); if (!class_exists($this->driverClasses[$class], $use_autoload)) { - $this->driverClasses[$class] = $class; + $this->driverClasses[$class] = 'drupal\\' . $class; } } return $this->driverClasses[$class]; @@ -1664,8 +1664,8 @@ abstract class Database { // We cannot rely on the registry yet, because the registry requires an // open database connection. - $driver_class = 'DatabaseConnection_' . $driver; require_once ROOT . '/core/includes/database/' . $driver . '/database.inc'; + $driver_class = 'drupal\DatabaseConnection_' . $driver; $new_connection = new $driver_class(self::$databaseInfo[$key][$target]); $new_connection->setTarget($target); $new_connection->setKey($key); diff --git a/core/includes/database/select.inc b/core/includes/database/select.inc index 6044a00..df2fc6c 100644 --- a/core/includes/database/select.inc +++ b/core/includes/database/select.inc @@ -1133,11 +1133,12 @@ class SelectQuery extends Query implements SelectQueryInterface { /* Implementations of QueryExtendableInterface. */ public function extend($extender_name) { - $override_class = $extender_name . '_' . $this->connection->driver(); + $class = 'drupal\\' . $extender_name; + $override_class = $class . '_' . $this->connection->driver(); if (class_exists($override_class)) { - $extender_name = $override_class; + $class = $override_class; } - return new $extender_name($this, $this->connection); + return new $class($this, $this->connection); } public function havingIsNull($field) { diff --git a/core/includes/errors.inc b/core/includes/errors.inc index df41d30..0a70f64 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -71,7 +71,7 @@ function _error_handler_real($error_level, $message, $filename, $line, $context) list($severity_msg, $severity_level) = $types[$error_level]; $caller = _get_last_caller(debug_backtrace()); - if (!function_exists('filter_xss_admin')) { + if (!function_exists('drupal\filter_xss_admin')) { require_once ROOT . '/core/includes/common.inc'; } @@ -110,7 +110,7 @@ function _decode_exception($exception) { // The first element in the stack is the call, the second element gives us the caller. // We skip calls that occurred in one of the classes of the database layer // or in one of its global functions. - $db_functions = array('db_query', 'db_query_range'); + $db_functions = array('drupal\db_query', 'drupal\db_query_range'); while (!empty($backtrace[1]) && ($caller = $backtrace[1]) && ((isset($caller['class']) && (strpos($caller['class'], 'Query') !== FALSE || strpos($caller['class'], 'Database') !== FALSE || strpos($caller['class'], 'PDO') !== FALSE)) || in_array($caller['function'], $db_functions))) { @@ -269,7 +269,7 @@ function _log_error($error, $fatal = FALSE) { function _get_last_caller($backtrace) { // Errors that occur inside PHP internal functions do not generate // information about file and line. Ignore black listed functions. - $blacklist = array('debug', '_error_handler', '_exception_handler'); + $blacklist = array('drupal\debug', 'drupal\_error_handler', 'drupal\_exception_handler'); while (($backtrace && !isset($backtrace[0]['line'])) || (isset($backtrace[1]['function']) && in_array($backtrace[1]['function'], $blacklist))) { array_shift($backtrace); diff --git a/core/includes/file.inc b/core/includes/file.inc index f13f470..47549da 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -138,8 +138,9 @@ function file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL) { alter('stream_wrappers', $wrappers); $existing = stream_get_wrappers(); foreach ($wrappers as $scheme => $info) { + $class = 'drupal\\' . $info['class']; // We only register classes that implement our interface. - if (in_array('StreamWrapperInterface', class_implements($info['class']), TRUE)) { + if (in_array('drupal\DrupalStreamWrapperInterface', class_implements($class), TRUE)) { // Record whether we are overriding an existing scheme. if (in_array($scheme, $existing, TRUE)) { $wrappers[$scheme]['override'] = TRUE; @@ -149,10 +150,10 @@ function file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL) { $wrappers[$scheme]['override'] = FALSE; } if (($info['type'] & STREAM_WRAPPERS_LOCAL) == STREAM_WRAPPERS_LOCAL) { - stream_wrapper_register($scheme, $info['class']); + stream_wrapper_register($scheme, $class); } else { - stream_wrapper_register($scheme, $info['class'], STREAM_IS_URL); + stream_wrapper_register($scheme, $class, STREAM_IS_URL); } } // Pre-populate the static cache with the filters most typically used. @@ -177,7 +178,7 @@ function file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL) { } /** - * Returns the stream wrapper class name for a given scheme. + * Returns the fully qualified stream wrapper class name for a given scheme. * * @param $scheme * Stream scheme. @@ -187,7 +188,7 @@ function file_get_stream_wrappers($filter = STREAM_WRAPPERS_ALL) { */ function file_stream_wrapper_get_class($scheme) { $wrappers = file_get_stream_wrappers(); - return empty($wrappers[$scheme]) ? FALSE : $wrappers[$scheme]['class']; + return empty($wrappers[$scheme]) ? FALSE : 'drupal\\' . $wrappers[$scheme]['class']; } /** @@ -1644,6 +1645,7 @@ function file_validate(stdClass &$file, $validators = array()) { // Call the validation functions specified by this function's caller. $errors = array(); foreach ($validators as $function => $args) { + $function = 'drupal\\' . $function; if (function_exists($function)) { array_unshift($args, $file); $errors = array_merge($errors, call_user_func_array($function, $args)); @@ -1976,7 +1978,7 @@ function file_download() { // headers instead, use array_merge() to merge the returned arrays. $headers = array(); foreach (module_implements('file_download') as $module) { - $function = $module . '_file_download'; + $function = 'drupal\\' . $module . '_file_download'; $result = $function($uri); if ($result == -1) { return access_denied(); @@ -2058,7 +2060,8 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) { $key = $options['key']; $files[$file->$key] = $file; if ($options['callback']) { - $options['callback']($uri); + $function = 'drupal\\' . $options['callback']; + $function($uri); } } } diff --git a/core/includes/filetransfer/ftp.inc b/core/includes/filetransfer/ftp.inc index c826fa1..d4ee053 100644 --- a/core/includes/filetransfer/ftp.inc +++ b/core/includes/filetransfer/ftp.inc @@ -30,14 +30,11 @@ abstract class FileTransferFTP extends FileTransfer { $hostname = empty($settings['advanced']['hostname']) ? 'localhost' : $settings['advanced']['hostname']; $port = empty($settings['advanced']['port']) ? 21 : $settings['advanced']['port']; - if (function_exists('ftp_connect')) { - $class = 'FileTransferFTPExtension'; - } - else { + if (!function_exists('ftp_connect')) { throw new FileTransferException('No FTP backend available.'); } - return new $class($jail, $username, $password, $hostname, $port); + return new FileTransferFTPExtension($jail, $username, $password, $hostname, $port); } /** diff --git a/core/includes/form.inc b/core/includes/form.inc index f6b8fd1..9b8c6f2 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -734,7 +734,7 @@ function retrieve_form($form_id, &$form_state) { // We first check to see if there's a function named after the $form_id. // If there is, we simply pass the arguments on to it to get the form. - if (!function_exists($form_id)) { + if (!function_exists('drupal\\' . $form_id)) { // In cases where many form_ids need to share a central constructor function, // such as the node editing form, modules can implement hook_forms(). It // maps one or more form_ids to the correct constructor functions. @@ -786,14 +786,14 @@ function retrieve_form($form_id, &$form_state) { // pre-populating a form with common elements for certain forms, such as // back/next/save buttons in multi-step form wizards. See build_form(). if (isset($form_state['wrapper_callback'])) { - $form = call_user_func_array($form_state['wrapper_callback'], $args); + $form = call_user_func_array('drupal\\' . $form_state['wrapper_callback'], $args); // Put the prepopulated $form into $args. $args[0] = $form; } // If $callback was returned by a hook_forms() implementation, call it. // Otherwise, call the function named after the form id. - $form = call_user_func_array(isset($callback) ? $callback : $form_id, $args); + $form = call_user_func_array('drupal\\' . (isset($callback) ? $callback : $form_id), $args); $form['#form_id'] = $form_id; return $form; @@ -1022,12 +1022,12 @@ function prepare_form($form_id, &$form, &$form_state) { // Ensure that modules can rely on #validate being set. $form['#validate'] = array(); // Check for a handler specific to $form_id. - if (function_exists($form_id . '_validate')) { + if (function_exists('drupal\\' . $form_id . '_validate')) { $form['#validate'][] = $form_id . '_validate'; } // Otherwise check whether this is a shared form and whether there is a // handler for the shared $form_id. - elseif (isset($form_state['build_info']['base_form_id']) && function_exists($form_state['build_info']['base_form_id'] . '_validate')) { + elseif (isset($form_state['build_info']['base_form_id']) && function_exists('drupal\\' . $form_state['build_info']['base_form_id'] . '_validate')) { $form['#validate'][] = $form_state['build_info']['base_form_id'] . '_validate'; } } @@ -1036,12 +1036,12 @@ function prepare_form($form_id, &$form, &$form_state) { // Ensure that modules can rely on #submit being set. $form['#submit'] = array(); // Check for a handler specific to $form_id. - if (function_exists($form_id . '_submit')) { + if (function_exists('drupal\\' . $form_id . '_submit')) { $form['#submit'][] = $form_id . '_submit'; } // Otherwise check whether this is a shared form and whether there is a // handler for the shared $form_id. - elseif (isset($form_state['build_info']['base_form_id']) && function_exists($form_state['build_info']['base_form_id'] . '_submit')) { + elseif (isset($form_state['build_info']['base_form_id']) && function_exists('drupal\\' . $form_state['build_info']['base_form_id'] . '_submit')) { $form['#submit'][] = $form_state['build_info']['base_form_id'] . '_submit'; } } @@ -1229,13 +1229,13 @@ function redirect_form($form_state) { if (!isset($form_state['redirect']) || $form_state['redirect'] !== FALSE) { if (isset($form_state['redirect'])) { if (is_array($form_state['redirect'])) { - call_user_func_array('redirect', $form_state['redirect']); + call_user_func_array('drupal\redirect', $form_state['redirect']); } else { // This function can be called from the installer, which guarantees // that $redirect will always be a string, so catch that case here // and use the appropriate redirect function. - $function = installation_attempted() ? 'install_redirect' : 'redirect'; + $function = installation_attempted() ? 'drupal\install_redirect' : 'drupal\redirect'; $function($form_state['redirect']); } } @@ -1385,6 +1385,7 @@ function _form_validate(&$elements, &$form_state, $form_id = NULL) { // #value data. elseif (isset($elements['#element_validate'])) { foreach ($elements['#element_validate'] as $function) { + $function = 'drupal\\' . $function; $function($elements, $form_state, $form_state['complete_form']); } } @@ -1438,6 +1439,7 @@ function form_execute_handlers($type, &$form, &$form_state) { $batch['has_form_submits'] = TRUE; } else { + $function = 'drupal\\' . $function; $function($form, $form_state); } $return = TRUE; @@ -1772,7 +1774,8 @@ function form_builder($form_id, &$element, &$form_state) { // checkboxes and files. if (isset($element['#process']) && !$element['#processed']) { foreach ($element['#process'] as $process) { - $element = $process($element, $form_state, $form_state['complete_form']); + $function = 'drupal\\' . $process; + $element = $function($element, $form_state, $form_state['complete_form']); } $element['#processed'] = TRUE; } @@ -1836,6 +1839,7 @@ function form_builder($form_id, &$element, &$form_state) { // after normal input parsing has been completed. if (isset($element['#after_build']) && !isset($element['#after_build_done'])) { foreach ($element['#after_build'] as $function) { + $function = 'drupal\\' . $function; $element = $function($element, $form_state); } $element['#after_build_done'] = TRUE; @@ -1957,7 +1961,7 @@ function _form_builder_handle_input_element($form_id, &$element, &$form_state) { // Set the element's #value property. if (!isset($element['#value']) && !array_key_exists('#value', $element)) { - $value_callback = !empty($element['#value_callback']) ? $element['#value_callback'] : 'form_type_' . $element['#type'] . '_value'; + $value_callback = 'drupal\\' . (!empty($element['#value_callback']) ? $element['#value_callback'] : 'form_type_' . $element['#type'] . '_value'); if ($process_input) { // Get the input for the current element. NULL values in the input need to // be explicitly distinguished from missing input. (see below) @@ -2869,7 +2873,7 @@ function form_process_date($element) { break; case 'month': - $options = map_assoc(range(1, 12), 'map_month'); + $options = map_assoc(range(1, 12), 'drupal\map_month'); $title = t('Month'); break; @@ -3435,7 +3439,7 @@ function form_validate_machine_name(&$element, &$form_state) { // Verify that the machine name is unique. if ($element['#default_value'] !== $element['#value']) { - $function = $element['#machine_name']['exists']; + $function = 'drupal\\' . $element['#machine_name']['exists']; if ($function($element['#value'], $element, $form_state)) { form_error($element, t('The machine-readable name is already in use. It must be unique.')); } @@ -4391,7 +4395,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = 'r $_SESSION['batches'][$batch['id']] = TRUE; // Redirect for processing. - $function = $batch['redirect_callback']; + $function = 'drupal\\' . $batch['redirect_callback']; $function($batch['url'], array('query' => array('op' => 'start', 'id' => $batch['id']))); } else { @@ -4472,7 +4476,7 @@ function _batch_queue($batch_set) { if (isset($batch_set['queue'])) { $name = $batch_set['queue']['name']; - $class = $batch_set['queue']['class']; + $class = 'drupal\\' . $batch_set['queue']['class']; if (!isset($queues[$class][$name])) { $queues[$class][$name] = new $class($name); diff --git a/core/includes/gettext.inc b/core/includes/gettext.inc index 285ef05..8b1e179 100644 --- a/core/includes/gettext.inc +++ b/core/includes/gettext.inc @@ -428,8 +428,8 @@ function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NUL for ($i = 3; $i <= count($entries); $i++) { $english[] = $english[1]; } - $translation = array_map('_locale_import_append_plural', $value['msgstr'], $entries); - $english = array_map('_locale_import_append_plural', $english, $entries); + $translation = array_map('drupal\_locale_import_append_plural', $value['msgstr'], $entries); + $english = array_map('drupal\_locale_import_append_plural', $english, $entries); foreach ($translation as $key => $trans) { if ($key == 0) { $plid = 0; diff --git a/core/includes/image.inc b/core/includes/image.inc index 20e3a83..2bdf340 100644 --- a/core/includes/image.inc +++ b/core/includes/image.inc @@ -68,7 +68,7 @@ function image_get_toolkit() { if (!isset($toolkit)) { $toolkits = image_get_available_toolkits(); $toolkit = variable_get('image_toolkit', 'gd'); - if (!isset($toolkits[$toolkit]) || !function_exists('image_' . $toolkit . '_load')) { + if (!isset($toolkits[$toolkit]) || !function_exists('drupal\image_' . $toolkit . '_load')) { // The selected toolkit isn't available so return the first one found. If // none are available this will return FALSE. reset($toolkits); @@ -93,7 +93,7 @@ function image_get_toolkit() { * Mixed values (typically Boolean indicating successful operation). */ function image_toolkit_invoke($method, stdClass $image, array $params = array()) { - $function = 'image_' . $image->toolkit . '_' . $method; + $function = 'drupal\image_' . $image->toolkit . '_' . $method; if (function_exists($function)) { array_unshift($params, $image); return call_user_func_array($function, $params); diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 7ec0dc1..5428b55 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -385,7 +385,7 @@ function install_run_tasks(&$install_state) { * The output of the task function, if there is any. */ function install_run_task($task, &$install_state) { - $function = $task['function']; + $function = 'drupal\\' . $task['function']; if ($task['type'] == 'form') { require_once ROOT . '/core/includes/form.inc'; @@ -400,7 +400,7 @@ function install_run_task($task, &$install_state) { 'build_info' => array('args' => array(&$install_state)), 'no_redirect' => TRUE, ); - $form = build_form($function, $form_state); + $form = build_form($task['function'], $form_state); // If a successful form submission did not occur, the form needs to be // rendered, which means the task is not complete yet. if (empty($form_state['executed'])) { @@ -416,13 +416,13 @@ function install_run_task($task, &$install_state) { // values taken from the installation state. Throw an exception if any // errors were encountered. $form_state = array( - 'values' => !empty($install_state['forms'][$function]) ? $install_state['forms'][$function] : array(), + 'values' => !empty($install_state['forms'][$task['function']]) ? $install_state['forms'][$task['function']] : array(), // We need to pass $install_state by reference in order for forms to // modify it, since the form API will use it in call_user_func_array(), // which requires that referenced variables be passed explicitly. 'build_info' => array('args' => array(&$install_state)), ); - form_submit($function, $form_state); + form_submit($task['function'], $form_state); $errors = form_get_errors(); if (!empty($errors)) { throw new Exception(implode("\n", $errors)); @@ -446,7 +446,7 @@ function install_run_task($task, &$install_state) { // task is currently running. Otherwise, we need to make sure the batch // will complete in one page request. if ($install_state['interactive']) { - variable_set('install_current_batch', $function); + variable_set('install_current_batch', $task['function']); } else { $batch =& batch_get(); @@ -458,7 +458,7 @@ function install_run_task($task, &$install_state) { } // If we are in the middle of processing this batch, keep sending back // any output from the batch process, until the task is complete. - elseif ($current_batch == $function) { + elseif ($current_batch == $task['function']) { include_once ROOT . '/core/includes/batch.inc'; $output = _batch_page(); // The task is complete when we try to access the batch page and receive @@ -587,7 +587,7 @@ function install_tasks($install_state) { if (file_exists($profile_install_file)) { include_once $profile_install_file; } - $function = $install_state['parameters']['profile'] . '_install_tasks'; + $function = 'drupal\\' . $install_state['parameters']['profile'] . '_install_tasks'; if (function_exists($function)) { $result = $function($install_state); if (is_array($result)) { @@ -614,7 +614,7 @@ function install_tasks($install_state) { $profile_file = ROOT . '/profiles/' . $install_state['parameters']['profile'] . '/' . $install_state['parameters']['profile'] . '.profile'; if (file_exists($profile_file)) { include_once $profile_file; - $function = $install_state['parameters']['profile'] . '_install_tasks_alter'; + $function = 'drupal\\' . $install_state['parameters']['profile'] . '_install_tasks_alter'; if (function_exists($function)) { $function($tasks, $install_state); } diff --git a/core/includes/install.inc b/core/includes/install.inc index 312254c..2c313c6 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -102,7 +102,7 @@ function get_schema_versions($module) { } // Prepare regular expression to match all possible defined hook_update_N(). - $regexp = '/^(?P.+)_update_(?P\d+)$/'; + $regexp = '/^drupal\\\\(?P.+)_update_(?P\d+)$/'; $functions = get_defined_functions(); // Narrow this down to functions ending with an integer, since all // hook_update_N() functions end this way, and there are other @@ -1162,7 +1162,7 @@ function check_profile($profile) { $requirements = array(); foreach ($info['dependencies'] as $module) { module_load_install($module); - $function = $module . '_requirements'; + $function = 'drupal\\' . $module . '_requirements'; if (function_exists($function)) { $requirements = array_merge($requirements, $function('install')); } @@ -1309,6 +1309,6 @@ function db_run_tasks($driver) { */ function db_installer_object($driver) { Database::loadDriverFile($driver, array('install.inc')); - $task_class = 'DatabaseTasks_' . $driver; + $task_class = 'drupal\DatabaseTasks_' . $driver; return new $task_class(); } diff --git a/core/includes/language.inc b/core/includes/language.inc index 2a1099b..ae6109b 100644 --- a/core/includes/language.inc +++ b/core/includes/language.inc @@ -51,7 +51,7 @@ function language_types_configurable($stored = TRUE) { $configurable = &drupal_static(__FUNCTION__); if ($stored && !isset($configurable)) { - $types = variable_get('language_types', language_types()); + $types = variable_get('language_types', _language_types()); $configurable = array_keys(array_filter($types)); } @@ -75,7 +75,7 @@ function language_types_configurable($stored = TRUE) { * An array of language types. */ function language_types_disable($types) { - $enabled_types = variable_get('language_types', language_types()); + $enabled_types = variable_get('language_types', _language_types()); foreach ($types as $type) { unset($enabled_types[$type]); @@ -197,7 +197,7 @@ function language_negotiation_get_switch_links($type, $path) { require_once ROOT . '/' . $provider['file']; } - $callback = $provider['callbacks']['switcher']; + $callback = 'drupal\\' . $provider['callbacks']['switcher']; $result = $callback($type, $path); if (!empty($result)) { @@ -346,7 +346,7 @@ function language_provider_invoke($provider_id, $provider = NULL) { // If the language provider has no cache preference or this is satisfied // we can execute the callback. $cache = !isset($provider['cache']) || $user->uid || $provider['cache'] == variable_get('cache', 0); - $callback = isset($provider['callbacks']['language']) ? $provider['callbacks']['language'] : FALSE; + $callback = isset($provider['callbacks']['language']) ? ('drupal\\' . $provider['callbacks']['language']) : FALSE; $langcode = $cache && function_exists($callback) ? $callback($languages) : FALSE; $results[$provider_id] = isset($languages[$langcode]) ? $languages[$langcode] : FALSE; } @@ -380,7 +380,7 @@ function language_provider_weight($provider) { * @return * The negotiated language object. */ -function language_initialize($type) { +function _language_initialize($type) { // Execute the language providers in the order they were set up and return the // first valid language found. $negotiation = variable_get("language_negotiation_$type", array()); diff --git a/core/includes/lock.inc b/core/includes/lock.inc index 27bd901..f53df57 100644 --- a/core/includes/lock.inc +++ b/core/includes/lock.inc @@ -85,7 +85,7 @@ function _lock_id() { // Assign a unique id. $lock_id = uniqid(mt_rand(), TRUE); // We only register a shutdown function if a lock is used. - drupal_register_shutdown_function('lock_release_all', $lock_id); + drupal_register_shutdown_function('drupal\lock_release_all', $lock_id); } return $lock_id; } diff --git a/core/includes/mail.inc b/core/includes/mail.inc index 0ac4adc..732ee32 100644 --- a/core/includes/mail.inc +++ b/core/includes/mail.inc @@ -157,7 +157,7 @@ function mail($module, $key, $to, $language, $params = array(), $from = NULL, $s // Build the e-mail (get subject and body, allow additional headers) by // invoking hook_mail() on this module. We cannot use module_invoke() as // we need to have $message by reference in hook_mail(). - if (function_exists($function = $module . '_mail')) { + if (function_exists($function = 'drupal\\' . $module . '_mail')) { $function($key, $message, $params); } @@ -274,9 +274,11 @@ function mail_system($module, $key) { $class = $configuration['default-system']; } + $class = 'drupal\\' . $class; + if (empty($instances[$class])) { $interfaces = class_implements($class); - if (isset($interfaces['MailSystemInterface'])) { + if (isset($interfaces['drupal\MailSystemInterface'])) { $instances[$class] = new $class(); } else { @@ -355,7 +357,7 @@ function wrap_mail($text, $indent = '') { $text = preg_replace('/ +\n/m', "\n", $text); // Wrap each line at the needed width. $lines = explode("\n", $text); - array_walk($lines, '_wrap_mail_line', array('soft' => $soft, 'length' => strlen($indent))); + array_walk($lines, 'drupal\_wrap_mail_line', array('soft' => $soft, 'length' => strlen($indent))); $text = implode("\n", $lines); } else { @@ -416,7 +418,7 @@ function html_to_text($string, $allowed_tags = NULL) { // 'See the Drupal site [1]' with the URL included as a footnote. _html_to_mail_urls(NULL, TRUE); $pattern = '@(]+?href="([^"]*)"[^>]*?>(.+?))@i'; - $string = preg_replace_callback($pattern, '_html_to_mail_urls', $string); + $string = preg_replace_callback($pattern, 'drupal\_html_to_mail_urls', $string); $urls = _html_to_mail_urls(); $footnotes = ''; if (count($urls)) { @@ -538,12 +540,13 @@ function html_to_text($string, $allowed_tags = NULL) { if (isset($chunk)) { // Apply any necessary case conversion. if (isset($casing)) { - $chunk = $casing($chunk); + $function = 'drupal\\' . $casing; + $chunk = $function($chunk); } // Format it and apply the current indentation. $output .= wrap_mail($chunk, implode('', $indent)) . MAIL_LINE_ENDINGS; // Remove non-quotation markers from indentation. - $indent = array_map('_html_to_text_clean', $indent); + $indent = array_map('drupal\_html_to_text_clean', $indent); } $tag = !$tag; diff --git a/core/includes/menu.inc b/core/includes/menu.inc index b82134f..4d035a4 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -511,7 +511,7 @@ function menu_execute_active_handler($path = NULL, $deliver = TRUE) { if ($router_item['include_file']) { require_once ROOT . '/' . $router_item['include_file']; } - $page_callback_result = call_user_func_array($router_item['page_callback'], $router_item['page_arguments']); + $page_callback_result = call_user_func_array('drupal\\' . $router_item['page_callback'], $router_item['page_arguments']); } else { $page_callback_result = MENU_ACCESS_DENIED; @@ -564,6 +564,7 @@ function _menu_load_objects(&$item, &$map) { // some processing. In this case the $function is the key to the // load_function array, and the value is the list of arguments. list($function, $args) = each($function); + $function = 'drupal\\' . $function; $load_functions[$index] = $function; // Some arguments are placeholders for dynamic items to process. @@ -587,6 +588,7 @@ function _menu_load_objects(&$item, &$map) { $return = call_user_func_array($function, $args); } else { + $function = 'drupal\\' . $function; $return = $function($value); } // If callback returned an error or there is no callback, trigger 404. @@ -630,7 +632,7 @@ function _menu_check_access(&$item, $map) { $item['access'] = (count($arguments) == 1) ? user_access($arguments[0]) : user_access($arguments[0], $arguments[1]); } else { - $item['access'] = call_user_func_array($callback, $arguments); + $item['access'] = call_user_func_array('drupal\\' . $callback, $arguments); } } } @@ -690,11 +692,12 @@ function _menu_item_localize(&$item, $map, $link_translate = FALSE) { } } elseif ($callback) { + $function = 'drupal\\' . $callback; if (empty($item['title_arguments'])) { - $item['title'] = $callback($item['title']); + $item['title'] = $function($item['title']); } else { - $item['title'] = call_user_func_array($callback, menu_unserialize($item['title_arguments'], $map)); + $item['title'] = call_user_func_array($function, menu_unserialize($item['title_arguments'], $map)); } // Avoid calling check_plain again on l() function. if ($callback == 'check_plain') { @@ -807,6 +810,7 @@ function _menu_link_map_translate(&$map, $to_arg_functions) { $to_arg_functions = unserialize($to_arg_functions); foreach ($to_arg_functions as $index => $function) { // Translate place-holders into real values. + $function = 'drupal\\' . $function; $arg = $function(!empty($map[$index]) ? $map[$index] : '', $map, $index); if (!empty($map[$index]) || isset($arg)) { $map[$index] = $arg; @@ -1710,7 +1714,7 @@ function menu_get_active_help() { $arg = help_arg(arg(NULL)); foreach (module_implements('help') as $module) { - $function = $module . '_help'; + $function = 'drupal\\' . $module . '_help'; // Lookup help for this path. if ($help = $function($router_path, $arg)) { $output .= $help . "\n"; @@ -1739,7 +1743,7 @@ function menu_get_custom_theme($initialize = FALSE) { // First allow modules to dynamically set a custom theme for the current // page. Since we can only have one, the last module to return a valid // theme takes precedence. - $custom_themes = array_filter(module_invoke_all('custom_theme'), 'theme_access'); + $custom_themes = array_filter(module_invoke_all('custom_theme'), 'drupal\theme_access'); if (!empty($custom_themes)) { $custom_theme = array_pop($custom_themes); } @@ -1748,7 +1752,7 @@ function menu_get_custom_theme($initialize = FALSE) { // by a hook_custom_theme() implementation above. $router_item = menu_get_item(); if (!empty($router_item['access']) && !empty($router_item['theme_callback'])) { - $theme_name = call_user_func_array($router_item['theme_callback'], $router_item['theme_arguments']); + $theme_name = call_user_func_array('drupal\\' . $router_item['theme_callback'], $router_item['theme_arguments']); if (theme_access($theme_name)) { $custom_theme = $theme_name; } @@ -2689,7 +2693,7 @@ function menu_router_build() { // a given item came from. $callbacks = array(); foreach (module_implements('menu') as $module) { - $router_items = call_user_func($module . '_menu'); + $router_items = call_user_func('drupal\\' . $module . '_menu'); if (isset($router_items) && is_array($router_items)) { foreach (array_keys($router_items) as $path) { $router_items[$path]['module'] = $module; @@ -3256,9 +3260,9 @@ function _menu_clear_page_cache() { $cache_cleared = 1; } elseif ($cache_cleared == 1) { - drupal_register_shutdown_function('cache_clear_all'); + drupal_register_shutdown_function('drupal\cache_clear_all'); // Keep track of which menus have expanded items. - drupal_register_shutdown_function('_menu_set_expanded_menus'); + drupal_register_shutdown_function('drupal\_menu_set_expanded_menus'); $cache_cleared = 2; } } @@ -3506,12 +3510,12 @@ function _menu_router_build($callbacks) { $load_functions[$k] = NULL; } else { - if (function_exists($matches[1] . '_to_arg')) { + if (function_exists('drupal\\' . $matches[1] . '_to_arg')) { $to_arg_functions[$k] = $matches[1] . '_to_arg'; $load_functions[$k] = NULL; $match = TRUE; } - if (function_exists($matches[1] . '_load')) { + if (function_exists('drupal\\' . $matches[1] . '_load')) { $function = $matches[1] . '_load'; // Create an array of arguments that will be passed to the _load // function when this menu path is checked, if 'load arguments' diff --git a/core/includes/module.inc b/core/includes/module.inc index b65d9bc..e858092 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -296,7 +296,7 @@ function module_load_include($type, $module, $name = NULL) { $name = $module; } - if (function_exists('get_path')) { + if (function_exists('drupal\get_path')) { $file = ROOT . '/' . get_path('module', $module) . "/$name.$type"; if (is_file($file)) { require_once $file; @@ -598,7 +598,7 @@ function module_disable($module_list, $disable_dependents = TRUE) { * implemented in that module. */ function module_hook($module, $hook) { - $function = $module . '_' . $hook; + $function = 'drupal\\' . $module . '_' . $hook; if (function_exists($function)) { return TRUE; } @@ -658,7 +658,7 @@ function module_implements($hook, $sort = FALSE) { $include_file = isset($hook_info[$hook]['group']) && module_load_include('inc', $module, $module . '.' . $hook_info[$hook]['group']); // Since module_hook() may needlessly try to load the include file again, // function_exists() is used directly here. - if (function_exists($module . '_' . $hook)) { + if (function_exists('drupal\\' . $module . '_' . $hook)) { $implementations[$hook][$module] = $include_file ? $hook_info[$hook]['group'] : FALSE; } } @@ -680,7 +680,7 @@ function module_implements($hook, $sort = FALSE) { // function exists on each request to avoid undefined function errors. // Since module_hook() may needlessly try to load the include file again, // function_exists() is used directly here. - if (!function_exists($module . '_' . $hook)) { + if (!function_exists('drupal\\' . $module . '_' . $hook)) { // Clear out the stale implementation from the cache and force a cache // refresh to forget about no longer existing hook implementations. unset($implementations[$hook][$module]); @@ -734,7 +734,7 @@ function module_hook_info() { // We can't use module_invoke_all() here or it would cause an infinite // loop. foreach (module_list() as $module) { - $function = $module . '_hook_info'; + $function = 'drupal\\' . $module . '_hook_info'; if (function_exists($function)) { $result = $function(); if (isset($result) && is_array($result)) { @@ -744,7 +744,7 @@ function module_hook_info() { } // We can't use alter() for the same reason as above. foreach (module_list() as $module) { - $function = $module . '_hook_info_alter'; + $function = 'drupal\\' . $module . '_hook_info_alter'; if (function_exists($function)) { $function($hook_info); } @@ -765,7 +765,7 @@ function module_hook_info() { * @see module_implements() */ function module_implements_write_cache() { - $implementations = &drupal_static('module_implements'); + $implementations = &drupal_static('drupal\module_implements'); // Check whether we need to write the cache. We do not want to cache hooks // which are only invoked on HTTP POST requests since these do not need to be // optimized as tightly, and not doing so keeps the cache entry smaller. @@ -793,7 +793,7 @@ function module_invoke($module, $hook) { // Remove $module and $hook from the arguments. unset($args[0], $args[1]); if (module_hook($module, $hook)) { - return call_user_func_array($module . '_' . $hook, $args); + return call_user_func_array('drupal\\' . $module . '_' . $hook, $args); } } @@ -815,7 +815,7 @@ function module_invoke_all($hook) { unset($args[0]); $return = array(); foreach (module_implements($hook) as $module) { - $function = $module . '_' . $hook; + $function = 'drupal\\' . $module . '_' . $hook; if (function_exists($function)) { $result = call_user_func_array($function, $args); if (isset($result) && is_array($result)) { @@ -942,7 +942,7 @@ function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) { // function_exists(), since module_implements() returns only modules with // implementations. foreach ($modules as $module) { - $functions[$cid][] = $module . '_' . $hook; + $functions[$cid][] = 'drupal\\' . $module . '_' . $hook; } } else { @@ -977,12 +977,12 @@ function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) { // Since $modules is a merged array, for any given module, we do not // know whether it has any particular implementation, so we need a // function_exists(). - $function = $module . '_' . $hook; + $function = 'drupal\\' . $module . '_' . $hook; if (function_exists($function)) { $functions[$cid][] = $function; } foreach ($extra_types as $extra_type) { - $function = $module . '_' . $extra_type . '_alter'; + $function = 'drupal\\' . $module . '_' . $extra_type . '_alter'; if (function_exists($function)) { $functions[$cid][] = $function; } @@ -999,13 +999,13 @@ function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) { } $theme_keys[] = $theme; foreach ($theme_keys as $theme_key) { - $function = $theme_key . '_' . $hook; + $function = 'drupal\\' . $theme_key . '_' . $hook; if (function_exists($function)) { $functions[$cid][] = $function; } if (isset($extra_types)) { foreach ($extra_types as $extra_type) { - $function = $theme_key . '_' . $extra_type . '_alter'; + $function = 'drupal\\' . $theme_key . '_' . $extra_type . '_alter'; if (function_exists($function)) { $functions[$cid][] = $function; } diff --git a/core/includes/path.inc b/core/includes/path.inc index 8ada587..2f52e7c 100644 --- a/core/includes/path.inc +++ b/core/includes/path.inc @@ -205,7 +205,7 @@ function lookup_path($action, $path = '', $path_language = NULL) { function cache_system_paths() { // Check if the system paths for this page were loaded from cache in this // request to avoid writing to cache on every request. - $cache = &drupal_static('lookup_path', array()); + $cache = &drupal_static('drupal\lookup_path', array()); if (empty($cache['system_paths']) && !empty($cache['map'])) { // Generate a cache ID (cid) specifically for this page. $cid = current_path(); @@ -270,7 +270,7 @@ function get_normal_path($path, $path_language = NULL) { // here because we need to run hook_url_inbound_alter() in the reverse order // of hook_url_outbound_alter(). foreach (array_reverse(module_implements('url_inbound_alter')) as $module) { - $function = $module . '_url_inbound_alter'; + $function = 'drupal\\' . $module . '_url_inbound_alter'; $function($path, $original_path, $path_language); } diff --git a/core/includes/session.inc b/core/includes/session.inc index 31d1d73..c94414d 100644 --- a/core/includes/session.inc +++ b/core/includes/session.inc @@ -238,7 +238,7 @@ function _session_write($sid, $value) { function session_initialize() { global $user, $is_https; - session_set_save_handler('_session_open', '_session_close', '_session_read', '_session_write', '_session_destroy', '_session_garbage_collection'); + session_set_save_handler('drupal\_session_open', 'drupal\_session_close', 'drupal\_session_read', 'drupal\_session_write', 'drupal\_session_destroy', 'drupal\_session_garbage_collection'); // We use !empty() in the following check to ensure that blank session IDs // are not valid. diff --git a/core/includes/stream_wrappers.inc b/core/includes/stream_wrappers.inc index 8660d54..6c871d2 100644 --- a/core/includes/stream_wrappers.inc +++ b/core/includes/stream_wrappers.inc @@ -124,7 +124,7 @@ interface StreamWrapperInterface { * Extend the StreamWrapperInterface with methods expected by Drupal stream * wrapper classes. */ -interface StreamWrapperInterface extends StreamWrapperInterface { +interface DrupalStreamWrapperInterface extends StreamWrapperInterface { /** * Set the absolute stream resource URI. * @@ -232,7 +232,7 @@ interface StreamWrapperInterface extends StreamWrapperInterface { * LocalStreamWrapper implementations need to implement at least the * getDirectoryPath() and getExternalUrl() methods. */ -abstract class LocalStreamWrapper implements StreamWrapperInterface { +abstract class LocalStreamWrapper implements DrupalStreamWrapperInterface { /** * Stream context resource. * diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 5a646a1..e8a8d69 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -208,13 +208,13 @@ function _theme_initialize($theme, $base_theme = array(), $registry_callback = ' if (isset($theme->engine)) { // Include the engine. include_once ROOT . '/' . $theme->owner; - $theme_engine = $theme->engine; - if (function_exists($theme_engine . '_init')) { + $function = 'drupal\\' . $theme_engine . '_init'; + if (function_exists($function)) { foreach ($base_theme as $base) { - call_user_func($theme_engine . '_init', $base); + call_user_func($function, $base); } - call_user_func($theme_engine . '_init', $theme); + call_user_func($function, $theme); } } else { @@ -262,7 +262,7 @@ function theme_get_registry($complete = TRUE) { if (!$complete) { $arguments[] = FALSE; } - $theme_registry[$key] = call_user_func_array($callback, $arguments); + $theme_registry[$key] = call_user_func_array('drupal\\' . $callback, $arguments); } return $theme_registry[$key]; @@ -505,7 +505,7 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) { // Invoke the hook_theme() implementation, process what is returned, and // merge it into $cache. - $function = $name . '_theme'; + $function = 'drupal\\' . $name . '_theme'; if (function_exists($function)) { $result = $function($cache, $type, $theme, $path); foreach ($result as $hook => $info) { @@ -585,10 +585,10 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) { foreach ($prefixes as $prefix) { // Only use non-hook-specific variable processors for theming hooks // implemented as templates. See theme(). - if (isset($info['template']) && function_exists($prefix . '_' . $phase)) { + if (isset($info['template']) && function_exists('drupal\\' . $prefix . '_' . $phase)) { $info[$phase_key][] = $prefix . '_' . $phase; } - if (function_exists($prefix . '_' . $phase . '_' . $hook)) { + if (function_exists('drupal\\' . $prefix . '_' . $phase . '_' . $hook)) { $info[$phase_key][] = $prefix . '_' . $phase . '_' . $hook; } } @@ -622,10 +622,10 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) { } // Only use non-hook-specific variable processors for theming hooks // implemented as templates. See theme(). - if (isset($info['template']) && function_exists($name . '_' . $phase)) { + if (isset($info['template']) && function_exists('drupal\\' . $name . '_' . $phase)) { $cache[$hook][$phase_key][] = $name . '_' . $phase; } - if (function_exists($name . '_' . $phase . '_' . $hook)) { + if (function_exists('drupal\\' . $name . '_' . $phase . '_' . $hook)) { $cache[$hook][$phase_key][] = $name . '_' . $phase . '_' . $hook; $cache[$hook]['theme path'] = $path; } @@ -992,6 +992,7 @@ function theme($hook, $variables = array()) { foreach (array('preprocess functions', 'process functions') as $phase) { if (!empty($info[$phase])) { foreach ($info[$phase] as $processor_function) { + $processor_function = 'drupal\\' . $processor_function; if (function_exists($processor_function)) { // We don't want a poorly behaved process function changing $hook. $hook_clone = $hook; @@ -1030,23 +1031,24 @@ function theme($hook, $variables = array()) { // Generate the output using either a function or a template. $output = ''; if (isset($info['function'])) { - if (function_exists($info['function'])) { - $output = $info['function']($variables); + $function = 'drupal\\' . $info['function']; + if (function_exists($function)) { + $output = $function($variables); } } else { // Default render function and extension. - $render_function = 'theme_render_template'; + $render_function = 'drupal\theme_render_template'; $extension = '.tpl.php'; // The theme engine may use a different extension and a different renderer. global $theme_engine; if (isset($theme_engine)) { if ($info['type'] != 'module') { - if (function_exists($theme_engine . '_render_template')) { - $render_function = $theme_engine . '_render_template'; + if (function_exists('drupal\\' . $theme_engine . '_render_template')) { + $render_function = 'drupal\\' . $theme_engine . '_render_template'; } - $extension_function = $theme_engine . '_extension'; + $extension_function = 'drupal\\' . $theme_engine . '_extension'; if (function_exists($extension_function)) { $extension = $extension_function(); } @@ -1132,13 +1134,13 @@ function find_theme_functions($cache, $prefixes) { // intermediary suggestion. $pattern = isset($info['pattern']) ? $info['pattern'] : ($hook . '__'); if (!isset($info['base hook']) && !empty($pattern)) { - $matches = preg_grep('/^' . $prefix . '_' . $pattern . '/', $functions['user']); + $matches = preg_grep('/^drupal\\\\' . $prefix . '_' . $pattern . '/', $functions['user']); if ($matches) { foreach ($matches as $match) { - $new_hook = substr($match, strlen($prefix) + 1); + $new_hook = substr($match, strlen($prefix) + 8); $arg_name = isset($info['variables']) ? 'variables' : 'render element'; $implementations[$new_hook] = array( - 'function' => $match, + 'function' => $prefix . '_' . $new_hook, $arg_name => $info[$arg_name], 'base hook' => $hook, ); @@ -1148,7 +1150,7 @@ function find_theme_functions($cache, $prefixes) { // Find theme functions that implement registered theme hooks and include // that in what is returned so that the registry knows that the theme has // this implementation. - if (function_exists($prefix . '_' . $hook)) { + if (function_exists('drupal\\' . $prefix . '_' . $hook)) { $implementations[$hook] = array( 'function' => $prefix . '_' . $hook, ); @@ -2255,7 +2257,7 @@ function _template_preprocess_default_variables() { // The user object has no uid property when the database does not exist during // install. The user_access() check deals with issues when in maintenance mode // as uid is set but the user.module has not been included. - if (isset($user->uid) && function_exists('user_access')) { + if (isset($user->uid) && function_exists('drupal\user_access')) { $variables['is_admin'] = user_access('access administration pages'); $variables['logged_in'] = ($user->uid > 0); } diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc index c9c0ff8..f995169 100644 --- a/core/includes/theme.maintenance.inc +++ b/core/includes/theme.maintenance.inc @@ -55,7 +55,7 @@ function _maintenance_theme() { } // Ensure that system.module is loaded. - if (!function_exists('_system_rebuild_theme_data')) { + if (!function_exists('drupal\_system_rebuild_theme_data')) { $module_list['system']['filename'] = 'core/modules/system/system.module'; module_list(TRUE, FALSE, FALSE, $module_list); load('module', 'system'); diff --git a/core/includes/token.inc b/core/includes/token.inc index 49c5514..fddb17d 100644 --- a/core/includes/token.inc +++ b/core/includes/token.inc @@ -88,7 +88,7 @@ function token_replace($text, array $data = array(), array $options = array()) { // Optionally alter the list of replacement values. if (!empty($options['callback'])) { - $function = $options['callback']; + $function = 'drupal\\' . $options['callback']; $function($replacements, $data, $options); } diff --git a/core/includes/unicode.inc b/core/includes/unicode.inc index 9d8f793..05cc2cd 100644 --- a/core/includes/unicode.inc +++ b/core/includes/unicode.inc @@ -393,9 +393,9 @@ function mime_header_encode($string) { */ function mime_header_decode($header) { // First step: encoded chunks followed by other encoded chunks (need to collapse whitespace) - $header = preg_replace_callback('/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=\s+(?==\?)/', '_mime_header_decode', $header); + $header = preg_replace_callback('/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=\s+(?==\?)/', 'drupal\_mime_header_decode', $header); // Second step: remaining chunks (do not collapse whitespace) - return preg_replace_callback('/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=/', '_mime_header_decode', $header); + return preg_replace_callback('/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=/', 'drupal\_mime_header_decode', $header); } /** @@ -461,7 +461,7 @@ function drupal_strtoupper($text) { // Use C-locale for ASCII-only uppercase $text = strtoupper($text); // Case flip Latin-1 accented letters - $text = preg_replace_callback('/\xC3[\xA0-\xB6\xB8-\xBE]/', '_unicode_caseflip', $text); + $text = preg_replace_callback('/\xC3[\xA0-\xB6\xB8-\xBE]/', 'drupal\_unicode_caseflip', $text); return $text; } } @@ -480,7 +480,7 @@ function drupal_strtolower($text) { // Use C-locale for ASCII-only lowercase $text = strtolower($text); // Case flip Latin-1 accented letters - $text = preg_replace_callback('/\xC3[\x80-\x96\x98-\x9E]/', '_unicode_caseflip', $text); + $text = preg_replace_callback('/\xC3[\x80-\x96\x98-\x9E]/', 'drupal\_unicode_caseflip', $text); return $text; } } diff --git a/core/includes/update.inc b/core/includes/update.inc index c3be80a..905f0e0 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -217,7 +217,7 @@ function update_module_enable(array $modules) { // installed module is always 0. Using 8000 here would be inconsistent // since $module_update_8000() may involve a schema change, and we want // to install the schema as it was before any updates were added. - $function = $module . '_schema_0'; + $function = 'drupal\\' . $module . '_schema_0'; if (function_exists($function)) { $schema = $function(); foreach ($schema as $table => $spec) { @@ -282,7 +282,7 @@ function update_module_enable(array $modules) { * @see update_resolve_dependencies() */ function update_do_one($module, $number, $dependency_map, &$context) { - $function = $module . '_update_' . $number; + $function = 'drupal\\' . $module . '_update_' . $number; // If this update was aborted in a previous step, or has a dependency that // was aborted in a previous step, go no further. @@ -486,7 +486,7 @@ function update_get_update_list() { foreach (array_keys($updates) as $update) { if ($update > $schema_version) { // The description for an update comes from its Doxygen. - $func = new ReflectionFunction($module . '_update_' . $update); + $func = new ReflectionFunction('drupal\\' . $module . '_update_' . $update); $description = str_replace(array("\n", '*', '/'), '', $func->getDocComment()); $ret[$module]['pending'][$update] = "$update - $description"; if (!isset($ret[$module]['start'])) { @@ -554,7 +554,7 @@ function update_resolve_dependencies($starting_updates) { // Perform the depth-first search and sort the results. require_once ROOT . '/core/includes/graph.inc'; depth_first_search($graph); - uasort($graph, 'sort_weight'); + uasort($graph, 'drupal\sort_weight'); foreach ($graph as $function => &$data) { $module = $data['module']; @@ -718,7 +718,7 @@ function update_build_dependency_graph($update_functions) { * provided list of updates to run; FALSE otherwise. */ function update_is_missing($module, $number, $update_functions) { - return !isset($update_functions[$module][$number]) || !function_exists($update_functions[$module][$number]); + return !isset($update_functions[$module][$number]) || !function_exists('drupal\\' . $update_functions[$module][$number]); } /** @@ -758,7 +758,7 @@ function update_retrieve_dependencies() { // the same order that module_invoke_all() does. $modules = db_query("SELECT name FROM {system} WHERE type = 'module' AND schema_version <> :schema ORDER BY weight ASC, name ASC", array(':schema' => SCHEMA_UNINSTALLED))->fetchCol(); foreach ($modules as $module) { - $function = $module . '_update_dependencies'; + $function = 'drupal\\' . $module . '_update_dependencies'; if (function_exists($function)) { $result = $function(); // Each implementation of hook_update_dependencies() returns a diff --git a/core/includes/updater.inc b/core/includes/updater.inc index fb5b0b9..a7e3a61 100644 --- a/core/includes/updater.inc +++ b/core/includes/updater.inc @@ -100,7 +100,8 @@ class Updater { else { throw new UpdaterException(t('Unable to determine the type of the source directory.')); } - return new $updater($source); + $class = 'drupal\\' . $updater; + return new $class($source); } /** @@ -117,7 +118,7 @@ class Updater { $updaters = get_updaters(); foreach ($updaters as $updater) { $class = $updater['class']; - if (call_user_func(array($class, 'canUpdateDirectory'), $directory)) { + if (call_user_func(array('drupal\\' . $class, 'canUpdateDirectory'), $directory)) { return $class; } } diff --git a/core/includes/uuid.inc b/core/includes/uuid.inc index e220586..fc63345 100644 --- a/core/includes/uuid.inc +++ b/core/includes/uuid.inc @@ -38,7 +38,7 @@ class Uuid { * This constructor instantiates the correct UUID object. */ public function __construct() { - $class = $this->determinePlugin(); + $class = 'drupal\\' . $this->determinePlugin(); $this->plugin = new $class(); } diff --git a/core/includes/xmlrpc.inc b/core/includes/xmlrpc.inc index cad18ee..94696ab 100644 --- a/core/includes/xmlrpc.inc +++ b/core/includes/xmlrpc.inc @@ -177,8 +177,8 @@ function xmlrpc_message_parse($xmlrpc_message) { // Set XML parser to take the case of tags into account. xml_parser_set_option($xmlrpc_message->_parser, XML_OPTION_CASE_FOLDING, FALSE); // Set XML parser callback functions - xml_set_element_handler($xmlrpc_message->_parser, 'xmlrpc_message_tag_open', 'xmlrpc_message_tag_close'); - xml_set_character_data_handler($xmlrpc_message->_parser, 'xmlrpc_message_cdata'); + xml_set_element_handler($xmlrpc_message->_parser, 'drupal\xmlrpc_message_tag_open', 'drupal\xmlrpc_message_tag_close'); + xml_set_character_data_handler($xmlrpc_message->_parser, 'drupal\xmlrpc_message_cdata'); xmlrpc_message_set($xmlrpc_message); if (!xml_parse($xmlrpc_message->_parser, $xmlrpc_message->message)) { return FALSE; diff --git a/core/includes/xmlrpcs.inc b/core/includes/xmlrpcs.inc index 323a314..da8e215 100644 --- a/core/includes/xmlrpcs.inc +++ b/core/includes/xmlrpcs.inc @@ -186,7 +186,7 @@ function xmlrpc_server_call($xmlrpc_server, $methodname, $args) { if (!isset($xmlrpc_server->callbacks[$methodname])) { return xmlrpc_error(-32601, t('Server error. Requested method @methodname not specified.', array("@methodname" => $xmlrpc_server->message->methodname))); } - $method = $xmlrpc_server->callbacks[$methodname]; + $method = 'drupal\\' . $xmlrpc_server->callbacks[$methodname]; $signature = $xmlrpc_server->signatures[$methodname]; // If the method has a signature, validate the request against the signature diff --git a/core/modules/aggregator/aggregator.admin.inc b/core/modules/aggregator/aggregator.admin.inc index 9e8852a..9ee66d3 100644 --- a/core/modules/aggregator/aggregator.admin.inc +++ b/core/modules/aggregator/aggregator.admin.inc @@ -73,7 +73,7 @@ function aggregator_view() { * @see aggregator_form_feed_submit() */ function aggregator_form_feed($form, &$form_state, stdClass $feed = NULL) { - $period = map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval'); + $period = map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'drupal\format_interval'); $period[AGGREGATOR_CLEAR_NEVER] = t('Never'); $form['title'] = array('#type' => 'textfield', @@ -262,7 +262,7 @@ function aggregator_admin_remove_feed_submit($form, &$form_state) { * @see aggregator_form_opml_submit() */ function aggregator_form_opml($form, &$form_state) { - $period = map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval'); + $period = map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'drupal\format_interval'); $form['upload'] = array( '#type' => 'file', @@ -290,7 +290,7 @@ function aggregator_form_opml($form, &$form_state) { ); // Handling of categories. - $options = array_map('check_plain', db_query("SELECT cid, title FROM {aggregator_category} ORDER BY title")->fetchAllKeyed()); + $options = array_map('drupal\check_plain', db_query("SELECT cid, title FROM {aggregator_category} ORDER BY title")->fetchAllKeyed()); if ($options) { $form['category'] = array( '#type' => 'checkboxes', diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 11adab1..baf25c5 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -673,7 +673,7 @@ function aggregator_refresh($feed) { ->execute(); // Expire old feed items. - if (function_exists('aggregator_expire')) { + if (function_exists('drupal\aggregator_expire')) { aggregator_expire($feed); } } diff --git a/core/modules/aggregator/aggregator.parser.inc b/core/modules/aggregator/aggregator.parser.inc index f8de6e7..2da57c5 100644 --- a/core/modules/aggregator/aggregator.parser.inc +++ b/core/modules/aggregator/aggregator.parser.inc @@ -76,8 +76,8 @@ function aggregator_parse_feed(&$data, $feed) { // Parse the data. $xml_parser = drupal_xml_parser_create($data); - xml_set_element_handler($xml_parser, 'aggregator_element_start', 'aggregator_element_end'); - xml_set_character_data_handler($xml_parser, 'aggregator_element_data'); + xml_set_element_handler($xml_parser, 'drupal\aggregator_element_start', 'drupal\aggregator_element_end'); + xml_set_character_data_handler($xml_parser, 'drupal\aggregator_element_data'); if (!xml_parse($xml_parser, $data, 1)) { watchdog('aggregator', 'The feed from %site seems to be broken due to an error "%error" on line %line.', array('%site' => $feed->title, '%error' => xml_error_string(xml_get_error_code($xml_parser)), '%line' => xml_get_current_line_number($xml_parser)), WATCHDOG_WARNING); diff --git a/core/modules/aggregator/aggregator.processor.inc b/core/modules/aggregator/aggregator.processor.inc index 7c4da66..b07ce24 100644 --- a/core/modules/aggregator/aggregator.processor.inc +++ b/core/modules/aggregator/aggregator.processor.inc @@ -73,8 +73,8 @@ function aggregator_aggregator_remove($feed) { function aggregator_form_aggregator_admin_form_alter(&$form, $form_state) { if (in_array('aggregator', variable_get('aggregator_processors', array('aggregator')))) { $info = module_invoke('aggregator', 'aggregator_process', 'info'); - $items = map_assoc(array(3, 5, 10, 15, 20, 25), '_aggregator_items'); - $period = map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval'); + $items = map_assoc(array(3, 5, 10, 15, 20, 25), 'drupal\_aggregator_items'); + $period = map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'drupal\format_interval'); $period[AGGREGATOR_CLEAR_NEVER] = t('Never'); // Only wrap into a collapsible fieldset if there is a basic configuration. @@ -119,7 +119,7 @@ function aggregator_form_aggregator_admin_form_alter(&$form, $form_state) { '#type' => 'select', '#title' => t('Length of trimmed description'), '#default_value' => variable_get('aggregator_teaser_length', 600), - '#options' => map_assoc(array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000), '_aggregator_characters'), + '#options' => map_assoc(array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000), 'drupal\_aggregator_characters'), '#description' => t("The maximum number of characters used in the trimmed version of content.") ); diff --git a/core/modules/block/block.admin.inc b/core/modules/block/block.admin.inc index 31a633c..7dea801 100644 --- a/core/modules/block/block.admin.inc +++ b/core/modules/block/block.admin.inc @@ -60,9 +60,9 @@ function block_admin_display($theme = NULL) { */ function block_admin_display_prepare_blocks($theme) { $blocks = _block_rehash($theme); - $compare_theme = &drupal_static('_block_compare:theme'); + $compare_theme = &drupal_static('drupal\_block_compare:theme'); $compare_theme = $theme; - usort($blocks, '_block_compare'); + usort($blocks, 'drupal\_block_compare'); return $blocks; } @@ -405,7 +405,7 @@ function block_admin_configure($form, &$form_state, $module, $delta) { ':module' => $block->module, ':delta' => $block->delta, ))->fetchCol(); - $role_options = array_map('check_plain', user_roles()); + $role_options = array_map('drupal\check_plain', user_roles()); $form['visibility']['role'] = array( '#type' => 'fieldset', '#title' => t('Roles'), diff --git a/core/modules/book/book.module b/core/modules/book/book.module index e13fb3e..ceb2a08 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -1247,7 +1247,7 @@ function book_export_traverse($tree, $visit_func) { } if (!empty($visit_func)) { - $output .= call_user_func($visit_func, $node, $children); + $output .= call_user_func('drupal\\' . $visit_func, $node, $children); } else { // Use the default function. diff --git a/core/modules/book/book.pages.inc b/core/modules/book/book.pages.inc index 7dcb206..156b312 100644 --- a/core/modules/book/book.pages.inc +++ b/core/modules/book/book.pages.inc @@ -49,7 +49,7 @@ function book_render() { function book_export($type, $nid) { $type = drupal_strtolower($type); - $export_function = 'book_export_' . $type; + $export_function = 'drupal\book_export_' . $type; if (function_exists($export_function)) { print call_user_func($export_function, $nid); diff --git a/core/modules/color/color.module b/core/modules/color/color.module index 66f404b..5204a6d 100644 --- a/core/modules/color/color.module +++ b/core/modules/color/color.module @@ -428,7 +428,7 @@ function color_scheme_form_submit($form, &$form_state) { _build_css_path(NULL, $base); // Prefix all paths within this CSS file, ignoring absolute paths. - $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', '_build_css_path', $style); + $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', 'drupal\_build_css_path', $style); // Rewrite stylesheet with new colors. $style = _color_rewrite_stylesheet($theme, $info, $paths, $palette, $style); diff --git a/core/modules/entity/entity.class.inc b/core/modules/entity/entity.class.inc index 04448e7..c18008e 100644 --- a/core/modules/entity/entity.class.inc +++ b/core/modules/entity/entity.class.inc @@ -207,8 +207,8 @@ class Entity implements EntityInterface { */ public function label() { $label = FALSE; - if (isset($this->entityInfo['label callback']) && function_exists($this->entityInfo['label callback'])) { - $label = $this->entityInfo['label callback']($this->entityType, $this); + if (isset($this->entityInfo['label callback']) && function_exists($function = 'drupal\\' . $this->entityInfo['label callback'])) { + $label = $function($this->entityType, $this); } elseif (!empty($this->entityInfo['entity keys']['label']) && isset($this->{$this->entityInfo['entity keys']['label']})) { $label = $this->{$this->entityInfo['entity keys']['label']}; @@ -236,13 +236,16 @@ class Entity implements EntityInterface { } // Invoke the callback to get the URI. If there is no callback, return NULL. - if (isset($uri_callback) && function_exists($uri_callback)) { - $uri = $uri_callback($this); - // Pass the entity data to url() so that alter functions do not need to - // look up this entity again. - $uri['options']['entity_type'] = $this->entityType; - $uri['options']['entity'] = $this; - return $uri; + if (isset($uri_callback)) { + $function = 'drupal\\' . $uri_callback; + if (function_exists($function)) { + $uri = $function($this); + // Pass the entity data to url() so that alter functions do not need to + // look up this entity again. + $uri['options']['entity_type'] = $this->entityType; + $uri['options']['entity'] = $this; + return $uri; + } } } diff --git a/core/modules/entity/entity.controller.inc b/core/modules/entity/entity.controller.inc index 3a10536..7b45e20 100644 --- a/core/modules/entity/entity.controller.inc +++ b/core/modules/entity/entity.controller.inc @@ -207,7 +207,7 @@ class DefaultEntityController implements EntityControllerInterface { // We provide the necessary arguments for PDO to create objects of the // specified entity class. // @see EntityInterface::__construct() - $query_result->setFetchMode(PDO::FETCH_CLASS, $this->entityInfo['entity class'], array(array(), $this->entityType)); + $query_result->setFetchMode(PDO::FETCH_CLASS, 'drupal\\' . $this->entityInfo['entity class'], array(array(), $this->entityType)); } $queried_entities = $query_result->fetchAllAssoc($this->idKey); } @@ -339,7 +339,7 @@ class DefaultEntityController implements EntityControllerInterface { // Call hook_entity_load(). foreach (module_implements('entity_load') as $module) { - $function = $module . '_entity_load'; + $function = 'drupal\\' . $module . '_entity_load'; $function($queried_entities, $this->entityType); } // Call hook_TYPE_load(). The first argument for hook_TYPE_load() are @@ -347,7 +347,7 @@ class DefaultEntityController implements EntityControllerInterface { // $this->hookLoadArguments. $args = array_merge(array($queried_entities), $this->hookLoadArguments); foreach (module_implements($this->entityInfo['load hook']) as $module) { - call_user_func_array($module . '_' . $this->entityInfo['load hook'], $args); + call_user_func_array('drupal\\' . $module . '_' . $this->entityInfo['load hook'], $args); } } @@ -559,8 +559,11 @@ class EntityDatabaseStorageController extends DefaultEntityController implements * The entity object. */ protected function invokeHook($hook, EntityInterface $entity) { - if (!empty($this->entityInfo['fieldable']) && function_exists($function = 'field_attach_' . $hook)) { - $function($this->entityType, $entity); + if (!empty($this->entityInfo['fieldable'])) { + $function = 'drupal\field_attach_' . $hook; + if (function_exists($function)) { + $function($this->entityType, $entity); + } } // Invoke the hook. module_invoke_all($this->entityType . '_' . $hook, $entity); diff --git a/core/modules/entity/entity.module b/core/modules/entity/entity.module index a6015b6..8112ae9 100644 --- a/core/modules/entity/entity.module +++ b/core/modules/entity/entity.module @@ -284,7 +284,7 @@ function entity_delete_multiple($entity_type, $ids) { */ function entity_create($entity_type, array $values) { $info = entity_get_info($entity_type) + array('entity class' => 'Entity'); - $class = $info['entity class']; + $class = 'drupal\\' . $info['entity class']; return new $class($values, $entity_type); } @@ -295,7 +295,7 @@ function entity_get_controller($entity_type) { $controllers = &drupal_static(__FUNCTION__, array()); if (!isset($controllers[$entity_type])) { $type_info = entity_get_info($entity_type); - $class = $type_info['controller class']; + $class = 'drupal\\' . $type_info['controller class']; $controllers[$entity_type] = new $class($entity_type); } return $controllers[$entity_type]; @@ -376,7 +376,8 @@ function entity_uri($entity_type, $entity) { // Invoke the callback to get the URI. If there is no callback, return NULL. if (isset($uri_callback)) { - $uri = $uri_callback($entity); + $function = 'drupal\\' . $uri_callback; + $uri = $function($entity); // Pass the entity data to url() so that alter functions do not need to // lookup this entity again. $uri['options']['entity_type'] = $entity_type; @@ -406,7 +407,8 @@ function entity_label($entity_type, $entity) { $label = FALSE; $info = entity_get_info($entity_type); if (isset($info['label callback'])) { - $label = $info['label callback']($entity_type, $entity); + $function = 'drupal\\' . $info['label callback']; + $label = $function($entity_type, $entity); } elseif (!empty($info['entity keys']['label']) && isset($entity->{$info['entity keys']['label']})) { $label = $entity->{$info['entity keys']['label']}; @@ -464,6 +466,7 @@ function entity_form_submit_build_entity($entity_type, $entity, $form, &$form_st // Invoke all specified builders for copying form values to entity properties. if (isset($form['#entity_builders'])) { foreach ($form['#entity_builders'] as $function) { + $function = 'drupal\\' . $function; $function($entity_type, $entity, $form, $form_state); } } diff --git a/core/modules/entity/entity.query.inc b/core/modules/entity/entity.query.inc index de0d67f..53c79e0 100644 --- a/core/modules/entity/entity.query.inc +++ b/core/modules/entity/entity.query.inc @@ -755,8 +755,9 @@ class EntityFieldQuery { public function queryCallback() { // Use the override from $this->executeCallback. It can be set either // while building the query, or using hook_entity_query_alter(). - if (function_exists($this->executeCallback)) { - return $this->executeCallback; + $function = 'drupal\\' . $this->executeCallback; + if (function_exists($function)) { + return $function; } // If there are no field conditions and sorts, and no execute callback // then we default to querying entity tables in SQL. @@ -774,7 +775,7 @@ class EntityFieldQuery { } if ($storage) { // Use hook_field_storage_query() from the field storage. - return $storage . '_field_storage_query'; + return 'drupal\\' . $storage . '_field_storage_query'; } else { throw new EntityFieldQueryException(t("Field storage engine not found.")); diff --git a/core/modules/entity/tests/entity_crud_hook_test.test b/core/modules/entity/tests/entity_crud_hook_test.test index 4da1095..f03bfbf 100644 --- a/core/modules/entity/tests/entity_crud_hook_test.test +++ b/core/modules/entity/tests/entity_crud_hook_test.test @@ -88,18 +88,18 @@ class EntityCrudHookTestCase extends WebTestCase { comment_save($comment); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_comment_presave called', - 'entity_crud_hook_test_entity_presave called for type comment', - 'entity_crud_hook_test_comment_insert called', - 'entity_crud_hook_test_entity_insert called for type comment', + 'drupal\entity_crud_hook_test_comment_presave called', + 'drupal\entity_crud_hook_test_entity_presave called for type comment', + 'drupal\entity_crud_hook_test_comment_insert called', + 'drupal\entity_crud_hook_test_entity_insert called for type comment', )); $_SESSION['entity_crud_hook_test'] = array(); $comment = comment_load($comment->cid); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_entity_load called for type comment', - 'entity_crud_hook_test_comment_load called', + 'drupal\entity_crud_hook_test_entity_load called for type comment', + 'drupal\entity_crud_hook_test_comment_load called', )); $_SESSION['entity_crud_hook_test'] = array(); @@ -107,20 +107,20 @@ class EntityCrudHookTestCase extends WebTestCase { comment_save($comment); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_comment_presave called', - 'entity_crud_hook_test_entity_presave called for type comment', - 'entity_crud_hook_test_comment_update called', - 'entity_crud_hook_test_entity_update called for type comment', + 'drupal\entity_crud_hook_test_comment_presave called', + 'drupal\entity_crud_hook_test_entity_presave called for type comment', + 'drupal\entity_crud_hook_test_comment_update called', + 'drupal\entity_crud_hook_test_entity_update called for type comment', )); $_SESSION['entity_crud_hook_test'] = array(); comment_delete($comment->cid); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_comment_predelete called', - 'entity_crud_hook_test_entity_predelete called for type comment', - 'entity_crud_hook_test_comment_delete called', - 'entity_crud_hook_test_entity_delete called for type comment', + 'drupal\entity_crud_hook_test_comment_predelete called', + 'drupal\entity_crud_hook_test_entity_predelete called for type comment', + 'drupal\entity_crud_hook_test_comment_delete called', + 'drupal\entity_crud_hook_test_entity_delete called for type comment', )); } @@ -144,18 +144,18 @@ class EntityCrudHookTestCase extends WebTestCase { file_save($file); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_file_presave called', - 'entity_crud_hook_test_entity_presave called for type file', - 'entity_crud_hook_test_file_insert called', - 'entity_crud_hook_test_entity_insert called for type file', + 'drupal\entity_crud_hook_test_file_presave called', + 'drupal\entity_crud_hook_test_entity_presave called for type file', + 'drupal\entity_crud_hook_test_file_insert called', + 'drupal\entity_crud_hook_test_entity_insert called for type file', )); $_SESSION['entity_crud_hook_test'] = array(); $file = file_load($file->fid); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_entity_load called for type file', - 'entity_crud_hook_test_file_load called', + 'drupal\entity_crud_hook_test_entity_load called for type file', + 'drupal\entity_crud_hook_test_file_load called', )); $_SESSION['entity_crud_hook_test'] = array(); @@ -163,20 +163,20 @@ class EntityCrudHookTestCase extends WebTestCase { file_save($file); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_file_presave called', - 'entity_crud_hook_test_entity_presave called for type file', - 'entity_crud_hook_test_file_update called', - 'entity_crud_hook_test_entity_update called for type file', + 'drupal\entity_crud_hook_test_file_presave called', + 'drupal\entity_crud_hook_test_entity_presave called for type file', + 'drupal\entity_crud_hook_test_file_update called', + 'drupal\entity_crud_hook_test_entity_update called for type file', )); $_SESSION['entity_crud_hook_test'] = array(); file_delete($file); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_file_predelete called', - 'entity_crud_hook_test_entity_predelete called for type file', - 'entity_crud_hook_test_file_delete called', - 'entity_crud_hook_test_entity_delete called for type file', + 'drupal\entity_crud_hook_test_file_predelete called', + 'drupal\entity_crud_hook_test_entity_predelete called for type file', + 'drupal\entity_crud_hook_test_file_delete called', + 'drupal\entity_crud_hook_test_entity_delete called for type file', )); } @@ -200,18 +200,18 @@ class EntityCrudHookTestCase extends WebTestCase { node_save($node); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_node_presave called', - 'entity_crud_hook_test_entity_presave called for type node', - 'entity_crud_hook_test_node_insert called', - 'entity_crud_hook_test_entity_insert called for type node', + 'drupal\entity_crud_hook_test_node_presave called', + 'drupal\entity_crud_hook_test_entity_presave called for type node', + 'drupal\entity_crud_hook_test_node_insert called', + 'drupal\entity_crud_hook_test_entity_insert called for type node', )); $_SESSION['entity_crud_hook_test'] = array(); $node = node_load($node->nid); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_entity_load called for type node', - 'entity_crud_hook_test_node_load called', + 'drupal\entity_crud_hook_test_entity_load called for type node', + 'drupal\entity_crud_hook_test_node_load called', )); $_SESSION['entity_crud_hook_test'] = array(); @@ -219,20 +219,20 @@ class EntityCrudHookTestCase extends WebTestCase { node_save($node); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_node_presave called', - 'entity_crud_hook_test_entity_presave called for type node', - 'entity_crud_hook_test_node_update called', - 'entity_crud_hook_test_entity_update called for type node', + 'drupal\entity_crud_hook_test_node_presave called', + 'drupal\entity_crud_hook_test_entity_presave called for type node', + 'drupal\entity_crud_hook_test_node_update called', + 'drupal\entity_crud_hook_test_entity_update called for type node', )); $_SESSION['entity_crud_hook_test'] = array(); node_delete($node->nid); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_node_predelete called', - 'entity_crud_hook_test_entity_predelete called for type node', - 'entity_crud_hook_test_node_delete called', - 'entity_crud_hook_test_entity_delete called for type node', + 'drupal\entity_crud_hook_test_node_predelete called', + 'drupal\entity_crud_hook_test_entity_predelete called for type node', + 'drupal\entity_crud_hook_test_node_delete called', + 'drupal\entity_crud_hook_test_entity_delete called for type node', )); } @@ -258,18 +258,18 @@ class EntityCrudHookTestCase extends WebTestCase { taxonomy_term_save($term); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_taxonomy_term_presave called', - 'entity_crud_hook_test_entity_presave called for type taxonomy_term', - 'entity_crud_hook_test_taxonomy_term_insert called', - 'entity_crud_hook_test_entity_insert called for type taxonomy_term', + 'drupal\entity_crud_hook_test_taxonomy_term_presave called', + 'drupal\entity_crud_hook_test_entity_presave called for type taxonomy_term', + 'drupal\entity_crud_hook_test_taxonomy_term_insert called', + 'drupal\entity_crud_hook_test_entity_insert called for type taxonomy_term', )); $_SESSION['entity_crud_hook_test'] = array(); $term = taxonomy_term_load($term->tid); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_entity_load called for type taxonomy_term', - 'entity_crud_hook_test_taxonomy_term_load called', + 'drupal\entity_crud_hook_test_entity_load called for type taxonomy_term', + 'drupal\entity_crud_hook_test_taxonomy_term_load called', )); $_SESSION['entity_crud_hook_test'] = array(); @@ -277,20 +277,20 @@ class EntityCrudHookTestCase extends WebTestCase { taxonomy_term_save($term); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_taxonomy_term_presave called', - 'entity_crud_hook_test_entity_presave called for type taxonomy_term', - 'entity_crud_hook_test_taxonomy_term_update called', - 'entity_crud_hook_test_entity_update called for type taxonomy_term', + 'drupal\entity_crud_hook_test_taxonomy_term_presave called', + 'drupal\entity_crud_hook_test_entity_presave called for type taxonomy_term', + 'drupal\entity_crud_hook_test_taxonomy_term_update called', + 'drupal\entity_crud_hook_test_entity_update called for type taxonomy_term', )); $_SESSION['entity_crud_hook_test'] = array(); taxonomy_term_delete($term->tid); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_taxonomy_term_predelete called', - 'entity_crud_hook_test_entity_predelete called for type taxonomy_term', - 'entity_crud_hook_test_taxonomy_term_delete called', - 'entity_crud_hook_test_entity_delete called for type taxonomy_term', + 'drupal\entity_crud_hook_test_taxonomy_term_predelete called', + 'drupal\entity_crud_hook_test_entity_predelete called for type taxonomy_term', + 'drupal\entity_crud_hook_test_taxonomy_term_delete called', + 'drupal\entity_crud_hook_test_entity_delete called for type taxonomy_term', )); } @@ -308,18 +308,18 @@ class EntityCrudHookTestCase extends WebTestCase { taxonomy_vocabulary_save($vocabulary); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_taxonomy_vocabulary_presave called', - 'entity_crud_hook_test_entity_presave called for type taxonomy_vocabulary', - 'entity_crud_hook_test_taxonomy_vocabulary_insert called', - 'entity_crud_hook_test_entity_insert called for type taxonomy_vocabulary', + 'drupal\entity_crud_hook_test_taxonomy_vocabulary_presave called', + 'drupal\entity_crud_hook_test_entity_presave called for type taxonomy_vocabulary', + 'drupal\entity_crud_hook_test_taxonomy_vocabulary_insert called', + 'drupal\entity_crud_hook_test_entity_insert called for type taxonomy_vocabulary', )); $_SESSION['entity_crud_hook_test'] = array(); $vocabulary = taxonomy_vocabulary_load($vocabulary->vid); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_entity_load called for type taxonomy_vocabulary', - 'entity_crud_hook_test_taxonomy_vocabulary_load called', + 'drupal\entity_crud_hook_test_entity_load called for type taxonomy_vocabulary', + 'drupal\entity_crud_hook_test_taxonomy_vocabulary_load called', )); $_SESSION['entity_crud_hook_test'] = array(); @@ -327,20 +327,20 @@ class EntityCrudHookTestCase extends WebTestCase { taxonomy_vocabulary_save($vocabulary); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_taxonomy_vocabulary_presave called', - 'entity_crud_hook_test_entity_presave called for type taxonomy_vocabulary', - 'entity_crud_hook_test_taxonomy_vocabulary_update called', - 'entity_crud_hook_test_entity_update called for type taxonomy_vocabulary', + 'drupal\entity_crud_hook_test_taxonomy_vocabulary_presave called', + 'drupal\entity_crud_hook_test_entity_presave called for type taxonomy_vocabulary', + 'drupal\entity_crud_hook_test_taxonomy_vocabulary_update called', + 'drupal\entity_crud_hook_test_entity_update called for type taxonomy_vocabulary', )); $_SESSION['entity_crud_hook_test'] = array(); taxonomy_vocabulary_delete($vocabulary->vid); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_taxonomy_vocabulary_predelete called', - 'entity_crud_hook_test_entity_predelete called for type taxonomy_vocabulary', - 'entity_crud_hook_test_taxonomy_vocabulary_delete called', - 'entity_crud_hook_test_entity_delete called for type taxonomy_vocabulary', + 'drupal\entity_crud_hook_test_taxonomy_vocabulary_predelete called', + 'drupal\entity_crud_hook_test_entity_predelete called for type taxonomy_vocabulary', + 'drupal\entity_crud_hook_test_taxonomy_vocabulary_delete called', + 'drupal\entity_crud_hook_test_entity_delete called for type taxonomy_vocabulary', )); } @@ -360,18 +360,18 @@ class EntityCrudHookTestCase extends WebTestCase { $account = user_save($account, $edit); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_user_presave called', - 'entity_crud_hook_test_entity_presave called for type user', - 'entity_crud_hook_test_user_insert called', - 'entity_crud_hook_test_entity_insert called for type user', + 'drupal\entity_crud_hook_test_user_presave called', + 'drupal\entity_crud_hook_test_entity_presave called for type user', + 'drupal\entity_crud_hook_test_user_insert called', + 'drupal\entity_crud_hook_test_entity_insert called for type user', )); $_SESSION['entity_crud_hook_test'] = array(); $account = user_load($account->uid); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_entity_load called for type user', - 'entity_crud_hook_test_user_load called', + 'drupal\entity_crud_hook_test_entity_load called for type user', + 'drupal\entity_crud_hook_test_user_load called', )); $_SESSION['entity_crud_hook_test'] = array(); @@ -379,20 +379,20 @@ class EntityCrudHookTestCase extends WebTestCase { $account = user_save($account, $edit); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_user_presave called', - 'entity_crud_hook_test_entity_presave called for type user', - 'entity_crud_hook_test_user_update called', - 'entity_crud_hook_test_entity_update called for type user', + 'drupal\entity_crud_hook_test_user_presave called', + 'drupal\entity_crud_hook_test_entity_presave called for type user', + 'drupal\entity_crud_hook_test_user_update called', + 'drupal\entity_crud_hook_test_entity_update called for type user', )); $_SESSION['entity_crud_hook_test'] = array(); user_delete($account->uid); $this->assertHookMessageOrder(array( - 'entity_crud_hook_test_user_predelete called', - 'entity_crud_hook_test_entity_predelete called for type user', - 'entity_crud_hook_test_user_delete called', - 'entity_crud_hook_test_entity_delete called for type user', + 'drupal\entity_crud_hook_test_user_predelete called', + 'drupal\entity_crud_hook_test_entity_predelete called for type user', + 'drupal\entity_crud_hook_test_user_delete called', + 'drupal\entity_crud_hook_test_entity_delete called for type user', )); } diff --git a/core/modules/entity/tests/entity_query.test b/core/modules/entity/tests/entity_query.test index 5a3f779..971a1ab 100644 --- a/core/modules/entity/tests/entity_query.test +++ b/core/modules/entity/tests/entity_query.test @@ -1227,14 +1227,14 @@ class EntityFieldQueryTestCase extends WebTestCase { // Field-only query. $query = new EntityFieldQuery(); $query->fieldCondition($this->fields[0], 'value', '3'); - $this->assertIdentical($query->queryCallback(), 'field_sql_storage_field_storage_query', t('Pure field queries are handled by the Field storage handler.')); + $this->assertIdentical($query->queryCallback(), 'drupal\field_sql_storage_field_storage_query', t('Pure field queries are handled by the Field storage handler.')); // Mixed entity and field query. $query = new EntityFieldQuery(); $query ->entityCondition('entity_type', 'test_entity_bundle_key') ->fieldCondition($this->fields[0], 'value', '3'); - $this->assertIdentical($query->queryCallback(), 'field_sql_storage_field_storage_query', t('Mixed queries are handled by the Field storage handler.')); + $this->assertIdentical($query->queryCallback(), 'drupal\field_sql_storage_field_storage_query', t('Mixed queries are handled by the Field storage handler.')); // Overriding with $query->executeCallback. $query = new EntityFieldQuery(); diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index fa76bcc..05ff412 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -198,7 +198,7 @@ function _field_invoke($op, $entity_type, $entity, &$a = NULL, &$b = NULL, $opti foreach ($instances as $instance) { $field_name = $instance['field_name']; $field = field_info_field($field_name); - $function = $options['default'] ? 'field_default_' . $op : $field['module'] . '_field_' . $op; + $function = $options['default'] ? ('drupal\field_default_' . $op) : ('drupal\\' . $field['module'] . '_field_' . $op); if (function_exists($function)) { // Determine the list of languages to iterate on. $available_languages = field_available_languages($entity_type, $field); @@ -308,7 +308,7 @@ function _field_invoke_multiple($op, $entity_type, $entities, &$a = NULL, &$b = $field_id = $instance['field_id']; $field_name = $instance['field_name']; $field = $field_info[$field_id]; - $function = $options['default'] ? 'field_default_' . $op : $field['module'] . '_field_' . $op; + $function = $options['default'] ? ('drupal\field_default_' . $op) : ('drupal\\' . $field['module'] . '_field_' . $op); if (function_exists($function)) { // Add the field to the list of fields to invoke the hook on. if (!isset($fields[$field_id])) { @@ -337,7 +337,7 @@ function _field_invoke_multiple($op, $entity_type, $entities, &$a = NULL, &$b = // For each field, invoke the field hook and collect results. foreach ($fields as $field_id => $field) { $field_name = $field['field_name']; - $function = $options['default'] ? 'field_default_' . $op : $field['module'] . '_field_' . $op; + $function = $options['default'] ? ('drupal\field_default_' . $op) : ('drupal\\' . $field['module'] . '_field_' . $op); // Iterate over all the field translations. foreach ($grouped_items[$field_id] as $langcode => &$items) { $entities = $grouped_entities[$field_id][$langcode]; @@ -576,7 +576,7 @@ function field_attach_form($entity_type, $entity, &$form, &$form_state, $langcod // Let other modules make changes to the form. // Avoid module_invoke_all() to let parameters be taken by reference. foreach (module_implements('field_attach_form') as $module) { - $function = $module . '_field_attach_form'; + $function = 'drupal\\' . $module . '_field_attach_form'; $function($entity_type, $entity, $form, $form_state, $langcode); } } @@ -671,7 +671,7 @@ function field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $ // data before the storage engine, accumulating along the way. $skip_fields = array(); foreach (module_implements('field_storage_pre_load') as $module) { - $function = $module . '_field_storage_pre_load'; + $function = 'drupal\\' . $module . '_field_storage_pre_load'; $function($entity_type, $queried_entities, $age, $skip_fields, $options); } @@ -779,7 +779,7 @@ function field_attach_validate($entity_type, $entity) { // Let other modules validate the entity. // Avoid module_invoke_all() to let $errors be taken by reference. foreach (module_implements('field_attach_validate') as $module) { - $function = $module . '_field_attach_validate'; + $function = 'drupal\\' . $module . '_field_attach_validate'; $function($entity_type, $entity, $errors); } @@ -866,7 +866,7 @@ function field_attach_submit($entity_type, $entity, $form, &$form_state) { // Let other modules act on submitting the entity. // Avoid module_invoke_all() to let $form_state be taken by reference. foreach (module_implements('field_attach_submit') as $module) { - $function = $module . '_field_attach_submit'; + $function = 'drupal\\' . $module . '_field_attach_submit'; $function($entity_type, $entity, $form, $form_state); } } @@ -915,7 +915,7 @@ function field_attach_insert($entity_type, $entity) { // saved fields along the way. $skip_fields = array(); foreach (module_implements('field_storage_pre_insert') as $module) { - $function = $module . '_field_storage_pre_insert'; + $function = 'drupal\\' . $module . '_field_storage_pre_insert'; $function($entity_type, $entity, $skip_fields); } @@ -962,7 +962,7 @@ function field_attach_update($entity_type, $entity) { // saved fields along the way. $skip_fields = array(); foreach (module_implements('field_storage_pre_update') as $module) { - $function = $module . '_field_storage_pre_update'; + $function = 'drupal\\' . $module . '_field_storage_pre_update'; $function($entity_type, $entity, $skip_fields); } diff --git a/core/modules/field/field.crud.inc b/core/modules/field/field.crud.inc index d4678d9..e9e89a1 100644 --- a/core/modules/field/field.crud.inc +++ b/core/modules/field/field.crud.inc @@ -260,7 +260,7 @@ function field_update_field($field) { // See if any module forbids the update by throwing an exception. foreach (module_implements('field_update_forbid') as $module) { - $function = $module . '_field_update_forbid'; + $function = 'drupal\\' . $module . '_field_update_forbid'; $function($field, $prior_field, $has_data); } @@ -915,7 +915,7 @@ function field_purge_data($entity_type, $entity, $field, $instance) { // Let other modules act on purging the data. foreach (module_implements('field_attach_purge') as $module) { - $function = $module . '_field_attach_purge'; + $function = 'drupal\\' . $module . '_field_attach_purge'; $function($entity_type, $entity, $field, $instance); } } diff --git a/core/modules/field/field.default.inc b/core/modules/field/field.default.inc index 1f23328..4c1262c 100644 --- a/core/modules/field/field.default.inc +++ b/core/modules/field/field.default.inc @@ -161,7 +161,7 @@ function field_default_prepare_view($entity_type, $entities, $field, $instances, foreach ($modules as $module) { // Invoke hook_field_formatter_prepare_view(). - $function = $module . '_field_formatter_prepare_view'; + $function = 'drupal\\' . $module . '_field_formatter_prepare_view'; if (function_exists($function)) { $function($entity_type, $grouped_entities[$module], $field, $grouped_instances[$module], $langcode, $grouped_items[$module], $grouped_displays[$module]); } @@ -206,7 +206,7 @@ function field_default_view($entity_type, $entity, $field, $instance, $langcode, if ($display['type'] !== 'hidden') { // Calling the formatter function through module_invoke() can have a // performance impact on pages with many fields and values. - $function = $display['module'] . '_field_formatter_view'; + $function = 'drupal\\' . $display['module'] . '_field_formatter_view'; if (function_exists($function)) { $elements = $function($entity_type, $entity, $field, $instance, $langcode, $items, $display); diff --git a/core/modules/field/field.form.inc b/core/modules/field/field.form.inc index e82abb9..cd075f6 100644 --- a/core/modules/field/field.form.inc +++ b/core/modules/field/field.form.inc @@ -61,7 +61,7 @@ function field_default_form($entity_type, $entity, $field, $instance, $langcode, // make it the $delta value. else { $delta = isset($get_delta) ? $get_delta : 0; - $function = $instance['widget']['module'] . '_field_widget_form'; + $function = 'drupal\\' . $instance['widget']['module'] . '_field_widget_form'; if (function_exists($function)) { $element = array( '#entity_type' => $instance['entity_type'], @@ -171,7 +171,7 @@ function field_multiple_value_form($field, $instance, $langcode, $items, &$form, $field_elements = array(); - $function = $instance['widget']['module'] . '_field_widget_form'; + $function = 'drupal\\' . $instance['widget']['module'] . '_field_widget_form'; if (function_exists($function)) { for ($delta = 0; $delta <= $max; $delta++) { $multiple = $field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED; @@ -297,7 +297,7 @@ function theme_field_multiple_value_form($variables) { $items[] = &$element[$key]; } } - usort($items, '_field_sort_items_value_helper'); + usort($items, 'drupal\_field_sort_items_value_helper'); // Add the items as table rows. foreach ($items as $key => $item) { @@ -359,7 +359,7 @@ function field_default_form_errors($entity_type, $entity, $field, $instance, $la $field_state = field_form_get_state($form['#parents'], $field['field_name'], $langcode, $form_state); if (!empty($field_state['errors'])) { - $function = $instance['widget']['module'] . '_field_widget_error'; + $function = 'drupal\\' . $instance['widget']['module'] . '_field_widget_error'; $function_exists = function_exists($function); // Locate the correct element in the the form. diff --git a/core/modules/field/field.module b/core/modules/field/field.module index fda64a0..f0ec15d 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -484,7 +484,7 @@ function field_associate_fields($module) { function field_get_default_value($entity_type, $entity, $field, $instance, $langcode = NULL) { $items = array(); if (!empty($instance['default_value_function'])) { - $function = $instance['default_value_function']; + $function = 'drupal\\' . $instance['default_value_function']; $items = $function($entity_type, $entity, $field, $instance, $langcode); } elseif (!empty($instance['default_value'])) { @@ -506,7 +506,7 @@ function field_get_default_value($entity_type, $entity, $field, $instance, $lang * the array keys to ensure sequential deltas. */ function _field_filter_items($field, $items) { - $function = $field['module'] . '_field_is_empty'; + $function = 'drupal\\' . $field['module'] . '_field_is_empty'; foreach ((array) $items as $delta => $item) { // Explicitly break if the function is undefined. if ($function($item, $field)) { @@ -522,7 +522,7 @@ function _field_filter_items($field, $items) { */ function _field_sort_items($field, $items) { if (($field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED) && isset($items[0]['_weight'])) { - usort($items, '_field_sort_items_helper'); + usort($items, 'drupal\_field_sort_items_helper'); foreach ($items as $delta => $item) { if (is_array($items[$delta])) { unset($items[$delta]['_weight']); @@ -1001,7 +1001,7 @@ function field_access($op, $field, $entity_type, $entity = NULL, $account = NULL } foreach (module_implements('field_access') as $module) { - $function = $module . '_field_access'; + $function = 'drupal\\' . $module . '_field_access'; $access = $function($op, $field, $entity_type, $entity, $account); if ($access === FALSE) { return FALSE; diff --git a/core/modules/field/modules/field_sql_storage/field_sql_storage.module b/core/modules/field/modules/field_sql_storage/field_sql_storage.module index 21910b2..a82dae7 100644 --- a/core/modules/field/modules/field_sql_storage/field_sql_storage.module +++ b/core/modules/field/modules/field_sql_storage/field_sql_storage.module @@ -495,11 +495,11 @@ function field_sql_storage_field_storage_purge($entity_type, $entity, $field, $i */ function field_sql_storage_field_storage_query(EntityFieldQuery $query) { if ($query->age == FIELD_LOAD_CURRENT) { - $tablename_function = '_field_sql_storage_tablename'; + $tablename_function = 'drupal\_field_sql_storage_tablename'; $id_key = 'entity_id'; } else { - $tablename_function = '_field_sql_storage_revision_tablename'; + $tablename_function = 'drupal\_field_sql_storage_revision_tablename'; $id_key = 'revision_id'; } $table_aliases = array(); @@ -526,7 +526,7 @@ function field_sql_storage_field_storage_query(EntityFieldQuery $query) { // Add field conditions. We need a fresh grouping cache. drupal_static_reset('drupal\_field_sql_storage_query_field_conditions'); - _field_sql_storage_query_field_conditions($query, $select_query, $query->fieldConditions, $table_aliases, '_field_sql_storage_columnname'); + _field_sql_storage_query_field_conditions($query, $select_query, $query->fieldConditions, $table_aliases, 'drupal\_field_sql_storage_columnname'); // Add field meta conditions. _field_sql_storage_query_field_conditions($query, $select_query, $query->fieldMetaConditions, $table_aliases, function ($field_name, $column) { return $column; }); diff --git a/core/modules/field/modules/list/list.module b/core/modules/field/modules/list/list.module index 6563a0d..a0aed58 100644 --- a/core/modules/field/modules/list/list.module +++ b/core/modules/field/modules/list/list.module @@ -232,8 +232,8 @@ function list_allowed_values($field) { $allowed_values = &drupal_static(__FUNCTION__, array()); if (!isset($allowed_values[$field['id']])) { - $function = $field['settings']['allowed_values_function']; - if (!empty($function)) { + if (!empty($field['settings']['allowed_values_function'])) { + $function = 'drupal\\' . $field['settings']['allowed_values_function']; $values = $function($field); } else { diff --git a/core/modules/field/modules/number/number.module b/core/modules/field/modules/number/number.module index e2726e3..de3b323 100644 --- a/core/modules/field/modules/number/number.module +++ b/core/modules/field/modules/number/number.module @@ -294,8 +294,8 @@ function number_field_formatter_view($entity_type, $entity, $field, $instance, $ foreach ($items as $delta => $item) { $output = number_format($item['value'], $settings['scale'], $settings['decimal_separator'], $settings['thousand_separator']); if ($settings['prefix_suffix']) { - $prefixes = isset($instance['settings']['prefix']) ? array_map('field_filter_xss', explode('|', $instance['settings']['prefix'])) : array(''); - $suffixes = isset($instance['settings']['suffix']) ? array_map('field_filter_xss', explode('|', $instance['settings']['suffix'])) : array(''); + $prefixes = isset($instance['settings']['prefix']) ? array_map('drupal\field_filter_xss', explode('|', $instance['settings']['prefix'])) : array(''); + $suffixes = isset($instance['settings']['suffix']) ? array_map('drupal\field_filter_xss', explode('|', $instance['settings']['suffix'])) : array(''); $prefix = (count($prefixes) > 1) ? format_plural($item['value'], $prefixes[0], $prefixes[1]) : $prefixes[0]; $suffix = (count($suffixes) > 1) ? format_plural($item['value'], $suffixes[0], $suffixes[1]) : $suffixes[0]; $output = $prefix . $output . $suffix; diff --git a/core/modules/field/tests/field.test b/core/modules/field/tests/field.test index e1b6eac..aa16855 100644 --- a/core/modules/field/tests/field.test +++ b/core/modules/field/tests/field.test @@ -1949,7 +1949,7 @@ class FieldCrudTestCase extends FieldTestCase { field_test_memorize(); $field_definition = field_create_field($field_definition); $mem = field_test_memorize(); - $this->assertIdentical($mem['field_test_field_create_field'][0][0], $field_definition, 'hook_field_create_field() called with correct arguments.'); + $this->assertIdentical($mem['drupal\field_test_field_create_field'][0][0], $field_definition, 'hook_field_create_field() called with correct arguments.'); // Read the raw record from the {field_config_instance} table. $result = db_query('SELECT * FROM {field_config} WHERE field_name = :field_name', array(':field_name' => $field_definition['field_name'])); @@ -3144,10 +3144,10 @@ class FieldBulkDeleteTestCase extends FieldTestCase { // pseudo entity has a $field property that matches the original entity, // but no others. $mem = field_test_memorize(); - $this->assertEqual(count($mem['field_test_field_delete']), 10, 'hook_field_delete was called for the right number of entities'); + $this->assertEqual(count($mem['drupal\field_test_field_delete']), 10, 'hook_field_delete was called for the right number of entities'); $stubs = $this->_generateStubEntities($this->entity_type, $this->entities, $field['field_name']); $count = count($stubs); - foreach ($mem['field_test_field_delete'] as $args) { + foreach ($mem['drupal\field_test_field_delete'] as $args) { $entity = $args[1]; $this->assertEqual($stubs[$entity->ftid], $entity, 'hook_field_delete() called with the correct stub'); unset($stubs[$entity->ftid]); diff --git a/core/modules/field/tests/field_test.entity.inc b/core/modules/field/tests/field_test.entity.inc index 45152f1..3de8937 100644 --- a/core/modules/field/tests/field_test.entity.inc +++ b/core/modules/field/tests/field_test.entity.inc @@ -312,7 +312,7 @@ function field_test_entity_save(&$entity) { } // Save fields. - $function = "field_attach_$op"; + $function = 'drupal\field_attach_' . $op; $function('test_entity', $entity); } diff --git a/core/modules/field/tests/field_test.storage.inc b/core/modules/field/tests/field_test.storage.inc index f5d52dc..253b88c 100644 --- a/core/modules/field/tests/field_test.storage.inc +++ b/core/modules/field/tests/field_test.storage.inc @@ -256,7 +256,7 @@ function field_test_field_storage_query($field_id, $conditions, $count, &$cursor $field_data = $data[$field['id']]; $sub_table = $load_current ? 'current' : 'revisions'; // We need to sort records by entity type and entity id. - usort($field_data[$sub_table], '_field_test_field_storage_query_sort_helper'); + usort($field_data[$sub_table], 'drupal\_field_test_field_storage_query_sort_helper'); // Initialize results array. $return = array(); diff --git a/core/modules/field_ui/field_ui.admin.inc b/core/modules/field_ui/field_ui.admin.inc index aba39e5..f61f666 100644 --- a/core/modules/field_ui/field_ui.admin.inc +++ b/core/modules/field_ui/field_ui.admin.inc @@ -88,8 +88,8 @@ function _field_ui_reduce_order($array, $a) { $array[] = $a['name']; } if (!empty($a['children'])) { - uasort($a['children'], 'sort_weight'); - $array = array_merge($array, array_reduce($a['children'], '_field_ui_reduce_order')); + uasort($a['children'], 'drupal\sort_weight'); + $array = array_merge($array, array_reduce($a['children'], 'drupal\_field_ui_reduce_order')); } return $array; } @@ -161,7 +161,7 @@ function field_ui_table_pre_render($elements) { unset($list[$name]); // Determine the region for the row. - $function = $row['#region_callback']; + $function = 'drupal\\' . $row['#region_callback']; $region_name = $function($row); // Add the element in the tree. @@ -193,7 +193,7 @@ function field_ui_table_pre_render($elements) { } // Determine rendering order from the tree structure. foreach ($regions as $region_name => $region) { - $elements['#regions'][$region_name]['rows_order'] = array_reduce($trees[$region_name], '_field_ui_reduce_order'); + $elements['#regions'][$region_name]['rows_order'] = array_reduce($trees[$region_name], 'drupal\_field_ui_reduce_order'); } $elements['#attached']['js'][] = array( @@ -1058,7 +1058,7 @@ function field_ui_display_overview_form($form, &$form_state, $entity_type, $bund $table[$name]['format']['settings_edit_form'] = array(); $settings_form = array(); - $function = $formatter['module'] . '_field_formatter_settings_form'; + $function = 'drupal\\' . $formatter['module'] . '_field_formatter_settings_form'; if (function_exists($function)) { $settings_form = $function($field, $instance, $view_mode, $form, $form_state); } @@ -2085,7 +2085,7 @@ function field_ui_field_edit_form_validate($form, &$form_state) { // Validate the value and report errors. $errors = array(); - $function = $field['module'] . '_field_validate'; + $function = 'drupal\\' . $field['module'] . '_field_validate'; if (function_exists($function)) { $function(NULL, NULL, $field, $instance, LANGUAGE_NONE, $items, $errors); } diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 6417892..811d4df 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -281,7 +281,7 @@ function _field_ui_view_mode_menu_access($entity_type, $bundle, $view_mode, $acc return (count($args) == 1) ? user_access($args[0]) : user_access($args[0], $args[1]); } else { - return call_user_func_array($access_callback, $args); + return call_user_func_array('drupal\\' . $access_callback, $args); } } } diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc index c8c914c..1827fc5 100644 --- a/core/modules/file/file.field.inc +++ b/core/modules/file/file.field.inc @@ -852,7 +852,7 @@ function theme_file_widget_multiple($variables) { foreach (element_children($element) as $key) { $widgets[] = &$element[$key]; } - usort($widgets, '_field_sort_items_value_helper'); + usort($widgets, 'drupal\_field_sort_items_value_helper'); $rows = array(); foreach ($widgets as $key => &$widget) { diff --git a/core/modules/filter/filter.admin.inc b/core/modules/filter/filter.admin.inc index 36dab5b..25a9c5f 100644 --- a/core/modules/filter/filter.admin.inc +++ b/core/modules/filter/filter.admin.inc @@ -29,7 +29,7 @@ function filter_admin_overview($form) { } else { $form['formats'][$id]['name'] = array('#markup' => check_plain($format->name)); - $roles = array_map('check_plain', filter_get_roles_by_format($format)); + $roles = array_map('drupal\check_plain', filter_get_roles_by_format($format)); $roles_markup = $roles ? implode(', ', $roles) : t('No roles may use this format'); } $form['formats'][$id]['roles'] = array('#markup' => $roles_markup); @@ -146,7 +146,7 @@ function filter_admin_format_form($form, &$form_state, $format) { $form['roles'] = array( '#type' => 'checkboxes', '#title' => t('Roles'), - '#options' => array_map('check_plain', user_roles()), + '#options' => array_map('drupal\check_plain', user_roles()), '#disabled' => $is_fallback, ); if ($is_fallback) { @@ -233,7 +233,7 @@ function filter_admin_format_form($form, &$form_state, $format) { foreach ($filter_info as $name => $filter) { if (isset($filter['settings callback'])) { - $function = $filter['settings callback']; + $function = 'drupal\\' . $filter['settings callback']; // Pass along stored filter settings and default settings, but also the // format object and all filters to allow for complex implementations. $defaults = (isset($filter['default settings']) ? $filter['default settings'] : array()); diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 3448596..60a9d2c 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -581,7 +581,7 @@ function filter_get_filters() { // Allow modules to alter filter definitions. alter('filter_info', $filters); - uasort($filters, '_filter_list_cmp'); + uasort($filters, 'drupal\_filter_list_cmp'); } return $filters; @@ -749,7 +749,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE) // Give filters the chance to escape HTML-like data such as code or formulas. foreach ($filters as $name => $filter) { if ($filter->status && isset($filter_info[$name]['prepare callback'])) { - $function = $filter_info[$name]['prepare callback']; + $function = 'drupal\\' . $filter_info[$name]['prepare callback']; $text = $function($text, $filter, $format, $langcode, $cache, $cache_id); } } @@ -757,7 +757,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE) // Perform filtering. foreach ($filters as $name => $filter) { if ($filter->status && isset($filter_info[$name]['process callback'])) { - $function = $filter_info[$name]['process callback']; + $function = 'drupal\\' . $filter_info[$name]['process callback']; $text = $function($text, $filter, $format, $langcode, $cache, $cache_id); } } @@ -1018,7 +1018,8 @@ function _filter_tips($format_id, $long = FALSE) { $tips[$format->name] = array(); foreach ($filters as $name => $filter) { if ($filter->status && isset($filter_info[$name]['tips callback'])) { - $tip = $filter_info[$name]['tips callback']($filter, $format, $long); + $function = 'drupal\\' . $filter_info[$name]['tips callback']; + $tip = $function($filter, $format, $long); if (isset($tip)) { $tips[$format->name][$name] = array('tip' => $tip, 'id' => $name); } @@ -1435,7 +1436,7 @@ function _filter_url($text, $filter) { // markup, especially a '>'. Therefore, remove all comment contents and add // them back later. _filter_url_escape_comments('', TRUE); - $text = preg_replace_callback('``s', '_filter_url_escape_comments', $text); + $text = preg_replace_callback('``s', 'drupal\_filter_url_escape_comments', $text); // Split at all tags; ensures that no tags or attributes are processed. $chunks = preg_split('/(<.+?>)/is', $text, -1, PREG_SPLIT_DELIM_CAPTURE); @@ -1454,7 +1455,7 @@ function _filter_url($text, $filter) { if ($open_tag == '') { // If there is a match, inject a link into this chunk via the callback // function contained in $task. - $chunks[$i] = preg_replace_callback($pattern, $task, $chunks[$i]); + $chunks[$i] = preg_replace_callback($pattern, 'drupal\\' . $task, $chunks[$i]); } // Text chunk is done, so next chunk must be a tag. $chunk_type = 'tag'; @@ -1481,7 +1482,7 @@ function _filter_url($text, $filter) { $text = implode($chunks); // Revert back to the original comment contents _filter_url_escape_comments('', FALSE); - $text = preg_replace_callback('``', '_filter_url_escape_comments', $text); + $text = preg_replace_callback('``', 'drupal\_filter_url_escape_comments', $text); } return $text; diff --git a/core/modules/filter/filter.test b/core/modules/filter/filter.test index 3d07bff..f7a6962 100644 --- a/core/modules/filter/filter.test +++ b/core/modules/filter/filter.test @@ -795,7 +795,7 @@ class FilterUnitTestCase extends UnitTestCase { function testLineBreakFilter() { // Setup dummy filter object. $filter = new stdClass(); - $filter->callback = '_filter_autop'; + $filter->callback = 'drupal\_filter_autop'; // Since the line break filter naturally needs plenty of newlines in test // strings and expectations, we're using "\n" instead of regular newlines @@ -1159,7 +1159,7 @@ class FilterUnitTestCase extends UnitTestCase { function testHtmlEscapeFilter() { // Setup dummy filter object. $filter = new stdClass(); - $filter->callback = '_filter_html_escape'; + $filter->callback = 'drupal\_filter_html_escape'; $tests = array( " One. Two'.\n

Three.

\n " => array( @@ -1177,7 +1177,7 @@ class FilterUnitTestCase extends UnitTestCase { function testUrlFilter() { // Setup dummy filter object. $filter = new stdClass(); - $filter->callback = '_filter_url'; + $filter->callback = 'drupal\_filter_url'; $filter->settings = array( 'filter_url_length' => 496, ); diff --git a/core/modules/help/help.test b/core/modules/help/help.test index fcf52ff..f81cf32 100644 --- a/core/modules/help/help.test +++ b/core/modules/help/help.test @@ -95,7 +95,7 @@ class HelpTestCase extends WebTestCase { $this->modules = array(); $result = db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC"); foreach ($result as $module) { - if (file_exists($module->filename) && function_exists($module->name . '_help')) { + if (file_exists($module->filename) && function_exists('drupal\\' . $module->name . '_help')) { $fullname = unserialize($module->info); $this->modules[$module->name] = $fullname['name']; } diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc index 191263e..7dc265d 100644 --- a/core/modules/image/image.admin.inc +++ b/core/modules/image/image.admin.inc @@ -391,7 +391,7 @@ function image_effect_form($form, &$form_state, $style, $effect) { $form['#tree'] = TRUE; $form['#attached']['css'][get_path('module', 'image') . '/image.admin.css'] = array(); - $form['data'] = call_user_func($effect['form callback'], $effect['data']); + $form['data'] = call_user_func('drupal\\' . $effect['form callback'], $effect['data']); // Check the URL for a weight, then the image effect, otherwise use default. $form['weight'] = array( diff --git a/core/modules/image/image.module b/core/modules/image/image.module index ed116be..0d24abd 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -833,7 +833,8 @@ function image_style_transform_dimensions($style_name, array &$dimensions) { } if (isset($effect['dimensions callback'])) { - $effect['dimensions callback']($dimensions, $effect['data']); + $function = 'drupal\\' . $effect['dimensions callback']; + $function($dimensions, $effect['data']); } else { $dimensions['width'] = $dimensions['height'] = NULL; @@ -997,7 +998,7 @@ function image_effect_definitions() { $effects[$name] = $effect; } } - uasort($effects, '_image_effect_definitions_sort'); + uasort($effects, 'drupal\_image_effect_definitions_sort'); alter('image_effect_info', $effects); cache()->set("image_effects:$langcode", $effects); } @@ -1151,7 +1152,7 @@ function image_effect_delete($effect) { */ function image_effect_apply($image, $effect) { module_load_include('inc', 'image', 'image.effects'); - $function = $effect['effect callback']; + $function = 'drupal\\' . $effect['effect callback']; return $function($image, $effect['data']); } diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 367ec94..67e2462 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -1031,6 +1031,7 @@ function locale_url_outbound_alter(&$path, &$options, $original_path) { } foreach ($callbacks as $callback) { + $callback = 'drupal\\' . $callback; $callback($path, $options); } diff --git a/core/modules/locale/locale.test b/core/modules/locale/locale.test index 1544aca..8397fa6 100644 --- a/core/modules/locale/locale.test +++ b/core/modules/locale/locale.test @@ -1057,8 +1057,8 @@ class LocaleInstallTest extends WebTestCase { * Verify that function signatures of t() and st() are equal. */ function testFunctionSignatures() { - $reflector_t = new ReflectionFunction('t'); - $reflector_st = new ReflectionFunction('st'); + $reflector_t = new ReflectionFunction('drupal\t'); + $reflector_st = new ReflectionFunction('drupal\st'); $this->assertEqual($reflector_t->getParameters(), $reflector_st->getParameters(), t('Function signatures of t() and st() are equal.')); } } @@ -1130,7 +1130,7 @@ class LocaleUninstallFunctionalTest extends WebTestCase { // Change language negotiation options. load('module', 'locale'); - variable_set('language_types', language_types() + array('language_custom' => TRUE)); + variable_set('language_types', _language_types() + array('language_custom' => TRUE)); variable_set('language_negotiation_' . LANGUAGE_TYPE_INTERFACE, locale_language_negotiation_info()); variable_set('language_negotiation_' . LANGUAGE_TYPE_CONTENT, locale_language_negotiation_info()); variable_set('language_negotiation_' . LANGUAGE_TYPE_URL, locale_language_negotiation_info()); @@ -1159,7 +1159,7 @@ class LocaleUninstallFunctionalTest extends WebTestCase { // Check language negotiation. require_once ROOT . '/core/includes/language.inc'; - $this->assertTrue(count(language_types()) == count(language_types()), t('Language types reset')); + $this->assertTrue(count(language_types()) == count(_language_types()), t('Language types reset')); $language_negotiation = language_negotiation_get(LANGUAGE_TYPE_INTERFACE) == LANGUAGE_NEGOTIATION_DEFAULT; $this->assertTrue($language_negotiation, t('Interface language negotiation: %setting', array('%setting' => t($language_negotiation ? 'none' : 'set')))); $language_negotiation = language_negotiation_get(LANGUAGE_TYPE_CONTENT) == LANGUAGE_NEGOTIATION_DEFAULT; @@ -2629,7 +2629,7 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends WebTestCase { variable_set('locale_test_content_language_type', TRUE); $this->languageNegotiationUpdate(); $type = LANGUAGE_TYPE_CONTENT; - $language_types = variable_get('language_types', language_types()); + $language_types = variable_get('language_types', _language_types()); $this->assertTrue($language_types[$type], t('Content language type is configurable.')); // Enable some core and custom language providers. The test language type is @@ -2710,7 +2710,7 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends WebTestCase { // Enable/disable locale_test only if we did not already before. if ($last_op != $op) { - $function = "module_{$op}"; + $function = 'drupal\module_' . $op; $function($modules); // Reset hook implementation cache. module_implements_reset(); @@ -2718,7 +2718,7 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends WebTestCase { drupal_static_reset('drupal\language_types_info'); drupal_static_reset('drupal\language_negotiation_info'); - $function = "locale_modules_{$op}d"; + $function = 'drupal\locale_modules_' . $op . 'd'; if (function_exists($function)) { $function($modules); } diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc index bc571eb..c82c53c 100644 --- a/core/modules/node/node.admin.inc +++ b/core/modules/node/node.admin.inc @@ -604,7 +604,7 @@ function node_admin_nodes_submit($form, &$form_state) { $operation = $operations[$form_state['values']['operation']]; // Filter out unchecked nodes $nodes = array_filter($form_state['values']['nodes']); - if ($function = $operation['callback']) { + if ($operation['callback']) { // Add in callback arguments if present. if (isset($operation['callback arguments'])) { $args = array_merge(array($nodes), $operation['callback arguments']); @@ -612,7 +612,7 @@ function node_admin_nodes_submit($form, &$form_state) { else { $args = array($nodes); } - call_user_func_array($function, $args); + call_user_func_array('drupal\\' . $operation['callback'], $args); cache_clear_all(); } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 5331879..a063589 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -891,7 +891,7 @@ function node_hook($node, $hook) { function node_invoke($node, $hook, $a2 = NULL, $a3 = NULL, $a4 = NULL) { if (node_hook($node, $hook)) { $base = node_type_get_base($node); - $function = $base . '_' . $hook; + $function = 'drupal\\' . $base . '_' . $hook; return ($function($node, $a2, $a3, $a4)); } } @@ -1011,12 +1011,12 @@ function node_validate($node, $form, &$form_state) { // hook_node_validate() for miscellaneous validation needed by modules. Can't // use node_invoke() or module_invoke_all(), because $form_state must be // receivable by reference. - $function = node_type_get_base($node) . '_validate'; + $function = 'drupal\\' . node_type_get_base($node) . '_validate'; if (function_exists($function)) { $function($node, $form, $form_state); } foreach (module_implements('node_validate') as $module) { - $function = $module . '_node_validate'; + $function = 'drupal\\' . $module . '_node_validate'; $function($node, $form, $form_state); } } @@ -1151,7 +1151,7 @@ function node_save($node) { node_invoke($node, $op); // Save fields. - $function = "field_attach_$op"; + $function = 'drupal\field_attach_' . $op; $function('node', $node); module_invoke_all('node_' . $op, $node); @@ -2816,7 +2816,7 @@ function node_form_search_form_alter(&$form, $form_state) { ); // Node types: - $types = array_map('check_plain', node_type_get_names()); + $types = array_map('drupal\check_plain', node_type_get_names()); $form['advanced']['type'] = array( '#type' => 'checkboxes', '#title' => t('Only of the type(s)'), @@ -4104,7 +4104,7 @@ class NodeController extends DefaultEntityController { // Call object type specific callbacks on each typed array of nodes. foreach ($typed_nodes as $node_type => $nodes_of_type) { if (node_hook($node_type, 'load')) { - $function = node_type_get_base($node_type) . '_load'; + $function = 'drupal\\' . node_type_get_base($node_type) . '_load'; $function($nodes_of_type); } } diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc index 50ac6bb..bc913d7 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -170,7 +170,7 @@ function node_form($form, &$form_state, $node) { // because hook_form() needs to be able to receive $form_state by reference. // @todo hook_form() implementations are unable to add #validate or #submit // handlers to the form buttons below. Remove hook_form() entirely. - $function = node_type_get_base($node) . '_form'; + $function = 'drupal\\' . node_type_get_base($node) . '_form'; if (function_exists($function) && ($extra = $function($node, $form_state))) { $form = array_merge_recursive($form, $extra); } @@ -331,7 +331,7 @@ function node_form($form, &$form_state, $node) { // handler for the 'Save' action. To maintain backwards compatibility, a // #submit handler is auto-suggested for custom node type modules. $form['#validate'][] = 'node_form_validate'; - if (!isset($form['#submit']) && function_exists($node->type . '_node_form_submit')) { + if (!isset($form['#submit']) && function_exists('drupal\\' . $node->type . '_node_form_submit')) { $form['#submit'][] = $node->type . '_node_form_submit'; } $form += array('#submit' => array()); @@ -528,7 +528,7 @@ function node_form_submit_build_node($form, &$form_state) { node_submit($node); foreach (module_implements('node_submit') as $module) { - $function = $module . '_node_submit'; + $function = 'drupal\\' . $module . '_node_submit'; $function($node, $form, $form_state); } return $node; diff --git a/core/modules/openid/openid.inc b/core/modules/openid/openid.inc index ce03c47..c37871f 100644 --- a/core/modules/openid/openid.inc +++ b/core/modules/openid/openid.inc @@ -255,7 +255,8 @@ function openid_normalize($identifier) { // Execute each method in turn, stopping after the first method accepted // the identifier. foreach ($methods as $method) { - $result = $method($identifier); + $function = 'drupal\\' . $method; + $result = $function($identifier); if ($result !== NULL) { $identifier = $result; break; diff --git a/core/modules/openid/openid.module b/core/modules/openid/openid.module index d3e2999..2fddb71 100644 --- a/core/modules/openid/openid.module +++ b/core/modules/openid/openid.module @@ -466,7 +466,8 @@ function openid_discovery($claimed_id) { // Execute each method in turn and return first successful discovery. foreach ($methods as $method) { - $discovery = $method($claimed_id); + $function = 'drupal\\' . $method; + $discovery = $function($claimed_id); if (!empty($discovery)) { return $discovery; } diff --git a/core/modules/openid/tests/openid_test.module b/core/modules/openid/tests/openid_test.module index 86b5595..9b74d02 100644 --- a/core/modules/openid/tests/openid_test.module +++ b/core/modules/openid/tests/openid_test.module @@ -246,7 +246,7 @@ function openid_test_redirect($count = 0) { * Menu callback; respond with appropriate callback. */ function openid_test_redirected_method($method1, $method2) { - return call_user_func('openid_test_' . $method1 . '_' . $method2); + return call_user_func('drupal\openid_test_' . $method1 . '_' . $method2); } /** diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module index d9f3ed3..8782fba 100644 --- a/core/modules/overlay/overlay.module +++ b/core/modules/overlay/overlay.module @@ -138,7 +138,7 @@ function overlay_init() { // If a previous page requested that we close the overlay, close it and // redirect to the final destination. if (isset($_SESSION['overlay_close_dialog'])) { - call_user_func_array('overlay_close_dialog', $_SESSION['overlay_close_dialog']); + call_user_func_array('drupal\overlay_close_dialog', $_SESSION['overlay_close_dialog']); unset($_SESSION['overlay_close_dialog']); } // If this page shouldn't be rendered inside the overlay, redirect to the @@ -846,10 +846,10 @@ function overlay_render_region($region) { // on the final rendered page. $original_js = add_js(); $original_css = add_css(); - $original_libraries = drupal_static('add_library'); - $js = &drupal_static('add_js'); - $css = &drupal_static('add_css'); - $libraries = &drupal_static('add_library'); + $original_libraries = drupal_static('drupal\add_library'); + $js = &drupal_static('drupal\add_js'); + $css = &drupal_static('drupal\add_css'); + $libraries = &drupal_static('drupal\add_library'); $markup = render_page($page); $js = $original_js; $css = $original_css; diff --git a/core/modules/poll/poll.module b/core/modules/poll/poll.module index 52c69cf..0911c31 100644 --- a/core/modules/poll/poll.module +++ b/core/modules/poll/poll.module @@ -810,7 +810,7 @@ function template_preprocess_poll_vote(&$variables) { */ function poll_view_results($node, $view_mode, $block = FALSE) { // Make sure that choices are ordered by their weight. - uasort($node->choice, 'sort_weight'); + uasort($node->choice, 'drupal\sort_weight'); // Count the votes and find the maximum $total_votes = 0; diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index dbdb8f9..6422880 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -306,7 +306,7 @@ function rdf_rdfa_attributes($mapping, $data = NULL) { $attributes['property'] = $mapping['predicates']; // Convert $data to a specific format as per the callback function. if (isset($data) && isset($mapping['callback'])) { - $callback = $mapping['callback']; + $callback = 'drupal\\' . $mapping['callback']; $attributes['content'] = $callback($data); } if (isset($mapping['datatype'])) { @@ -336,7 +336,7 @@ function rdf_rdfa_attributes($mapping, $data = NULL) { */ function rdf_modules_installed($modules) { foreach ($modules as $module) { - $function = $module . '_rdf_mapping'; + $function = 'drupal\\' . $module . '_rdf_mapping'; if (function_exists($function)) { foreach ($function() as $mapping) { // Only the bundle mappings are saved in the database. diff --git a/core/modules/search/search.module b/core/modules/search/search.module index e01eef9..ed3c1e4 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -263,7 +263,7 @@ function search_get_info($all = FALSE) { if (!isset($search_hooks)) { foreach (module_implements('search_info') as $module) { - $search_hooks[$module] = call_user_func($module . '_search_info'); + $search_hooks[$module] = call_user_func('drupal\\' . $module . '_search_info'); // Use module name as the default value. $search_hooks[$module] += array('title' => $module, 'path' => $module); // Include the module name itself in the array. @@ -300,7 +300,7 @@ function search_get_default_module_info() { * Access callback for search tabs. */ function _search_menu_access($name) { - return user_access('search content') && (!function_exists($name . '_search_access') || module_invoke($name, 'search_access')); + return user_access('search content') && (!function_exists('drupal\\' . $name . '_search_access') || module_invoke($name, 'search_access')); } /** @@ -363,7 +363,7 @@ function search_dirty($word = NULL) { function search_cron() { // We register a shutdown function to ensure that search_total is always up // to date. - drupal_register_shutdown_function('search_update_totals'); + drupal_register_shutdown_function('drupal\search_update_totals'); foreach (variable_get('search_active_modules', array('node', 'user')) as $module) { // Update word index @@ -427,7 +427,7 @@ function search_simplify($text) { // Simple CJK handling if (variable_get('overlap_cjk', TRUE)) { - $text = preg_replace_callback('/[' . PREG_CLASS_CJK . ']+/u', 'search_expand_cjk', $text); + $text = preg_replace_callback('/[' . PREG_CLASS_CJK . ']+/u', 'drupal\search_expand_cjk', $text); } // To improve searching for numerical data such as dates, IP addresses @@ -453,7 +453,7 @@ function search_simplify($text) { // Truncate everything to 50 characters. $words = explode(' ', $text); - array_walk($words, '_search_index_truncate'); + array_walk($words, 'drupal\_search_index_truncate'); $text = implode(' ', $words); return $text; @@ -1115,7 +1115,7 @@ function search_excerpt($keys, $text) { $text = decode_entities($text); // Slash-escape quotes in the search keyword string. - array_walk($keys, '_search_excerpt_replace'); + array_walk($keys, 'drupal\_search_excerpt_replace'); $workkeys = $keys; // Extract fragments around keywords. @@ -1227,7 +1227,7 @@ function search_excerpt($keys, $text) { $text = check_plain($text); // Slash-escape quotes in keys found in a derived form and merge with original keys. - array_walk($foundkeys, '_search_excerpt_replace'); + array_walk($foundkeys, 'drupal\_search_excerpt_replace'); $keys = array_merge($keys, $foundkeys); // Highlight keywords. Must be done at once to prevent conflicts ('strong' and ''). @@ -1279,7 +1279,7 @@ function search_simplify_excerpt_match($key, $text, $offset, $boundary) { // If we get here, we have a match. Now find the exact location of the match // and the original text that matched. Start by splitting up the text by all // potential starting points of the matching text and iterating through them. - $split = array_filter(preg_split('/' . $boundary . '/iu', $text, -1, PREG_SPLIT_OFFSET_CAPTURE), '_search_excerpt_match_filter'); + $split = array_filter(preg_split('/' . $boundary . '/iu', $text, -1, PREG_SPLIT_OFFSET_CAPTURE), 'drupal\_search_excerpt_match_filter'); foreach ($split as $value) { // Skip starting points before the offset. if ($value[1] < $offset) { diff --git a/core/modules/search/search.pages.inc b/core/modules/search/search.pages.inc index 6d5e974..9a77733 100644 --- a/core/modules/search/search.pages.inc +++ b/core/modules/search/search.pages.inc @@ -55,7 +55,7 @@ function search_view($module = NULL, $keys = '') { $conditions = NULL; if (isset($info['conditions_callback'])) { // Build an optional array of more search conditions. - $conditions = call_user_func($info['conditions_callback'], $keys); + $conditions = call_user_func('drupal\\' . $info['conditions_callback'], $keys); } // Only search if there are keywords or non-empty conditions. if ($keys || !empty($conditions)) { diff --git a/core/modules/simpletest/drupal_web_test_case.php b/core/modules/simpletest/drupal_web_test_case.php index 797c611..ec3dcbd 100644 --- a/core/modules/simpletest/drupal_web_test_case.php +++ b/core/modules/simpletest/drupal_web_test_case.php @@ -455,7 +455,7 @@ abstract class TestCase { */ protected function verbose($message) { if ($id = simpletest_verbose($message)) { - $url = file_create_url($this->originalFileDirectory . '/simpletest/verbose/' . get_class($this) . '-' . $id . '.html'); + $url = file_create_url($this->originalFileDirectory . '/simpletest/verbose/' . str_replace('\\', '-', get_class($this)) . '-' . $id . '.html'); $this->error(l(t('Verbose message'), $url, array('attributes' => array('target' => '_blank'))), 'User notice'); } } @@ -3496,7 +3496,7 @@ function simpletest_verbose($message, $original_file_directory = NULL, $test_cla if ($original_file_directory) { $file_directory = $original_file_directory; - $class = $test_class; + $class = str_replace('\\', '-', $test_class); $verbose = variable_get('simpletest_verbose', TRUE); $directory = $file_directory . '/simpletest/verbose'; $writable = file_prepare_directory($directory, FILE_CREATE_DIRECTORY); diff --git a/core/modules/simpletest/files/php-2.php b/core/modules/simpletest/files/php-2.php index ad16083..615a8d7 100644 --- a/core/modules/simpletest/files/php-2.php +++ b/core/modules/simpletest/files/php-2.php @@ -1,3 +1,2 @@ getInfo(); @@ -173,7 +174,7 @@ function _simpletest_batch_operation($test_list_init, $test_id, &$context) { $max = $context['sandbox']['max']; // Perform the next test. - $test_class = array_shift($test_list); + $test_class = 'drupal\\' . array_shift($test_list); $test = new $test_class($test_id); $test->run(); $size = count($test_list); @@ -324,8 +325,8 @@ function simpletest_test_get_all() { $groups = array(); foreach ($classes as $class) { // Test classes need to implement getInfo() to be valid. - if (class_exists($class) && method_exists($class, 'getInfo')) { - $info = call_user_func(array($class, 'getInfo')); + if (class_exists('drupal\\' . $class) && method_exists('drupal\\' . $class, 'getInfo')) { + $info = call_user_func(array('drupal\\' . $class, 'getInfo')); // If this test class requires a non-existing module, skip it. if (!empty($info['dependencies'])) { diff --git a/core/modules/simpletest/simpletest.pages.inc b/core/modules/simpletest/simpletest.pages.inc index 6c9b6b6..f060962 100644 --- a/core/modules/simpletest/simpletest.pages.inc +++ b/core/modules/simpletest/simpletest.pages.inc @@ -130,7 +130,7 @@ function theme_simpletest_test_table($variables) { ); // Sorting $element by children's #title attribute instead of by class name. - uasort($element, 'element_sort_by_title'); + uasort($element, 'drupal\element_sort_by_title'); // Cycle through each test within the current group. foreach (element_children($element) as $test_name) { @@ -188,7 +188,7 @@ function simpletest_test_form_submit($form, &$form_state) { foreach ($form_state['values'] as $class_name => $value) { // Since class_exists() will likely trigger an autoload lookup, // we do the fast check first. - if ($value === 1 && class_exists($class_name)) { + if ($value === 1 && class_exists('drupal\\' . $class_name)) { $tests_list[] = $class_name; } } @@ -258,7 +258,7 @@ function simpletest_result_form($form, &$form_state, $test_id) { $row[] = $assertion->message_group; $row[] = basename($assertion->file); $row[] = $assertion->line; - $row[] = $assertion->function; + $row[] = substr($assertion->function, 7); $row[] = simpletest_result_status_image($assertion->status); $class = 'simpletest-' . $assertion->status; @@ -359,7 +359,7 @@ function simpletest_result_form_submit($form, &$form_state) { $form_state_execute = array('values' => array()); foreach ($classes as $class) { - $form_state_execute['values'][$class] = 1; + $form_state_execute['values'][substr($class, 7)] = 1; } simpletest_test_form_submit(array(), $form_state_execute); diff --git a/core/modules/simpletest/tests/batch_test.module b/core/modules/simpletest/tests/batch_test.module index 44357ed..17a7897 100644 --- a/core/modules/simpletest/tests/batch_test.module +++ b/core/modules/simpletest/tests/batch_test.module @@ -122,7 +122,7 @@ function batch_test_simple_form() { function batch_test_simple_form_submit($form, &$form_state) { batch_test_stack(NULL, TRUE); - $function = '_batch_test_' . $form_state['values']['batch']; + $function = 'drupal\_batch_test_' . $form_state['values']['batch']; batch_set($function()); $form_state['redirect'] = 'batch-test/redirect'; diff --git a/core/modules/simpletest/tests/common.test b/core/modules/simpletest/tests/common.test index ffed5ca..ea93e82 100644 --- a/core/modules/simpletest/tests/common.test +++ b/core/modules/simpletest/tests/common.test @@ -75,7 +75,7 @@ class AlterTestCase extends WebTestCase { * 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 CommonURLUnitTest extends WebTestCase { +class URLUnitTest extends WebTestCase { public static function getInfo() { return array( 'name' => 'URL generation tests', @@ -399,7 +399,7 @@ class CommonXssUnitTest extends UnitTestCase { * Test t() and format_string() replacement functionality. */ function testFormatStringAndT() { - foreach (array('format_string', 't') as $function) { + foreach (array('drupal\format_string', 'drupal\t') as $function) { $text = $function('Simple text'); $this->assertEqual($text, 'Simple text', $function . ' leaves simple text alone.'); $text = $function('Escaped text: @value', array('@value' => '