WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#11028 closed defect (bug) (fixed)

Remove get_the_content / wp_link_pages dead code

Reported by: filosofo Owned by: ryan
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.9
Component: Template Keywords: $more_file $file
Focuses: Cc:

Description

$file and $more_file are variables that appear in wp_link_pages() and get_the_content() and are not used.

In the oldest version of WordPress I can find, 1.2.1, they don't seem to do anything either. Can someone enlighten me about their original purpose?

Patch removes the dead code.

Attachments (1)

get_the_content-dead_code.11028.diff (2.6 KB) - added by filosofo 6 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 @azaozz6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [12105]) Remove unused vars in get_the_content and wp_link_pages, props filosofo, fixes #11028

comment:2 follow-up: @westi6 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Should we not keep the last argument but mark it as deprecated in case anyone was calling the function with that argument set?

comment:3 in reply to: ↑ 2 ; follow-up: @filosofo6 years ago

Replying to westi:

Should we not keep the last argument but mark it as deprecated in case anyone was calling the function with that argument set?

No, because calling it with that argument doesn't do anything. What difference does it make if they call it or not?

comment:4 in reply to: ↑ 3 ; follow-ups: @westi6 years ago

Replying to filosofo:

Replying to westi:

Should we not keep the last argument but mark it as deprecated in case anyone was calling the function with that argument set?

No, because calling it with that argument doesn't do anything. What difference does it make if they call it or not?

Do you not get an error about incorrect number of arguments - if not why are we keeping other deprecated args on functions.

comment:5 in reply to: ↑ 4 @filosofo6 years ago

You can pass more arguments to a function than are explicitly defined, but you can't neglect to pass a value to an argument that's defined without a default value--that's what will produce an error.

Replying to westi:

why are we keeping other deprecated args on functions.

I don't know. This one kinda makes sense, because $autoload isn't deprecated, so removing the deprecated one would change the argument order:

function add_option( $name, $value = '', $deprecated = '', $autoload = 'yes' ) {

I can see the point of this one, too, as it is still functional and gives the developer warning that in...er...2.7 it's going to be non-functional:

 *
 * @param string $domain Unique identifier for retrieving translated strings
 * @param string $abs_rel_path Optional. Relative path to ABSPATH of a folder,
 *      where the .mo file resides. Deprecated, but still functional until 2.7
 * @param string $plugin_rel_path Optional. Relative path to WP_PLUGIN_DIR. This is the preferred argument to use. It takes precendence over $abs_rel_path
 */
function load_plugin_textdomain($domain, $abs_rel_path = false, $plugin_rel_path = false) {

But we could probably get rid of this one, especially since the removed argument was unlikely to have been used outside of core.

function wp_get_http( $url, $file_path = false, $deprecated = false ) {

Grepping through core I'm amazed at how much "deprecated" cruft there is. I think I'll make another patch to clear out some of this stuff.

comment:6 in reply to: ↑ 4 @azaozz6 years ago

Replying to westi:

Do you not get an error about incorrect number of arguments...

Not on user defined functions only on built-in. That's the basis for func_get_args() and similar.

comment:7 @nacin5 years ago

  • Keywords close added; has-patch $more_file $file removed

Thinking this can be closed as fixed assuming there's another patch for 3.0 to clear out deprecated arguments when they don't affect the argument order.

comment:8 @filosofo5 years ago

  • Keywords $more_file $file added; close removed
  • Resolution set to fixed
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.