The following functions are simple wrappers around their replacements. These should be marked @deprecated, will be removed before Drupal 8.0, and their replacements documented in change notices.

bootstrap.inc

t() (or will we make an exception here?)
settings() (or will we make an exception here?) Removed (possibly accidentally) in #2219009: Improve DX of Settings class
format_string()
drupal_validate_utf8()
drupal_placeholder() Marked deprecated in #2552579: Remove SafeMarkup::placeholder(), deprecate drupal_placeholder() and stop drupal_placeholder() from marking safe.
_current_path() (private anyway, but we might as well to avoid confusion)

common.inc

check_url()
filter_xss_admin() by #2089433: Remove uses of deprecated XSS filter functions
filter_xss() by #2089433: Remove uses of deprecated XSS filter functions
filter_xss_bad_protocol() by #2089433: Remove uses of deprecated XSS filter functions
format_date()
url_is_external() by #2221695: Remove uses of deprecated URL functions
url() Being handled by #2339219: [meta] Finalize URL generation API (naming, docs, deprecation)
drupal_merge_js_settings() Should not be deprecated, see #2113015: Add drupal_merge_attached() function, to merge #attached assets.
drupal_merge_attached() Should not be deprecated, see #2113015: Add drupal_merge_attached() function, to merge #attached assets.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ianthomas_uk’s picture

Issue summary: View changes
Rolf van de Krol’s picture

Assigned: Unassigned » Rolf van de Krol
Rolf van de Krol’s picture

Status: Active » Needs review
FileSize
6 KB

All functions in the issue description are marked deprecated and instructions are added on what to use instead. Only _current_path I'm not sure what to use, so didn't add instructions there.

Rolf van de Krol’s picture

Hmm, I see that I named the patch incorrectly. Sorry for that.

ParisLiakos’s picture

Status: Needs review » Needs work

Lets leave t() there. Procedural code should still be able to translate stuff in a way that the string extractor finds them. Even if we end up with 0 usages in core (which i doubt) we cant force everyone to give up procedural code style
Besides that patch looks good

ianthomas_uk’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
5.58 KB

