@todo - write a nice explanation of the reasons (for now, @see comment #5) we should do this with examples on howto (for now, @see http://php.net/manual/en/language.namespaces.php, http://php.net/manual/en/language.namespaces.importing.php)

\Drupal\Component\Utility\Json

- #2093161: Remove all calls to drupal_json_encode() in favour of \Drupal\Component\Utility\Json::encode()
- #2093173: Remove all calls to drupal_json_decode(), use \Drupal\Component\Utility\Json::decode()

\Drupal\Component\Utility\MapArray

- #2093179: Remove and deprecate calls to drupal_map_assoc(), use \Drupal\Component\Utility\MapArray::copyValuesToKeys()

\Drupal\Component\Utility\String

- #2089331: [meta] Replace calls to check_plain() with Drupal\Component\Utility\String::checkPlain()

\Drupal\Component\Utility\Unicode

- drupal_convert_to_utf8
- drupal_truncate_bytes (done!)
- truncate_utf8
- mime_header_encode
- mime_header_decode
- decode_entities
- drupal_strlen
- drupal_strtoupper
- drupal_strtolower
- drupal_ucfirst
- drupal_substr

\Drupal\Component\Utility\Xss

- #2089433: Remove uses of deprecated XSS filter functions

\Drupal\Component\Utility\Url

- #2089327: Remove / deprecate calls to drupal_strip_dangerous_protocols() use \Drupal\Component\Utility\Url::stripDangerousProtocols()

\Drupal\Core\Render - #2109793: Convert element_* methods in common.inc to a class

- #2181507: Remove the deprecated usages of element_* methods
- #2393329: Replace all drupal_render calls with the service, and inject it, if possible.

Related issues

- #2042165: Add a 'deprecated' module that includes deprecated functions only when enabled

CommentFileSizeAuthor
#15 deprecates-revealed-do-not-test.diff33.97 KBAki Tendo

Comments

thedavidmeister’s picture

Issue summary: View changes

Updated issue summary.

thedavidmeister’s picture

Issue summary: View changes

Updated issue summary.

thedavidmeister’s picture

Issue summary: View changes

Updated issue summary.

thedavidmeister’s picture

Issue tags: +Novice
thedavidmeister’s picture

Title: [meta] Remove calls to procedural functions that simply wrap a class and deprecate the procedural functions » [meta] Remove & deprecate calls to procedural functions that simply wrap a class
thedavidmeister’s picture

Issue summary: View changes

Updated issue summary.

thedavidmeister’s picture

Issue summary: View changes

Updated issue summary.

webchick’s picture

Can we talk please about this a bit first, before jaunting off and creating 5000 sub-issues? :)

My worry with this is it pushes the concept of namespaces down to the .module file level. Modules are going to end up with a pile of "use" statements at the top just to get even the simplest thing done.

Would another approach be moving these types of things to the "Drupal" class so they're always available?

thedavidmeister’s picture

I will do no jaunting prior to discussion.

thedavidmeister’s picture

Issue summary: View changes

Updated issue summary.

thedavidmeister’s picture

Title: [meta] Remove & deprecate calls to procedural functions that simply wrap a class » [meta] Remove calls to @deprecated and "backwards compatibility" procedural functions from core
Issue tags: +Needs issue summary update

@webchick - Wherever I see people knocking back patches because they use procedural "one line wrappers", I'm going to refer them to this issue to open up discussion.

Let me know if you disagree, but as I see it, not converting existing calls in core while simultaneously knocking back patches that are otherwise RTBC is counter-productive, so I'd like to raise the visibility of this discussion on those threads.

I don't intend for this issue to suggest deprecating functions that we still consider useful simply because the function is small - but I totally accept that with zero issue summary it's completely unclear what the intention here is at all (@todo!!!). The idea was to find functions that we already are considering "deprecated" in our patch reviews and explicitly document that they're deprecated; if we're OK with knocking back patches for calling a given function, let's give fair warning!

