Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
drupal_to_js() and drupal_json() are very confusing function names. I suggest we do the following:
- drupal_to_js() is just a wrapper around PHP json_encode(), let's rename it drupal_json_encode(), as we do elsewhere
- drupal_json() outputs a PHP datastructure after converting it to JSON, let's rename it drupal_output_json()
Comments
Comment #1
Damien Tournoud CreditAttribution: Damien Tournoud commentedHere is the patch.
Comment #3
Damien Tournoud CreditAttribution: Damien Tournoud commentedSomething weird happened ;)
Comment #4
dmitrig01 CreditAttribution: dmitrig01 commentedThe names look logical and much better. i can't really test the patch because i don't have the hardware to do so at the moment, but i'm giving it my +1. I've read through the code and it *looks* right.
Comment #5
dawehnerWhy starts drupal_output_json with output, but drupal_json_encode starts with json, after the drupal.
Shouldn't be both functions be named drupal_json_%
I just rewrote the patch.
Comment #7
Damien Tournoud CreditAttribution: Damien Tournoud commentedResubmitting for the test bot.
Comment #9
sunTests failed for whatever reason :-/
Due to the new function names, some PHPDoc exceeds 80 chars in that patch.
Comment #10
sunTagging.
Comment #11
dawehnerRerole to remove hunks.
Additional fixed the 80 chars PHPDoc
Comment #13
dawehnerI missed one rename.
Comment #14
Dave ReidLooks really good and +1 for the name changes to help make it more clear.
This review is powered by Dreditor.
Comment #15
sunyeah, looks ready to fly.
Too bad that we don't support renderable arrays for json. Because, if we would, my first guess was that we'd like to rename drupal_json_output() to drupal_render_json() - going hand in hand with drupal_render_page()... :) However, since these are simple arrays currently, that doesn't make sense. Anyway, just ignore this paragraph ;)
Comment #16
Dries CreditAttribution: Dries commentedOK, that looks like a nice clean-up. Committed to CVS HEAD. Thanks all.
Let's document this in the upgrade instructions and mark as 'fixed' after.
Comment #17
dawehnerAdd update instructions http://drupal.org/update/modules/6/7
Comment #18
sun