We need to ensure these are all covered by change records (they probably aren't at the moment).

I agree it's best to leave t(), or at least discuss it in its own issue, so this patch does that. Needs review just so it gets tested.

ianthomas_uk’s picture

format_string(): Covered by https://www.drupal.org/node/2302363 (7.x to 8.x) and https://drupal.org/node/1312890 (7.7 and earlier to 7.8+ and 8.x)
drupal_validate_utf8(): Covered by https://www.drupal.org/node/1992584
drupal_placeholder(): Covered by https://www.drupal.org/node/2302363
_current_path(): Private, CR not applicable
check_url(): Not currently just a simple wrapper, but should really be moved to UrlHelper and covered by https://www.drupal.org/node/2079005
filter_xss_admin(): Covered by https://drupal.org/node/2239919
filter_xss(): Covered by https://drupal.org/node/2239919
filter_xss_bad_protocol(): Covered by https://drupal.org/node/2079005
format_date(): Covered by https://www.drupal.org/node/1876852, updates required to https://drupal.org/node/2047135, https://drupal.org/node/1831138 and https://drupal.org/node/1441334 (plus confirmation that the new function can be used from a twig template).
url_is_external(): Covered by https://drupal.org/node/2079005

New CR needed means I couldn't find an existing CR that covers the change. It may be appropriate to extend an existing CR to cover that function. If a function is crossed out it means no CRs need to be added/updated.

ianthomas_uk’s picture

Issue summary: View changes
Status: Needs review » Needs work

Actually, drupal_merge_*() should not be marked deprecated, see #2113015: Add drupal_merge_attached() function, to merge #attached assets. I've not bothered updating the patch, as there is little point until we have updated the change records.

xjm’s picture

Issue tags: +beta target
xjm’s picture

I think we need to leave them in until 9.x, or make this beta deadline.

xjm’s picture

Issue tags: +Pre-AMS beta sprint
xjm’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 6: drupal-deprecate_old_functions-2221771-6.patch, failed testing.

ianthomas_uk’s picture

Issue summary: View changes

remove url() from scope

ianthomas_uk’s picture

Assigned: Rolf van de Krol » Unassigned
Status: Needs work » Needs review
FileSize
1.7 KB

The list in the issue summary is out of date. This patch deprecates the remaining functions mentioned, except:
- url(), because it is being handled in all four current beta blockers
- format_date(), because I think it is needed for twig
- check_url(), because it wasn't clear what it should be replaced with.

The functions that this deprecates should be fairly uncontroversial, they are:
- format_string()
- drupal_validate_utf8()
- _current_path()
- drupal_placeholder()

xjm’s picture

@ianthomas_uk, thanks!

Two points of feedback:

  1. _current_path() doesn't indicate what you should do instead, and there's no indication to me that "@todo This is a temporary function pending refactoring Drupal to use Symfony's Request object exclusively" was anything more than wishful thinking. Is there an issue for this?
  2. For the others (like format_string()) that have clear replacements, we should have filed the issue that will convert all remaining core usages to the replacement, and reference that issue link in the deprecation note.
ianthomas_uk’s picture

Quick response before I run out the door:

17.1 I figured because it was already a private function that wasn't really necessary, but I guess it wouldn't hurt.
17.2 That's not something that I've see us do elsewhere, but seems a good idea. Generally we've been tracking removals in #2205673: [META] Remove all @deprecated functions marked "remove before 8.0"

ianthomas_uk’s picture

17.1 I've marked it clearly as an internal function and linked to its removal issue.
17.2 drupal_validate_utf8() and drupal_placeholder() only have a couple of uses, so I've just gone ahead and removed them. format_string() I've referenced the issue link.

rpayanm’s picture

Issue summary: View changes
rpayanm’s picture

FileSize
2.87 KB
xjm’s picture

Status: Needs review » Needs work
Issue tags: -Pre-AMS beta sprint

Thanks @rpayanm and @ianthomas_uk!

Since I last reviewed this issue, we've entered beta. Reviewing in terms of the allowed beta changes policy (https://www.drupal.org/core/beta-changes), this patch would definitely qualify as disruptive (because hundreds of lines of core code would be using deprecated functions as a result). It is not a prioritized type of change, and it is correctly marked as a normal task.

So, now that we are in the beta phase, we should instead be marking functions for removal for 9.0.0 if they were not already deprecated when the first beta was released. (In general, and in this issue in particular.) In addition, some of the deprecations below do not have finalized replacements in HEAD, so we should not deprecate them here. Specific notes below:

  1. +++ b/core/includes/bootstrap.inc
    @@ -539,6 +539,9 @@ function t($string, array $args = array(), array $options = array()) {
    + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.0.
    + *   Use \Drupal\Component\Utility\String::format().
      */
     function format_string($string, array $args = array()) {
    

    Over 600 uses of this still in core. Let's deprecate this for removal in 9.0.0 instead.

  2. +++ b/core/includes/bootstrap.inc
    @@ -569,6 +572,9 @@ function format_string($string, array $args = array()) {
    + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.0.
    + *   Use \Drupal\Component\Utility\Unicode::validateUtf8().
      */
     function drupal_validate_utf8($text) {
    

    This is not used so we should have an issue to just remove it in a separate issue. Can you file a separate followup issue and reference it on this issue? Actually, even if core doesn't use it, contrib might, so let's apply the same logic and deprecate it for 9.0.0 instead.

  3. +++ b/core/includes/bootstrap.inc
    @@ -1168,8 +1174,13 @@ function request_path() {
    + * Internal use only
    + *
      * @todo This is a temporary function pending refactoring Drupal to use
      *   Symfony's Request object exclusively.
    + *
    + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.0.
    + *   by https://www.drupal.org/node/2237001.
    

    This is a whole can of worms. We also should not mark things deprecated that do already have replacements in HEAD. I'd remove this change from the patch entirely.

  4. +++ b/core/includes/bootstrap.inc
    @@ -1353,6 +1364,9 @@ function drupal_static_reset($name = NULL) {
    + *
    + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.0.
    + *   Use \Drupal\Component\Utility\String::placeholder().
      */
     function drupal_placeholder($text) {
    

    3 uses in HEAD. Let's deprecate this for removal in 9.0.0 instead.

  5. +++ b/core/includes/common.inc
    @@ -323,6 +323,10 @@ function valid_email_address($mail) {
    + *   Use \Drupal\Component\Utility\String::checkPlain().
    ...
     function check_url($uri) {
    

    16 uses in HEAD. Looks like this is incorrect text? Or at least we should be providing more information. Let's deprecate this for removal in 9.0.0 instead.

  6. +++ b/core/includes/common.inc
    @@ -508,6 +512,9 @@ function format_size($size, $langcode = NULL) {
    + *
    + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
    + *   Use \Drupal::service('date.formatter')->format().
      */
     function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
    

    112 uses remaining. Let's deprecate this for removal in 9.0.0 instead.

Edit: removed comment that was about lines not in the patch. :P

xjm’s picture

Oh, regarding #19, it is out of scope to remove any code within this issue, but it looks like the latest patch in #21 reverted that.

Status: Needs work » Needs review

rickvug queued 21: 2221771-21.patch for re-testing.

Mile23’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Needs reroll.

$ git apply 2221771-21.patch 
error: patch failed: core/includes/bootstrap.inc:539
error: core/includes/bootstrap.inc: patch does not apply
error: patch failed: core/includes/common.inc:508
error: core/includes/common.inc: patch does not apply
rpayanm’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
2.5 KB

Please review.

Mile23’s picture

Status: Needs review » Reviewed & tested by the community

Just the fact that core currently uses a function doesn't mean it should not be deprecated for D9. I have a problem with deprecating for D9, because it really means "we won't actually deprecate this in any of our lifetimes."

Anyway, does this patch do what it says on the tin?

Yes.

xjm’s picture

Status: Reviewed & tested by the community » Needs work

Thanks @rpayanm, deprecating this for 9.0.0 is correct during the beta. Looks good. One more thing though:

+++ b/core/includes/common.inc
@@ -280,6 +280,9 @@ function valid_email_address($mail) {
+ *
+ * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
+ *   Use \Drupal\Component\Utility\SafeMarkup::checkPlain().
  */

As per #22 point 5, we need to add more detail to this documentation because checkPlain() is not a direct replacement for check_url().

Also, just a note for @rpayanm -- you can include an interdiff when updating patches so that reviewer can spot the changes you've made from the previous patch easily. Thanks!

alexpott’s picture

+++ b/core/includes/common.inc
@@ -280,6 +280,9 @@ function valid_email_address($mail) {
+ *
+ * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
+ *   Use \Drupal\Component\Utility\SafeMarkup::checkPlain().

This can't be deprecated like this. I don't think we can deprecate it yet. Let's just remove the deprecation notice for check_url() and move on.

Eli-T’s picture

Status: Needs work » Needs review
FileSize
2.07 KB
596 bytes

Undeprecate check_url().

DuaelFr’s picture

Status: Needs review » Reviewed & tested by the community

Nothing to add about that.
It does what it says.

DuaelFr’s picture

Status: Reviewed & tested by the community » Needs work

Sorry!
drupal_placeholder() is going to be marked as deprecated by #2552579: Remove SafeMarkup::placeholder(), deprecate drupal_placeholder() and stop drupal_placeholder() from marking safe. with a better comment. We should let that other issue manage this deprecation as it seems to be part of a bigger change.

Anonymous’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
1.63 KB

The patch didn't apply anymore, so rerolled.

Also removed drupal_placeholder() deprecation as per #32 and adjusted IS accordingly.

DuaelFr’s picture

Status: Needs review » Reviewed & tested by the community

Perfect, thank you :)
It applies and do the job.
Let's get it commited!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This is deprecating thing for Drupal 9 that have long been deprecated. Nice. Committed 5236486 and pushed to 8.0.x. Thanks!

  • alexpott committed 5236486 on 8.0.x
    Issue #2221771 by ianthomas_uk, rpayanm, Eli-T, Rolf van de Krol,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.