Hi,
I looked up through all Drupal 7(8) core files and found a list of bugs and typos:

1. drupal_valid_path() has undefined variable $form_item.

2. In _theme_table_cell() in case when $cell is not an array variable $attributes might be undefined.

3. In update_fix_d7_install_profile() variable $file is undefined and unnecessary incorrect: See #1479572-5: Fix undefined variable error in update_fix_d7_install_profile().

4. Updater::prepareInstallDirectory has undefined $install_location.

5. Updater::update calls Updater::makeBackup() function with 2 arguments but it requires three.

6. In drupal_var_export() is a concatination to undefined variable $output in this case:

  elseif (is_object($var) && get_class($var) === 'stdClass') {
    // var_export() will export stdClass objects using an undefined
    // magic method __set_state() leaving the export broken. This
    // workaround avoids this by casting the object as an array for
    // export and casting it back to an object when evaluated.
    $output .= '(object) ' . drupal_var_export((array) $var, $prefix);
  }

7. In DatabaseStatementPrefetch::current PHP function array_unshift() are used incorrectly (required second parameter is missing):

case PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE:
  $class_name = array_unshift($this->currentRow);

And the second bug here. Variable $k is undefined:

case PDO::FETCH_COLUMN:
  if (isset($this->columnNames[$this->fetchOptions['column']])) {
    return $this->currentRow[$k][$this->columnNames[$this->fetchOptions['column']]];
  }
  else {
    return;
  }

8. In field_sql_storage_field_storage_query() variables $select_query and $field_base_table are undefined in this case:

if ($key) {
  $select_query->join($tablename, $table_alias, "$table_alias.entity_type = $field_base_table.entity_type AND $table_alias.$id_key = $field_base_table.$id_key");
    }

Edit by chx: this is a loop over a list (array with int keys starting from 0) and the !$key case will always come first which defines these variables.

9. In field_test_field_attach_delete_bundle() variable $bundle_old is undefined.

10. hook_field_delete() and hook_field_delete_revision() has wrong example of API usage: function file_field_delete_file() takes at least 4 arguments, but in documentation of this hooks file_field_delete_file() takes only 2 arguments.

11. In image_effect_definitions() I'm not sure that $cache->data is ready to check in the if clause:
if ($cache = cache_get("image_effects:$langcode") && !empty($cache->data)) {
$effects = $cache->data;
}

12. In documentation of hook_node_grants_alter() variable $user is undefined.

13. In documentation of hook_prepare() function file_check_upload() are deprecated since Drupal 6. Variable $field_name is undefined. Function _image_build_derivatives() is deprecated since Drupal 7.

14. In search_index() in case when $tag is FALSE variable $linktitle is undefined.

#1: #876580: drupal_valid_path fails for dynamic paths (e.g. user/% cannot be added to menus)
#2: -- (looks fine to Droplet, see comment #7)
#3: #1479572: Fix undefined variable error in update_fix_d7_install_profile()
#4: #1423510: Undefined var in prepareInstallDirectory
#5: #1476804: Updater::update calls Updater::makeBackup() function with 2 arguments but it requires three
#6: #1476776: drupal_var_export() is a concatenation to undefined variable $output
#7: #1476782: DatabaseStatementPrefetch::current PHP function array_unshift() are used incorrectly
#8: FIXED (see above chx's comment)
#9: -- (needs work)
#10: #1476812: hooks file_field_delete_file() takes only 2 arguments
#11: #1469758: Define $user in hook_node_grants_alter
#12: #1469758: Define $user in hook_node_grants_alter
#13: -- (needs work)
#14: #1479618: $linktitle is undefined in search_index()

Comments

spleshka’s picture

Issue summary: View changes

Fixed typo in a word 'used'.

spleshka’s picture

Issue summary: View changes

Added bracers to some functions.

oriol_e9g’s picture

Issue summary: View changes

Fixed typo.

oriol_e9g’s picture

Title: List of bugs and typos in Drupal core » [META] List of bugs and typos in Drupal core
Version: 7.x-dev » 8.x-dev
Priority: Major » Normal

Fix first in D8 and in a separate issues.

4) #1423510: Undefined var in prepareInstallDirectory

andypost’s picture

good bunch of notices! actually they should be filed as separate issues with Novice and Quick fix tags and checked for backportability...

chertzog’s picture

chertzog’s picture

Issue summary: View changes

Some typos were fixed.

chx’s picture

Issue summary: View changes

deleted 8

chx’s picture

To keep this issue manageable I edited the original node (which crossing out a bogus report).

chertzog’s picture

chertzog’s picture

Issue summary: View changes

Deleted 4 and 12

droplet’s picture

Issue summary: View changes

update fixed issue

droplet’s picture

Issue summary: View changes

add #14 issue thread

droplet’s picture

Issue summary updated.

#2, (SOLVED) predefined $attributes = ''; in function. so not a problem
#9, #13 is doc issue, needs seek a better / up-to-date example code

droplet’s picture

Issue summary: View changes

add #1

pillarsdotnet’s picture

Issue summary: View changes

Link to issue for #3.

pol’s picture

Regarding issue 9 (In field_test_field_attach_delete_bundle() variable $bundle_old is undefined), I gave a look at it this morning.

The test is this:

/**
 * Implements hook_field_attach_delete_bundle().
 */
function field_test_field_attach_delete_bundle($entity_type, $bundle, $instances) {
  $data = _field_test_storage_data();

  foreach ($instances as $field_name => $instance) {
    $field = field_info_field($field_name);
    if ($field['storage']['type'] == 'field_test_storage') {
      $field_data = &$data[$field['id']];
      foreach (array('current', 'revisions') as $sub_table) {
        foreach ($field_data[$sub_table] as &$row) {
          if ($row->bundle == $bundle_old) {
            $row->deleted = TRUE;
          }
        }
      }
    }
  }

  _field_test_storage_data($data);
}

And it doesn't pass the line:

    $field = field_info_field($field_name);

because the variable $field is NULL.

Now I don't have enough skills to go further... I'm still digging.

droplet’s picture

@Pol,

I think someone just copy the rename function and paste into delete_bundle.

https://api.drupal.org/api/drupal/modules%21field%21tests%21field_test.s...

It can remove the IF condition.

pol’s picture

@droplet, ah ok, that makes sense... I'll try to create a new test then, but first, I gotta read the field API ;-)

valthebald’s picture

Issue tags: +dcwroc2014

We are going to work on this issue during DCWroclaw 2014

manningpete’s picture

Issue tags: -Novice

Removing Novice tag.
There's nothing specific for a Novice to do on this.
Novice tag documentation: https://www.drupal.org/core-mentoring/novice-tasks

yesct’s picture

Title: [META] List of bugs and typos in Drupal core » [META] List of bugs and typos in Drupal core found by Spleshka
Status: Active » Closed (duplicate)

this is kind of an unusual meta... it is not really a list of all bugs and typos, but just a list found by this one person so they could track solving each separate thing. (having separate issues is great.)

retitling.

we could close this and just leave the individual issues open on their own as appropriate. ... yeah doing that.