That said, I believe that functions that are *already* deprecated (documented as @deprecated) should be not be called by core and those conversions should go ahead (the drupal_json_X() calls for example). That is to say, I believe the immediate DX concerns of using the replacement methods are secondary to ensuring Drupal Core correctly uses its own API.

Procedural functions that exist purely to provide backwards compatibility should be converted too - we don't need the overhead of calling the wrapper. Arguably this criteria, by definition, means we should also deprecate these functions when we're no longer using them internally.

I've updated the issue summary to be more specific.

Would another approach be moving these types of things to the "Drupal" class so they're always available?

I do agree that having 5-20+ "use" statements in every file is tedious, but I also think that there are benefits (including performance) to calling methods directly instead of through "one line wrappers". I don't have any strong opinion on, or any kind of answer to which approach is "better". I presume "randomly use either" is likely the worst option.

I don't have any suggestions as to how we can improve the situation, TBH I don't know that I have the experience/knowledge to suggest something others wouldn't rightfully hate. I am skeptical that bulk moving methods to the "Drupal" class based on the criteria "we have a procedural function wrapping it for historical reasons" (if that is what you meant by "these types of things") would make sense - I doubt that's what you meant, but someone else coming to this thread might not realise, so we should try to outline what "these types of things" are.

@webchick, I'd love to chat about this and other issues in IRC with you, I'm sure I'd learn a lot, but your timezones are really bad for me so I often miss you by a few hours :( apologies for the perceived jaunting!

thedavidmeister’s picture

Issue summary: View changes

Updated issue summary.

thedavidmeister’s picture

Issue summary: View changes

Updated issue summary.

thedavidmeister’s picture

@webchick, do you have any further comments on #5? I noticed that some of the sub-issues are being committed and I would actually be keen to open more cleanup issues, but I'm holding back based on what you said in #3.

sun’s picture

Issue summary: View changes
Issue tags: +@deprecated
thedavidmeister’s picture

thedavidmeister’s picture

Issue summary: View changes
thedavidmeister’s picture

Issue summary: View changes
grom358’s picture

jmarkel’s picture

Issue tags: -Novice

Doing a little weeding post-NYCCamp sprint - removed Novice tag

thedavidmeister’s picture

Issue summary: View changes
mile23’s picture

Aki Tendo’s picture

StatusFileSize
new33.97 KB

The attached patch adds "trigger_error('deprecation time: alternative function', E_USER_DEPRECATED)" to all deprecated functions, alters htaccess to not report those errors until the handlers are in place, DrupalKernel to return to E_ALL mode after setting up the handlers, and the handler itself to make just display the deprecated notices.

As should be safe to say - the patch returns a **lot** of hits, so I've labelled it do_not_test. We can consider the work on this ticket done when Drupal core can run this patch with E_ALL on at all times.

cilefen’s picture

Issue summary: View changes
mile23’s picture

mile23’s picture

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mile23’s picture

Adding related: #2959269: [meta] Core should not trigger deprecated code except in tests and during updates

Not all @deprecated code calls @trigger_error(), and finding the technical debt could be harder in those cases.

Also, not all items that should be @deprecated before Drupal 9 are marked as such. For instance #2748967: Trigger E_USER_DEPRECATED for BC support in simpletest_run_tests() as part of #2866082: [Plan] Roadmap for Simpletest I'm sure there are other less obvious examples.

gábor hojtsy’s picture

Aki Tendo’s picture

Well I did write that patch some time ago, but if I recall correctly it didn't take a long time to write - I simply did a search for @deprecated in sublime text and then added the trigger_error call where needed to cause the report. Building a new version of the patch (the old one is so out of date it probably can't apply) shouldn't take more than a couple hours.

voleger’s picture

andypost’s picture

Version: 8.6.x-dev » 8.8.x-dev
berdir’s picture

Status: Active » Closed (duplicate)

I'm closing this as a duplicate of #2959269: [meta] Core should not trigger deprecated code except in tests and during updates, all the specifically mentioned functions have been dealt with or actually their replacements already been deprecated and replaced again ;) And it seems to be about the same as the one referenced.