/**
964 * Send the HTTP response headers previously set using drupal_add_http_header().
965 * Add default headers, unless they have been replaced or unset using
966 * drupal_add_http_header().
967 *
968 * @param $default_headers
969 * An array of headers as name/value pairs.
970 * @param $single
971 * If TRUE and headers have already be sent, send only the specified header.
972 */
973 function drupal_send_headers($default_headers = array(), $only_default = FALSE) {
974 $headers_sent = &drupal_static(__FUNCTION__, FALSE);
975 $headers = drupal_get_http_header();
976 if ($only_default && $headers_sent) {
977 $headers = array();
978 }
979 $headers_sent = TRUE;

As the title, there may be a typo in the bootstrap.inc file. We believe that the second param should be unified with the real param.
So i suggest they are both "$default_single".

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jerenus’s picture

Here is my patch.

Jerenus’s picture

Jerenus’s picture

Sorry about my mistake, here is the new one.

Jerenus’s picture

Component: plugin system » documentation
FileSize
842 bytes

May be you like "default", new one ;)

Status: Needs review » Needs work

The last submitted patch, drupal-fix_typo-1853050-4.patch, failed testing.

jhodgdon’s picture

Title: There may be a Drupal core typo in the bootstrap.inc file » Typos in docs for drupal_send_headers()
Version: 7.x-dev » 8.x-dev

That patch in #4 looks fine... but could we also fix the typos in the next line down? "headers have already *been* sent... the specified header*s*". That will most likely also cause the line to need wrapping to 80-character maximum. Thanks!

Also, we need to fix this in Drupal 8.x first, then backport the fix to 7.x.

Jerenus’s picture

jhodgdon,
Here is my new patch for Drupal 8.x, please check.

Thanks!
Jerenus

Lars Toomre’s picture

Both of the function parameters have optional values. Hence, each of the description lines should start with '(optional)' and include a statement of what the default value is. Each @param directive also could use a variable type hint.

I am not at a development machine right now, but if this is not re-rolled before late tomorrow, I will roll a patch with the above changes.

Jerenus’s picture

jhodgdon,
Sorry for missing your last piece of advice. Here is new one.

Thanks!!
Jerenus

Jerenus’s picture

Status: Needs work » Needs review
FileSize
1.17 KB

Lars Toomre,
Here is additional one for your advice(#8).

Thanks,
Jerenus

jhodgdon’s picture

Status: Needs review » Needs work

RE #8 - Starting with (optional) - Yes. Including information on the default values - No, unless it is not obvious from the function signature.

So on the patch in #10 - you can take out the "Defaults to FALSE". Also, if you're going to put the type "bool" into one parameter, maybe put the type "array" in for the other one? Thanks!

Jerenus’s picture

Status: Needs work » Needs review
FileSize
1.26 KB

jhodgdon,
Here is the new one, please check.

Thanks!
Jerenus

jhodgdon’s picture

This is much better, thanks!

But... the parameter names for this function are quite confusing, since they have "default" in the name, which doesn't make any sense. Now that we have clear documentation about what the parameters *do*, it is quite obvious that the names of the parameters are bad. Maybe we should change the names of the parameters to $additional_headers and $only_additional, or something like that? As they are only parameter names and local variables, that is considered "documentation" and can be done in this patch...

I also think that the previous paragraph of documentation is confusing... well I can't figure out what this is trying to say, given the code and the rest of the documentation:
" Default headers are not set if they have been replaced or unset using drupal_add_http_header()."

Any guesses? If you think these additional changes are out of scope for this issue, then we can commit the docs fix (which is good!) and work on those other problems in a different issue. Thoughts?

jhodgdon’s picture

Title: Typos in docs for drupal_send_headers() » Fix docs and param names for drupal_send_headers()
Status: Needs review » Active

OK... I went ahead and committed the patch in #12 to both 8.x and 7.x. Thanks for your work on this patch!

I'd like to leave this issue open though. What I'd like to see happen:
- Make sure the whole documentation for this function makes sense
- Make sure the parameter names make sense

In my opinion, neither of these is true at this time (see comment #13).

Jerenus’s picture

jhodgdon,
Sorry about our jet lag. $only_additional is good. If you want to improve this patch, i'd like to do. But, can you change the author name of the patchs to my name? Thank you very much!

Jerenus

jhodgdon’s picture

What are you talking about on the "author name of the patches"? Both of the commits have your user name in the commit message (which is how we attribute patches in Drupal Core):
http://drupalcode.org/project/drupal.git/commit/11fafe6
http://drupalcode.org/project/drupal.git/commit/2b6e2c1

skyredwang’s picture

@jhodgdon

he was saying that: his patch contains author meta data, but after you committed it, the author was changed to you. Please see the commit msg, both the author and the committer was you. You probably didn't simply apply his patch, which was the correct work flow. You might have just edited the file and committed; this way, git doesn't credit the people.

For more info: http://www.mcdruid.co.uk/content/git-commit-author-give-credit-where-cre...

jhodgdon’s picture

@skyredwang: In the Drupal Core project, we do not use author attribution for git patches, as a general rule.

To quote @webchick, replying to another user by email a few days ago:

I believe [this user] might be referring to giving credit via the --author flag, e.g.

git commit --author=[username]@[uid].no-reply.drupal.org

This makes people show up here: http://drupal.org/node/3060/committers as well as in Git log.

To date, however, we do not employ this method of commit credit in Drupal core, however, because in nearly all cases [...], a patch is the cumulative effort of several people: someone to do the initial patch, one or more people to provide feedback on it, maybe more people doing re-rolls and adding tests, etc. Unfortunately, Git's "author" flag only supports single values, not multiple values. :\ The people who are listed on that page are generally people who've done major "forklift" operations into core for major initiatives that were merged in from an external sandbox.

So Jennifer is correct that in Drupal core, we do this via comma-separated names in the commit message itself, and parse these out using various tools, such as stats.marvil07.net/drupal-core/. This is more fair overall to everyone.

Jerenus’s picture

jhodgdon,
Thanks for your patience and good attitude. Anyway, i will continue to dedicate my efforts to the community. Any new idea about the #13&#14? Or i just try to patch as you said above? Or you want to keep the present?

Thanks!
Jerenus

jhodgdon’s picture

The patch in #12 has been committed, and I would like to see a change as noted in #13/14... Do you have a different idea? I'm definitely open to suggestions. It would be good if this function's code actually made sense. :)

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.

  • jhodgdon committed 2b6e2c1 on 8.3.x
    Issue #1853050 by Jerenus: Fix up docs for drupal_send_headers()
    

  • jhodgdon committed 2b6e2c1 on 8.3.x
    Issue #1853050 by Jerenus: Fix up docs for drupal_send_headers()
    

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.

  • jhodgdon committed 2b6e2c1 on 8.4.x
    Issue #1853050 by Jerenus: Fix up docs for drupal_send_headers()
    

  • jhodgdon committed 2b6e2c1 on 8.4.x
    Issue #1853050 by Jerenus: Fix up docs for drupal_send_headers()
    

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.

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

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

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

quietone’s picture

Issue summary: View changes
Status: Active » Closed (outdated)
Issue tags: +Bug Smash Initiative

drupal_send_headers was deprecated in Drupal 8.x-dev, see #1984766: Change notice: Start relying on Request/Response objects for cache handling and removed in Oct 2014 in #2362123: drupal_page_header() and drupal_send_headers() are dead code: already deprecated, zero uses remain: remove. There is no need to update the documentation.

I think closing as outdated is the best choice here.