[wp-trac] [WordPress Trac] #24210: Issues found using a static analysis tool

WordPress Trac noreply at wordpress.org
Mon Apr 29 14:14:37 UTC 2013


#24210: Issues found using a static analysis tool
--------------------------+-----------------------
 Reporter:  rlerdorf      |       Owner:  nacin
     Type:  defect (bug)  |      Status:  accepted
 Priority:  normal        |   Milestone:  3.6
Component:  General       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+-----------------------

Old description:

> These all look like valid, but minor, issues:
> {{{
> --------------------------------
> File       : wp-includes/class-json.php:495
> Reason     : UnknownFunction
> Snippet    : class_name($var)
> Line       : : new Services_JSON_Error(class_name($var).
>
> --------------------------------
> File       : wp-signup.php:493
> Reason     : RequiredAfterOptionalParam
> Snippet    : $user_name = ''
> Line       : function confirm_blog_signup($domain, $path, $blog_title,
> $user_name = '', $user_email = '', $meta) {
>
> --------------------------------
> File       : wp-signup.php:493
> Reason     : RequiredAfterOptionalParam
> Snippet    : $user_email = ''
> Line       : function confirm_blog_signup($domain, $path, $blog_title,
> $user_name = '', $user_email = '', $meta) {
>
> --------------------------------
> File       : wp-includes/widgets.php:76
> Reason     : RequiredAfterOptionalParam
> Snippet    : $id_base = false
> Line       : function WP_Widget( $id_base = false, $name, $widget_options
> = array(), $control_options = array() ) {
>
> --------------------------------
> File       : wp-includes/widgets.php:93
> Reason     : RequiredAfterOptionalParam
> Snippet    : $id_base = false
> Line       : function __construct( $id_base = false, $name,
> $widget_options = array(), $control_options = array() ) {
>
> --------------------------------
> File       : wp-includes/post.php:4789
> Reason     : RequiredAfterOptionalParam
> Snippet    : $deprecated = ''
> Line       : function _future_post_hook( $deprecated = '', $post ) {
>
> --------------------------------
> File       : wp-admin/includes/class-wp-terms-list-table.php:173
> Reason     : RequiredAfterOptionalParam
> Snippet    : $start = 0
> Line       : function _rows( $taxonomy, $terms, &$children, $start = 0,
> $per_page = 20, &$count, $parent = 0, $level = 0 ) {
>
> --------------------------------
> File       : wp-admin/includes/class-wp-terms-list-table.php:173
> Reason     : RequiredAfterOptionalParam
> Snippet    : $per_page = 20
> Line       : function _rows( $taxonomy, $terms, &$children, $start = 0,
> $per_page = 20, &$count, $parent = 0, $level = 0 ) {
>
> --------------------------------
> File       : wp-admin/includes/class-wp-terms-list-table.php:159
> Reason     : TooManyArgument
> Snippet    : $this->single_row($term, 0, $taxonomy)
> Line       : $out .= $this->single_row( $term, 0, $taxonomy );
>
> --------------------------------
> File       : wp-admin/includes/class-wp-terms-list-table.php:202
> Reason     : TooManyArgument
> Snippet    : $this->single_row($my_parent, $level - $num_parents,
> $taxonomy)
> Line       : $output .=  "\t" . $this->single_row( $my_parent, $level -
> $num_parents, $taxonomy );
>
> --------------------------------
> File       : wp-admin/includes/class-wp-terms-list-table.php:208
> Reason     : TooManyArgument
> Snippet    : $this->single_row($term, $level, $taxonomy)
> Line       : $output .= "\t" . $this->single_row( $term, $level,
> $taxonomy );
>
> --------------------------------
> File       : wp-includes/SimplePie/Locator.php:94
> Reason     : RequiredAfterOptionalParam
> Snippet    : $type = SIMPLEPIE_LOCATOR_ALL
> Line       : public function find($type = SIMPLEPIE_LOCATOR_ALL,
> &$working)
>
> --------------------------------
> File       : wp-includes/class-wp-walker.php:118
> Reason     : RequiredAfterOptionalParam
> Snippet    : $depth = 0
> Line       : function display_element( $element, &$children_elements,
> $max_depth, $depth=0, $args, &$output ) {
>
> --------------------------------
> File       : wp-includes/comment-template.php:1298
> Reason     : RequiredAfterOptionalParam
> Snippet    : $depth = 0
> Line       : function display_element( $element, &$children_elements,
> $max_depth, $depth=0, $args, &$output ) {
>
> --------------------------------
> File       : wp-includes/deprecated.php:802
> Reason     : RequiredAfterOptionalParam
> Snippet    : $echo = false
> Line       : function get_author_link($echo = false, $author_id,
> $author_nicename = '') {
>
> --------------------------------
> File       : wp-includes/deprecated.php:1709
> Reason     : TooManyArgument
> Snippet    : get_the_content($more_link_text, $stripteaser, $more_file)
> Line       : $content = get_the_content($more_link_text, $stripteaser,
> $more_file);
>
> --------------------------------
> File       : wp-includes/ID3/module.tag.id3v2.php:433
> Reason     : TooFewArgument
> Snippet    : substr($footer[5])
> Line       : $id3_flags = ord(substr($footer{5}));
>
> --------------------------------
> File       : wp-includes/ID3/module.tag.id3v2.php:1586
> Reason     : StatementHasNoEffect
> Snippet    : $frame_ownerid == '';
> Line       : $frame_ownerid == '';
>
> --------------------------------
> File       : wp-includes/rewrite.php:92
> Reason     : TooManyArgument
> Snippet    : remove_action($hook, $hook, 10, 1)
> Line       : remove_action($hook, $hook, 10, 1);
>
> --------------------------------
> File       : wp-admin/includes/user.php:350
> Reason     : TooManyArgument
> Snippet    : delete_user_setting('default_password_nag', $user_ID)
> Line       : delete_user_setting('default_password_nag', $user_ID);
>
> --------------------------------
> File       : wp-includes/ID3/module.audio.mp3.php:37
> Reason     : TooManyArgument
> Snippet    : $this->getOnlyMPEGaudioInfoBruteForce($this->getid3->fp,
> $info)
> Line       : $this->getOnlyMPEGaudioInfoBruteForce($this->getid3->fp,
> $info);
>
> --------------------------------
> File       : wp-includes/SimplePie/Misc.php:127
> Reason     : TooManyArgument
> Snippet    : SimplePie_Misc::entities_decode(end($attribs[$j]), 'UTF-8')
> Line       : $return[$i]['attribs'][strtolower($attribs[$j][1])]['data']
> = SimplePie_Misc::entities_decode(end($attribs[$j]),
> 'UTF-8');
> }}}
>
> Resolved:
> {{{
> --------------------------------
> File       : wp-includes/media.php:2453
> Reason     : UnknownFunction
> Snippet    : sprint($link_fmt, $image)
> Line       : $image = sprint( $link_fmt, $image );
>
> --------------------------------
> File       : wp-includes/media.php:1040
> Reason     : TooManyArgument
> Snippet    : wp_mediaelement_fallback($fileurl, $width, $height)
> Line       : $html .= wp_mediaelement_fallback( $fileurl, $width, $height
> );
>
> --------------------------------
> File       : wp-includes/Text/Diff/Engine/xdiff.php:30
> Reason     : UnknownFunction
> Snippet    : xdiff_string_diff($from_string, $to_string,
> count($to_lines))
> Line       : $diff = xdiff_string_diff($from_string, $to_string,
> count($to_lines));
>
> --------------------------------
> File       : wp-admin/includes/class-wp-terms-list-table.php:159
> Reason     : UseVoidReturn
> Snippet    : $this->single_row($term, 0, $taxonomy)
> Line       : $out .= $this->single_row( $term, 0, $taxonomy );
>
> --------------------------------
> File       : wp-admin/includes/class-wp-terms-list-table.php:202
> Reason     : UseVoidReturn
> Snippet    : $this->single_row($my_parent, $level - $num_parents,
> $taxonomy)
> Line       : $output .=  "\t" . $this->single_row( $my_parent, $level -
> $num_parents, $taxonomy );
>
> --------------------------------
> File       : wp-admin/includes/class-wp-terms-list-table.php:208
> Reason     : UseVoidReturn
> Snippet    : $this->single_row($term, $level, $taxonomy)
> Line       : $output .= "\t" . $this->single_row( $term, $level,
> $taxonomy );
>
> --------------------------------
> File       : wp-admin/includes/class-wp-terms-list-table.php:228
> Reason     : UseVoidReturn
> Snippet    : $this->single_row_columns($tag)
> Line       : echo $this->single_row_columns( $tag );
>
> --------------------------------
> File       : wp-includes/wp-db.php:648
> Reason     : TooManyArgument
> Snippet    : $this->has_cap('collation', $dbh)
> Line       : if ( $this->has_cap( 'collation', $dbh ) && !empty( $charset
> ) ) {
>
> --------------------------------
> File       : wp-includes/wp-db.php:649
> Reason     : TooManyArgument
> Snippet    : $this->has_cap('set_charset', $dbh)
> Line       : if ( function_exists( 'mysql_set_charset' ) &&
> $this->has_cap( 'set_charset', $dbh ) ) {
>
> --------------------------------
> File       : wp-admin/network/site-settings.php:63
> Reason     : TooManyArgument
> Snippet    : update_option($key, $val, false)
> Line       : update_option( $key, $val, false ); // no need to refresh
> blog details yet
>
> --------------------------------
> File       : wp-admin/network/site-settings.php:126
> Reason     : TooManyArgument
> Snippet    : esc_html(maybe_unserialize($option->option_value), 'single')
> Line       : $option->option_value = esc_html( maybe_unserialize(
> $option->option_value ), 'single' );
>
> --------------------------------
> File       : wp-admin/includes/class-wp-comments-list-table.php:318
> Reason     : UseVoidReturn
> Snippet    : $this->single_row_columns($comment)
> Line       : echo $this->single_row_columns( $comment );
>
> --------------------------------
> File       : wp-admin/includes/class-wp-list-table.php:829
> Reason     : UseVoidReturn
> Snippet    : $this->single_row_columns($item)
> Line       : echo $this->single_row_columns( $item );
>
> --------------------------------
> File       : wp-admin/includes/class-wp-upgrader.php:1132
> Reason     : UseVoidReturn
> Snippet    : screen_icon()
> Line       : echo screen_icon();
>
> --------------------------------
> File       : wp-admin/includes/class-wp-posts-list-table.php:386
> Reason     : UseVoidReturn
> Snippet    : $this->single_row($page, $level)
> Line       : echo "\t" . $this->single_row( $page, $level );
>
> --------------------------------
> File       : wp-admin/includes/class-wp-posts-list-table.php:401
> Reason     : UseVoidReturn
> Snippet    : $this->single_row($op, 0)
> Line       : echo "\t" . $this->single_row( $op, 0 );
>
> --------------------------------
> File       : wp-admin/includes/class-wp-posts-list-table.php:447
> Reason     : UseVoidReturn
> Snippet    : $this->single_row($my_parent, $level - $num_parents)
> Line       : echo "\t" . $this->single_row( $my_parent, $level -
> $num_parents );
>
> --------------------------------
> File       : wp-admin/includes/class-wp-posts-list-table.php:453
> Reason     : UseVoidReturn
> Snippet    : $this->single_row($page, $level)
> Line       : echo "\t" . $this->single_row( $page, $level );
> }}}

New description:

 These all look like valid, but minor, issues:
 {{{
 --------------------------------
 File       : wp-includes/class-json.php:495
 Reason     : UnknownFunction
 Snippet    : class_name($var)
 Line       : : new Services_JSON_Error(class_name($var).

 --------------------------------
 File       : wp-includes/SimplePie/Locator.php:94
 Reason     : RequiredAfterOptionalParam
 Snippet    : $type = SIMPLEPIE_LOCATOR_ALL
 Line       : public function find($type = SIMPLEPIE_LOCATOR_ALL,
 &$working)

 --------------------------------
 File       : wp-includes/ID3/module.tag.id3v2.php:433
 Reason     : TooFewArgument
 Snippet    : substr($footer[5])
 Line       : $id3_flags = ord(substr($footer{5}));

 --------------------------------
 File       : wp-includes/ID3/module.tag.id3v2.php:1586
 Reason     : StatementHasNoEffect
 Snippet    : $frame_ownerid == '';
 Line       : $frame_ownerid == '';

 --------------------------------
 File       : wp-includes/ID3/module.audio.mp3.php:37
 Reason     : TooManyArgument
 Snippet    : $this->getOnlyMPEGaudioInfoBruteForce($this->getid3->fp,
 $info)
 Line       : $this->getOnlyMPEGaudioInfoBruteForce($this->getid3->fp,
 $info);

 --------------------------------
 File       : wp-includes/SimplePie/Misc.php:127
 Reason     : TooManyArgument
 Snippet    : SimplePie_Misc::entities_decode(end($attribs[$j]), 'UTF-8')
 Line       : $return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] =
 SimplePie_Misc::entities_decode(end($attribs[$j]),
 'UTF-8');
 }}}

 Resolved:
 {{{
 --------------------------------
 File       : wp-includes/class-wp-walker.php:118
 Reason     : RequiredAfterOptionalParam
 Snippet    : $depth = 0
 Line       : function display_element( $element, &$children_elements,
 $max_depth, $depth=0, $args, &$output ) {

 --------------------------------
 File       : wp-includes/comment-template.php:1298
 Reason     : RequiredAfterOptionalParam
 Snippet    : $depth = 0
 Line       : function display_element( $element, &$children_elements,
 $max_depth, $depth=0, $args, &$output ) {

 --------------------------------
 File       : wp-includes/deprecated.php:802
 Reason     : RequiredAfterOptionalParam
 Snippet    : $echo = false
 Line       : function get_author_link($echo = false, $author_id,
 $author_nicename = '') {

 --------------------------------
 File       : wp-includes/deprecated.php:1709
 Reason     : TooManyArgument
 Snippet    : get_the_content($more_link_text, $stripteaser, $more_file)
 Line       : $content = get_the_content($more_link_text, $stripteaser,
 $more_file);

 --------------------------------
 File       : wp-signup.php:493
 Reason     : RequiredAfterOptionalParam
 Snippet    : $user_name = ''
 Line       : function confirm_blog_signup($domain, $path, $blog_title,
 $user_name = '', $user_email = '', $meta) {

 --------------------------------
 File       : wp-signup.php:493
 Reason     : RequiredAfterOptionalParam
 Snippet    : $user_email = ''
 Line       : function confirm_blog_signup($domain, $path, $blog_title,
 $user_name = '', $user_email = '', $meta) {

 --------------------------------
 File       : wp-includes/widgets.php:76
 Reason     : RequiredAfterOptionalParam
 Snippet    : $id_base = false
 Line       : function WP_Widget( $id_base = false, $name, $widget_options
 = array(), $control_options = array() ) {

 --------------------------------
 File       : wp-includes/widgets.php:93
 Reason     : RequiredAfterOptionalParam
 Snippet    : $id_base = false
 Line       : function __construct( $id_base = false, $name,
 $widget_options = array(), $control_options = array() ) {

 --------------------------------
 File       : wp-includes/post.php:4789
 Reason     : RequiredAfterOptionalParam
 Snippet    : $deprecated = ''
 Line       : function _future_post_hook( $deprecated = '', $post ) {

 --------------------------------
 File       : wp-admin/includes/class-wp-terms-list-table.php:173
 Reason     : RequiredAfterOptionalParam
 Snippet    : $start = 0
 Line       : function _rows( $taxonomy, $terms, &$children, $start = 0,
 $per_page = 20, &$count, $parent = 0, $level = 0 ) {

 --------------------------------
 File       : wp-admin/includes/class-wp-terms-list-table.php:173
 Reason     : RequiredAfterOptionalParam
 Snippet    : $per_page = 20
 Line       : function _rows( $taxonomy, $terms, &$children, $start = 0,
 $per_page = 20, &$count, $parent = 0, $level = 0 ) {

 --------------------------------
 File       : wp-includes/rewrite.php:92
 Reason     : TooManyArgument
 Snippet    : remove_action($hook, $hook, 10, 1)
 Line       : remove_action($hook, $hook, 10, 1);

 --------------------------------
 File       : wp-admin/includes/user.php:350
 Reason     : TooManyArgument
 Snippet    : delete_user_setting('default_password_nag', $user_ID)
 Line       : delete_user_setting('default_password_nag', $user_ID);

 --------------------------------
 File       : wp-admin/includes/class-wp-terms-list-table.php:159
 Reason     : TooManyArgument
 Snippet    : $this->single_row($term, 0, $taxonomy)
 Line       : $out .= $this->single_row( $term, 0, $taxonomy );

 --------------------------------
 File       : wp-admin/includes/class-wp-terms-list-table.php:202
 Reason     : TooManyArgument
 Snippet    : $this->single_row($my_parent, $level - $num_parents,
 $taxonomy)
 Line       : $output .=  "\t" . $this->single_row( $my_parent, $level -
 $num_parents, $taxonomy );

 --------------------------------
 File       : wp-admin/includes/class-wp-terms-list-table.php:208
 Reason     : TooManyArgument
 Snippet    : $this->single_row($term, $level, $taxonomy)
 Line       : $output .= "\t" . $this->single_row( $term, $level, $taxonomy
 );

 --------------------------------
 File       : wp-includes/media.php:2453
 Reason     : UnknownFunction
 Snippet    : sprint($link_fmt, $image)
 Line       : $image = sprint( $link_fmt, $image );

 --------------------------------
 File       : wp-includes/media.php:1040
 Reason     : TooManyArgument
 Snippet    : wp_mediaelement_fallback($fileurl, $width, $height)
 Line       : $html .= wp_mediaelement_fallback( $fileurl, $width, $height
 );

 --------------------------------
 File       : wp-includes/Text/Diff/Engine/xdiff.php:30
 Reason     : UnknownFunction
 Snippet    : xdiff_string_diff($from_string, $to_string, count($to_lines))
 Line       : $diff = xdiff_string_diff($from_string, $to_string,
 count($to_lines));

 --------------------------------
 File       : wp-admin/includes/class-wp-terms-list-table.php:159
 Reason     : UseVoidReturn
 Snippet    : $this->single_row($term, 0, $taxonomy)
 Line       : $out .= $this->single_row( $term, 0, $taxonomy );

 --------------------------------
 File       : wp-admin/includes/class-wp-terms-list-table.php:202
 Reason     : UseVoidReturn
 Snippet    : $this->single_row($my_parent, $level - $num_parents,
 $taxonomy)
 Line       : $output .=  "\t" . $this->single_row( $my_parent, $level -
 $num_parents, $taxonomy );

 --------------------------------
 File       : wp-admin/includes/class-wp-terms-list-table.php:208
 Reason     : UseVoidReturn
 Snippet    : $this->single_row($term, $level, $taxonomy)
 Line       : $output .= "\t" . $this->single_row( $term, $level, $taxonomy
 );

 --------------------------------
 File       : wp-admin/includes/class-wp-terms-list-table.php:228
 Reason     : UseVoidReturn
 Snippet    : $this->single_row_columns($tag)
 Line       : echo $this->single_row_columns( $tag );

 --------------------------------
 File       : wp-includes/wp-db.php:648
 Reason     : TooManyArgument
 Snippet    : $this->has_cap('collation', $dbh)
 Line       : if ( $this->has_cap( 'collation', $dbh ) && !empty( $charset
 ) ) {

 --------------------------------
 File       : wp-includes/wp-db.php:649
 Reason     : TooManyArgument
 Snippet    : $this->has_cap('set_charset', $dbh)
 Line       : if ( function_exists( 'mysql_set_charset' ) &&
 $this->has_cap( 'set_charset', $dbh ) ) {

 --------------------------------
 File       : wp-admin/network/site-settings.php:63
 Reason     : TooManyArgument
 Snippet    : update_option($key, $val, false)
 Line       : update_option( $key, $val, false ); // no need to refresh
 blog details yet

 --------------------------------
 File       : wp-admin/network/site-settings.php:126
 Reason     : TooManyArgument
 Snippet    : esc_html(maybe_unserialize($option->option_value), 'single')
 Line       : $option->option_value = esc_html( maybe_unserialize(
 $option->option_value ), 'single' );

 --------------------------------
 File       : wp-admin/includes/class-wp-comments-list-table.php:318
 Reason     : UseVoidReturn
 Snippet    : $this->single_row_columns($comment)
 Line       : echo $this->single_row_columns( $comment );

 --------------------------------
 File       : wp-admin/includes/class-wp-list-table.php:829
 Reason     : UseVoidReturn
 Snippet    : $this->single_row_columns($item)
 Line       : echo $this->single_row_columns( $item );

 --------------------------------
 File       : wp-admin/includes/class-wp-upgrader.php:1132
 Reason     : UseVoidReturn
 Snippet    : screen_icon()
 Line       : echo screen_icon();

 --------------------------------
 File       : wp-admin/includes/class-wp-posts-list-table.php:386
 Reason     : UseVoidReturn
 Snippet    : $this->single_row($page, $level)
 Line       : echo "\t" . $this->single_row( $page, $level );

 --------------------------------
 File       : wp-admin/includes/class-wp-posts-list-table.php:401
 Reason     : UseVoidReturn
 Snippet    : $this->single_row($op, 0)
 Line       : echo "\t" . $this->single_row( $op, 0 );

 --------------------------------
 File       : wp-admin/includes/class-wp-posts-list-table.php:447
 Reason     : UseVoidReturn
 Snippet    : $this->single_row($my_parent, $level - $num_parents)
 Line       : echo "\t" . $this->single_row( $my_parent, $level -
 $num_parents );

 --------------------------------
 File       : wp-admin/includes/class-wp-posts-list-table.php:453
 Reason     : UseVoidReturn
 Snippet    : $this->single_row($page, $level)
 Line       : echo "\t" . $this->single_row( $page, $level );
 }}}

--

Comment (by nacin):

 Thanks, Rasmus, for testing your tool on WordPress trunk.

 The only ones left by my count are from ID3, Services_JSON, and SimplePie.

 SimplePie upstream: https://github.com/simplepie/simplepie/issues/293
 (open) and https://github.com/simplepie/simplepie/pull/291 (merged)

 Services_JSON upstream: http://pear.php.net/bugs/bug.php?id=19920

 The lack of recent activity upstream for ID3 (not to mention the use of a
 phpbb forum as a bug tracker) scares the hell out of me:
 http://www.getid3.org/phpBB3/viewforum.php?f=4

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/24210#comment:28>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list