I have been trying to resolve this error that I've been getting for some time and have finally figured it out so I wanted to share it with others. I was unable to find a post on the forums or elsewhere that resolved my particular problem.

warning: Invalid argument supplied for foreach() in [path to]/modules/taxonomy/taxonomy.module on line 1241.

I wrote a basic module that just checked nodes, node_revisions, taxonomy and users. It turns out that the majority of my "warnings" were from referencing a user.uid in the node and node_revisions table that did NOT exist in the user table.

Due to importing multiple Wordpress blogs and other content a number of users were created and then deleted from the users table to "clean things up" (as in someone went into phpadmin and deleted those rows with that uid). Over time this caused problems, especially when (re)indexing with the Solr module.

The module report I wrote compared nodes and the nodes loaded up using node_load. The majority of the warnings were resolved by just recreating an account with that user id (uid) in phpmyadmin and assigning it the missing uid. I think updating both the nodes and node_revisions table to a valid user's iud would work but I didn't want to take the risk of corrupting something else, hence recreating the deleted account.

Comments

Avaya’s picture

Not sure where to add this, but I turned my script into a Drupal reporting module. It checks various consistencies between tables and displays them. It seemed part of the problem with my errors was someone deleting rows from the node_revisions, users, term_node and vocabulary tables.

If you would like to try the report, let me know. It's bundled up already in a nice tar.gz.

ckreutz’s picture

Hi Avaya,

I have the same problem after a migration to 6.x. Would be great to have the script to check where my missing rows are.
Thanks in advance!

CLKeenan’s picture

Can you send me the file as well? Would be really helpful! clpkeenan [ AT ] gmail [ dot ] com

jvieille’s picture

I have this problem too
Could you please make this module available, at least "informally"
If you prefer not release it publicly, I would be glad to get it by email
Thanks

JV

jeannine’s picture

Could I have a copy too? Thanks so much
jmhaney [at] alaska [dot] edu

jvieille’s picture

j.vieille (at) controlchaingroup.com

JV

leon85321’s picture

Hi,

I am having that problem too, please send me a file to leonyang[dot]tech[at]gmail[dot]com

Thank you,

thiago.oliveira’s picture

Solution for error:
warning: Invalid argument supplied for foreach () in / var / www / html / modules / taxonomy / taxonomy.module on line 1241.

-> / modules / taxonomy / taxonomy.module on line 1241
/**
* Implementation of hook_nodeapi('update_index').
*/

function taxonomy_node_update_index(&$node) {
$output = array();
if(!empty ($node->taxonomy)){
foreach ($node->taxonomy as $term) {
$output[] = $term->name;
}
}

if (count($output)) {
return '('. implode(', ', $output) .')';
}
}

Good look!

Avaya’s picture

I didn't realize there was activity on this thread. I'll subscribe to it from now on. Also, this report helped resolve the issues I was having; it may or may not help resolve yours. It you find out that it doesn't help, let me know and I'll work to add other inconsistencies and problems to this report.

Provided is the code (sorry, didn't see how to attach any files).

The report is run in [drupal root]/sites/all/modules.

  1. mkdir [drupal root]/sites/all/modules/special_reports
  2. mkdir [drupal root]/sites/all/modules/special_reports/css
  3. in special_reports/ create node_debug_info.info using:
    ; $Id: node_debug_info.info,v .1a 2010/06/23 11:10:07 egerm Exp $
    name = Node Debug Information Report
    description = Assist in resolving the "warning: Invalid argument supplied for foreach() in [path to]/modules/taxonomy/taxonomy.module on line 1241." problem
    package = Special Reports
    version = VERSION
    core = 6.x
    
  4. in special_reports/ create node_debug_info.module using:
    <?php
    
    // $Id$ node_debug_info.module,v .1a 2010/06/23 11:10:07 egerm Exp $
    
    
    
    /**
    
     * @file
    
     * Node Debug Report
    
     *
    
     * resovle the "warning: Invalid argument supplied for foreach() 
    
     *  in /[path to]/modules/taxonomy/taxonomy.module on 
    
     *  line 1241." issue.
    
     *
    
     */
    
    
    
    /**
    
     * Dislplay in the Administrator menu
    
     * @return  :  array containing the information to display in menu
    
     *
    
     */
    
    function node_debug_info_menu() {
    
      $items = array();
    
    
    
      // for the reports
    
      $items['admin/reports/node_debug_info'] = array(
    
        'title' => 'Node Debug Information Report',
    
        'description' => 'Display possibles node and table discrepancies.',
    
        'page callback' => 'node_debug_info_information',
    
        'access arguments' => array('access system info'),
    
      );
    
    
    
      return ($items);
    
    }
    
    
    
    
    
    /**
    
     * Display the report
    
     *
    
     */
    
    function node_debug_info_information() {
    
      // get term_data information; note PK is tid, but vid is the vocab id used
    
      $result = db_query("SELECT * FROM {term_data} ORDER BY tid");
    
      while ($row = db_fetch_array($result)) {
    
        $term_data[$row["tid"]] = array(
    
          "vid" => $row["vid"], 
    
          "name" => $row["name"], 
    
          "description" => $row["description"]
    
        );
    
      }
    
    
    
      // get term_node information; note PK is tid + vid
    
      // tid = term_date.nid
    
      // vid = node.vid
    
      // nid = node.nid
    
      $result = db_query("SELECT * FROM {term_node} ORDER BY nid");
    
      while ($row = db_fetch_array($result)) {
    
        $term_node[$row["nid"]] = array("vid" => $row["vid"], "tid" => $row["tid"]);
    
      }
    
    
    
      // get node information
    
      $result = db_query("SELECT * FROM {node} ORDER BY vid");
    
      while ($row = db_fetch_array($result)) {
    
        $node_vid[$row["vid"]] = $row["title"];
    
        $node[$row["nid"]] = array(
    
          "vid" => $row["vid"],
    
          "type" => $row["type"],
    
          "title" => $row["title"],
    
          "uid" => $row["uid"],
    
          "created" => $row["created"],
    
          "changed" => $row["changed"]
    
        );
    
      }
    
    
    
      // get user information
    
      $result = db_query("SELECT * FROM {users} ORDER BY uid");
    
      while ($row = db_fetch_array($result)) {
    
        $users[$row["uid"]] = $row["name"];
    
      }
    
    
    
      // get term_data information; note PK is tid, but vid is the vocab id used
    
      $result = db_query("SELECT vid, name FROM {vocabulary} ORDER BY vid");
    
      while ($row = db_fetch_array($result)) {
    
        $vocabulary[$row["vid"]] = $row["name"];
    
      }
    
    
    
      $out = <<<TREE
    
        <p>The following is a report that queries various tables: node, node_revisions, term_data,
    
            term_node, users and vocabulary. This report does not offer "solutions"; it just provides
    
            results that you need to interpret. Most of these can be resolved by modifying rows within
    
            specific tables. This report does not tell you which rows within the tables to modify.</p>
    
    TREE;
    
      // save out to compare later
    
      $out_no_errors = $out;
    
    
    
    
    
      //
    
      // look for a term_node.tid that does not exist in term_data.tid
    
      //
    
      $heading_term = "<h3>Using a term_data that does not exist</h3>
    
        <p>This issue can be resolved by either: 1)
    
        creating a term_data.tid with the tid of the missing, or 2) delete any row contianing that
    
        value in term_node.tid
    
        with ";
    
      foreach ($term_node as $index => $joint) {
    
        if (!array_key_exists($joint["tid"], $term_data)) {
    
          @$out .= $heading_term . "<p>{$joint["tid"]} does not exist in term_data.tid
    
            <blockquote>
    
            term_node index/key: $index<br />
    
            nid: {$joint["nid"]} = {$term_data[$index]["name"]}<br />
    
            vid: {$joint["vid"]} = {$node_vid[$joint["vid"]]}
    
            </blockquote></p>";
    
            unset($heading_term);
    
      } }
    
    
    
    
    
      //
    
      // check the vocabulary
    
      //
    
      $heading_vocab = "<h3>Missing Vocabulary</h3><p>The following is a list of term_data.vid that are NOT in
    
        the vocabulary.vid. If a new vocabulary.vid is created all will be well.</p>";
    
      // look for missing vocabulary entries
    
      foreach ($term_data as $index => $data) {
    
        if (!array_key_exists($data["vid"], $vocabulary)) {
    
          @$out .= $heading_vocab . "<p>this term_data.vid/vocabulary.vid {$data["vid"]} IS NOT in vocabulary</p>";
    
          unset($heading_vocab);
    
      } }
    
    
    
    
    
      //
    
      // look for gjunked up nodes
    
      //
    
      foreach ($node as $index => $data) {
    
        //$dump = ecd_node_load($index, NULL, TRUE);
    
        $dump = node_load($index, NULL, TRUE);
    
        if (empty($dump->taxonomy)) {
    
          if ($index != $dump->nid) {
    
            $refurb[] = $index;
    
      } } }
    
      //e_r($node);
    
      
    
      // if there were errors loading nodes, determine why they were bad
    
      if ($refurb) {
    
        // loop through the bad nodes to figure out what is wrong with them
    
        foreach ($refurb as $bad) {
    
          //$result = db_query("SELECT * FROM {node_revisions} WHERE nid=$bad");
    
          $result = db_query("SELECT * FROM {node_revisions} WHERE nid=%d", $bad);
    
          $fetch = db_fetch_array($result);
    
    
    
          // if no result was found
    
          if (!$fetch) {
    
            $result = db_query("SELECT * FROM {node_revisions} WHERE vid=%d", $node[$bad]["vid"]);
    
            $fetch_vid = db_fetch_array($result);
    
            if (!$fetch_vid) {
    
              // if the node.nid cannot be found in node_revisions.nid, then there are greater forces at play
    
              @$out .= "<h3>node.nid($bad) CANNOT be found in node_revisions.nid</h3>
    
                <p>The node_revisions table lacks the row being called from node.nid($bad) with it's
    
                matching node.vid. <em>There is also not a node_revisions.vid({$node[$bad]["vid"]}) in 
    
                node_revisions.</em> One solution to resolve this is to insert a row into node_revisions where:
    
                <blockquote>
    
                  node_revisions.nid = $bad<br />
    
                  node_revisions.vid = {$node[$bad]["vid"]}<br />
    
                  node_revisions.uid = {$node[$bad]["uid"]}<br />
    
                  node_revisions.title = {$node[$bad]["title"]}<br />
    
                  node_revisions.body = This is a recovery for lost content.<br />
    
                  node_revisions.teaser = This is a recovery for lost content.<br />
    
                </blockquote>
    
                </p>
    
                ";
    
            } 
    
            else {
    
              // if the node.nid cannot be found in node_revisions.nid, then there are greater forces at play
    
              @$out .= "<h3>node.nid($bad) CANNOT be found in node_revisions.nid</h3>
    
                <p>The node_revisions table lacks the row being called from node.nid($bad) with it's
    
                matching node.vid.
    
                There IS a node_revisions.vid({$node[$bad]["vid"]}) that exists and it does not belong
    
                to the node.nid($bad) in question. This may prove to be
    
                diffucult to resolve.</p>
    
                <p>Information to assist in troubleshooting further:
    
                <blockquote>
    
                  node.nid = $bad<br />
    
                  node.vid = {$node[$bad]["vid"]}<br />
    
                  node.title = {$node[$bad]["title"]}<br />
    
                  node_revisions.nid = DOES NOT EXIST<br />
    
                  node_revisions.vid = {$node[$bad]["vid"]}, EXISTS
    
                </blockquote>
    
                </p>
    
                ";
    
            } 
    
          } 
    
          elseif (!array_key_exists($fetch["uid"], $users)) {
    
            // check to make sure a node_revisions.uid actually exists in the users.uid
    
            // create users.uid 16 to resolve our problem
    
            $bad_users[$fetch["uid"]][$fetch["nid"] . "_" . $fetch["vid"]]["nid"] = $fetch["nid"];
    
            $bad_users[$fetch["uid"]][$fetch["nid"] . "_" . $fetch["vid"]]["vid"] = $fetch["vid"];
    
        } }
    
    
    
        // format the bad users
    
        if ($bad_users) {
    
          foreach ($bad_users as $index => $data) { 
    
            if (is_numeric($index)) {
    
              $temp_out = "<h3>Invalid user referenced: $index</h3><p><blockquote>";
    
              
    
              foreach ($data as $error) {
    
              $temp_out .= "node_revisions.nid({$error[nid]})
    
                & node_revisions.vid({$error[vid]}) 
    
                uses node_revisions.<b>uid</b>($index), 
    
                but users.uid($index) does NOT EXIST.<br />";
    
            }
    
            $temp_out .= "</blockquote></p>";
    
            @$out .= $temp_out;
    
      } } } }
    
    
    
      if ($out == $out_no_errors) {
    
        $out .= "<h3>No errors were found using this script, but that doesn't mean there are
    
          some.</h3>";
    
      }
    
      return ($out);
    
    }
    
    
    
    
    
    /**
    
     * Special debuging function
    
     *
    
     */
    
    /*
    
    function e_r($array, $title = "something important") {
    
      echo "<h4>$title</h4><pre>"; print_r($array); echo "</pre></p><hr /><br /></br />";
    
    }
    
     */
    
  5. in special_reports/ create special_reports.inc using (pretty sure this file is needed as I've created several special reports):
    <?php
    
    // $Id$ activated_modules.module,v 1 2010/07/01 11:10:07 egerm Exp $
    
    
    
    /**
    
     * @file
    
     * External functions used in various Special Reports
    
     *
    
     */
    
    
    
      /**
    
      * Checks active status (Active:1, In-Active:0)
    
      * @param  = value  : a number of representing the active status
    
      * @return        : a string with the active/in-active or error status
    
      *
    
      */
    
      function special_reports_status($value) {
    
      if ($value == 1)
    
        return ("Active");
    
      elseif ($value == 0)
    
        return ("In-active");
    
      else
    
        return ("Warning! Warning!! Warning Will Robinson! Error with the status.");
    
      }
    
    
    
      /**
    
      * Do zebra striping for cleaner results
    
      * @param    = has_children    : 
    
      * @param    = in_active_trail  : 
    
      * @return                    : returns an even/odd class for stripping
    
      *
    
      * Thanks to dmitrig01 May 8, 2008 - 04:47
    
      *   http://drupal.org/node/249598
    
      *
    
      */
    
      function special_reports_zebra($has_children = FALSE, $in_active_trail = FALSE) {
    
      static $zebra = FALSE;
    
      $zebra = !$zebra;
    
    
    
      if ($in_active_trail) {
    
        $class .= ' active-trail';
    
      }
    
      if ($zebra) {
    
        $class .= ' even';
    
      }
    
      else {
    
        $class .= ' odd';
    
      }
    
      return ($class);
    
      }
    
    
    
    
    
      /**
    
      * Check length of value; if too large/long, then display in textarea
    
      * @param    : string value being checked
    
      * @return  : the value, possibly wrapped in a textarea
    
      *
    
      */
    
      function special_reports_length($something) {
    
      $lines = count(explode("\n", $something));
    
      $length = drupal_strlen($something);
    
      if (($length > 34) || ($lines > 1)) {
    
        if ($lines > 10) {
    
          $lines = 10;
    
        }
    
        $something = '<textarea cols="64" rows="'. ($lines + 1) .'">'. $something .'</textarea>';
    
      } 
    
      return ($something);
    
      }
    
  6. in special_reports/css/ create special_reports.css using (pretty sure this file is needed as I've created several special reports):
    /* for zebra pin striping */
    tr.even {
      background-color: #eee;
    }
    
    tr.odd {
      background-color: #fff;
    }
    
    /* styles used to clean up report */
    .mod_name {
    	font-weight:bold;
    	font-size: +1;
    }
    
    .mod_desc {
    	font-size: -2;
    	font-style: italic;
    	padding-left: 2em;
    }
    
    .spec_group_set {
     padding-left: 2em;
     font-weight:bold;
    }
    
    .padding1l {
     padding-left: 1em;
    }
    
    .padding2l {
     padding-left: 2em;
    }
    
    .padding3l {
     padding-left: 3em;
    }
    
    
ckreutz’s picture

Thank you very much for the code. Report indicated 6 problems, which I erased. Ran cron again, but the erros remained. warning: Invalid argument supplied for foreach() in /drupal/modules/taxonomy/taxonomy.module on line 1241.

Avaya’s picture

It's not a simple "erase".

That report only went so far to resolve the problems I had. If you have a specific problem and you can tell me how to replicate it, I can try to work on resolving it.

What 6 problems did you have, and what did you do so far to "erase" the problems?

ckreutz’s picture

Thanks a lot for taking a look at it. The error is below. I then choose 2) delete any row contianing that value in term_node.tid. That is what I meant by erase in my previous post.

0 does not exist in term_data.tid
term_node index/key: 7672
nid: =
vid: 7776 = user111
10579 does not exist in term_data.tid
term_node index/key: 7680
nid: =
vid: 7784 = topic33
0 does not exist in term_data.tid
term_node index/key: 7692
nid: =
vid: 7796 = user333
0 does not exist in term_data.tid
term_node index/key: 7693
nid: =
vid: 7797 = teststs
0 does not exist in term_data.tid
term_node index/key: 7694
nid: =
vid: 7798 = user222
0 does not exist in term_data.tid
term_node index/key: 7696
nid: =
vid: 7800 = user333

Avaya’s picture

That doesn't help much. I would need to know more.

The only thing off hand I could think is to check if there is no term_data.tid = 0, and then verify if in the term_is indeed a term_node that is set to term_node.tid = 0; if both are true, then try adding a row into term_data with a tid = 0.

REMEMBER TO BACK UP YOUR DATA FIRST AND TRY IT ON A TEST SERVER FIRST

ckreutz’s picture

I checked for term.data.tid = 0 and term_node.tid = 0. In both tables there is not tid = 0. I imagine it is another inconsistency I have to investigate further. Once again thank you very much!

jvieille’s picture

Thank you very much.
Find one problem for a term not attached to a vocabulary.
I hope it was the reason for my 1241 random error

JV

fdambrosio’s picture

I have the same problem with the new Drupal release!

antarchi’s picture

This resolved a number of issues for me. I couldn't get the site to index properly because of the line 1241 error, and I had a number of taxonomy issues. Now it's indexed the site and fixed the tax errors! Many thanks

Goekmen’s picture

Thank you, worked for me too (6.19).

69teve’s picture

helped me to solve the problem.

marko42’s picture

Very helpful, but like others, I had an issue not covered: Nodes were orphaned from their user, which was deleted. I used the debugging code found at:

http://stream.zerolab.org/post/2419224606/invalid-argument-supplied-for-...

Thanks!
Mark

nuthman’s picture

Here is a link to the module in a zip file..

http://www.as3blog.org/special_reports.zip

in case anyone didn't want to copy and paste all that code :)

royerd’s picture

would it be possible for someone to create this module for me and post it send me a link to it?

oops . . . ugh. see it right there above.

bryanb229’s picture

It was a great help.

eyenology’s picture

I haven't been through this process before. I have the module installed, but where does it output the report?

eyenology’s picture

Due to an error created by copy and paste that caused a subsequent reinstall, I failed to re-enable the module. Doing so created what I needed under 'reports'

eyenology’s picture

Got the "No errors were found using this script, but that doesn't mean there are some." Except I get three of the errors that this node is about every time cron is run.

Avaya’s picture

Yeah, I can't guarantee my script will report every problem. I was limited to the problems I had with my data and was trying to resolve my issues. That being said, I don't mind trying to help others, but it's difficult when I don't know what to look for; there is only so far someone can help without having access to a clone of your site.

If you're able to figure out what is causing your problems, let me know and I will add that to the report so it helps the next person.

Best of luck.

eiland’s picture

the script gives me a Internal Server Error :(

David-F’s picture

Copy / pasting the code from the web page resulted in a funky character at the beginning of many lines for me (Mac OS). I couldn't see them on Mac, but on Windows they showed as a capital E with a caret ^ on top and caused PHP parsing errors. When I got rid of them, it worked fine.

tryitonce’s picture

subscribing ... thanks for the advice ....

Anticosti’s picture

Same issue here ;(

mmachina’s picture

warning: Invalid argument supplied for foreach() in ........ modules/taxonomy/taxonomy.module on line 1242.

Hi Avaya... I tried using the special_reports module you supplied, but afterwards I am still experiencing the same problem... only I am using 6.19 and it is happening on 1242 instead of line 1241...

gateway69’s picture

I get the same thing

warning: Invalid argument supplied for foreach() in /var/www/beta/modules/taxonomy/taxonomy.module on line 1242.

drupalina’s picture

Thanks for the module!
I need a little help...
Each time the cron runs these errors appear 17 times.

Your module tells me:

Missing Vocabulary
The following is a list of term_data.vid that are NOT in the vocabulary.vid. If a new vocabulary.vid is created all will be well.

this term_data.vid/vocabulary.vid 0 IS NOT in vocabulary

In my PhpMyAdmin I looked at my term_data tables and there were no terms associated with vid 0
I looked at vocabulary tables and there are 9 vocabularies, vid from 1-10, but no vid 8 (I guess it was deleted at some point) - otherwise there's nothing suspicious.

What would you advise I should do?

Avaya’s picture

Yeah, I can't guarantee my script will report every problem. I was limited to the problems I had with my data and was trying to resolve my issues. That being said, I don't mind trying to help others, but it's difficult when I don't know what to look for; there is only so far someone can help without having access to a clone of your site.

If you're able to figure out what is causing your problems, let me know and I will add that to the report so it helps the next person.

Best of luck.

All,

I have two drupal test sites that I test this against, and I'm limited with only the data set that I have, so it's difficult to figure out some problems. I'm a bit perplexed why the report does not work for some, and it works for others. It leads me to believe there are other inconsistencies with the data in particular tables.

If you have a test instance of drupal, where the information in those tables is not sensitive (meaning test data), and you have issues that are not being resolved using this report, I invite you to share that exported data and your exact setup (meaning active modules, their versions and drupal version) so that others, including myself, can work to incorporate more features in order to address varieties of problems into this reporting module.

I've only tested this reporting module using MySQL, not PostgreSQL. I'm curious to know how many are using PostgreSQL.

I have not started to port this to drupal 7. Should similar problems arise in drupal 7, I will start porting it.

I never realized that there were so many users that were having similar problems. I would be interested in feedback to know if it would be more beneficial to create an actual "official" contributed module where others can assist me in contributing to and maintaining it.

I will continue to monitor this thread. When I can determine exactly what is causing these other errors, I will incorporate them into the module. Likewise, if I'm able to offer a resolution to a post here, I will post a reply.

I apologize for not being able to address the specific needs of everyone at this time. Like many others, my time and resources are limited.

V/R

Avaya

eyenology’s picture

Thanks for your help on this. I am unable to post the contents of my tables, but I will say that I did find some of the threads here helpful. I had about 20 users that I deleted during setup of my site that were for testing accounts. I used Devel module to create a a number of users. I then used phpMyAdmin to change UID #'s to fill in blanks. I did not replace every UID that was previously deleted. I have no more errors. While I do not know where the error came from, it was definitely a missing UID that caused the error.

I was among the number that this test did not find any errors.

Danny Englander’s picture

The module worked for me to determine the ID of the user in question as relating to the error. It turns out that the user was no longer in the database so my guess is that he might have been manually deleted instead of being deleted in Drupal but I can't be sure of that.

My error was:

node_revisions.nid(78) & node_revisions.vid(85) uses node_revisions.uid(11), but users.uid(11) does NOT EXIST.
(similar ones repeated 16 times all pointing to the same user ID

Should a new user be created a somehow try to assign that missing id to the user or would it be better to try to delete the node revisions or better yet assign a different user to those revisions?

UPDATE:
I was able to resolve this error found with the module using this query in PHPmyadmin:
update `node_revisions` set uid = 1 where uid = 11
You may need to substitute the user id in question. Basically the query changes the user id to 1 from the missing id of 11

jvieille’s picture

I have an error Invalid argument supplied for foreach() in /...taxonomy.module on line 1245

but this module reports nothing.

JV

allentseng’s picture

in additional to update node_revisions, there also need to run update `node` set uid = 1 where uid = 11 .
or the search index cron will not complete.

syaman’s picture

Thanks highrockmedia and allentseng - your solutions solved the problem for me! :)

uuno’s picture

It helped me

NROTC_Webmaster’s picture

Avaya,

Awesome module. I was however wondering if there was a way to add the variable table to check and see if the data stored in it was able to be serialized. I tried modifying what you have but I'm still fairly new to php and I can't quite seem to get it to work.
Also cafuego wrote a module for v7 http://drupal.org/project/variablecheck but even after going through his I just dont know what I'm doing wrong.

I'm running v6.20

Thanks in advance,

Avaya’s picture

...and see if the data stored in it was able to be serialized.

You mean just make sure each row's value column in the variable table is serialized?

NROTC_Webmaster’s picture

I get the following
Notice: unserialize() [function.unserialize]: Error at offset 42 of 374 bytes in unserialize() (line 637 of /public_html/includes/menu.inc).

I think it is in the variable table but I have manually checked the table and looked through it and cannot find the problem within the table. I think your module would help me identify the issue in the table.

Its weird because I don't have any variables that are 374 bytes in length in that table.

Avaya’s picture

When do you get that error, or where do you see it?

NROTC_Webmaster’s picture

I get the error whenever I view an admin page and it just shows up in the error log. I think it has something to do with my menu but I have a workaround for the menu because I was not able to alter the basic navigation menu.

cafuego added support to v6 for his Variable Check module which was able to fix my issue.

Thank you for you support.

jmwhitco’s picture

I ran the module and it did not give any error results. The problem I was having where I got this error, is when I search for the name of a user that should display with profile module, I get the error, and the entry where that user should come up, just had

"...
Anonymous - Comment"

If I tried to browse to the user's page profile page, I just got a 404 error.

I noticed in the node table that these users had a uid of 0. I changed on of these to 1 and the page worked. These particular users don't actually have login accounts, and are just listed as adjunct professors on my site, so I have been simply removing the user form the authoring information on the profile page (since an actual user can only have one profile).

so, what I noticed, is when I set the uid to 1, then went to the edit page for that user profile, it had my ID in the Author info. I removed that (setting the field to blank) and saved. Checked that user node in the DB again and it had a uid of 72. I used an update query to change all the uid =0 nodes (which corresponded to the profile pages that were having an issue. and now they all work. And the index that would only go to 95% complete, now goes to 100%.

Hope this helps.

Avaya’s picture

I'm working on an update that will check a few different things (including this). My time has been tight; classes just started back up.

Stephen Winters’s picture

Hi,
Thanks for the code. I installed your module and ran the report and received the following report. I don't yet know how to fix the errors. Hope someone can help me with that. If not I'll be studying it out myself as I have time.
(The top two "user warning" listings were errors from Drupal)

Node Debug Information Report

* user warning: Table 'winterss_solived.image' doesn't exist query: SELECT i.image_size, f.filepath FROM image i INNER JOIN files f ON i.fid = f.fid WHERE i.nid = 86 in /home/winterss/public_html/live-anew-com/so/sites/all/modules/image/image.module on line 468.
* user warning: Table 'winterss_solived.image' doesn't exist query: SELECT i.image_size, f.filepath FROM image i INNER JOIN files f ON i.fid = f.fid WHERE i.nid = 87 in /home/winterss/public_html/live-anew-com/so/sites/all/modules/image/image.module on line 468.

The following is a report that queries various tables: node, node_revisions, term_data, term_node, users and vocabulary. This report does not offer "solutions"; it just provides results that you need to interpret. Most of these can be resolved by modifying rows within specific tables. This report does not tell you which rows within the tables to modify.

Missing Vocabulary

The following is a list of term_data.vid that are NOT in the vocabulary.vid. If a new vocabulary.vid is created all will be well.

this term_data.vid/vocabulary.vid 154 IS NOT in vocabulary

this term_data.vid/vocabulary.vid 154 IS NOT in vocabulary

this term_data.vid/vocabulary.vid 154 IS NOT in vocabulary

node.nid(218) CANNOT be found in node_revisions.nid

The node_revisions table lacks the row being called from node.nid(218) with it's matching node.vid. There is also not a node_revisions.vid(327) in node_revisions. One solution to resolve this is to insert a row into node_revisions where:

node_revisions.nid = 218
node_revisions.vid = 327
node_revisions.uid = 1
node_revisions.title = bibl exp
node_revisions.body = This is a recovery for lost content.
node_revisions.teaser = This is a recovery for lost content.

node.nid(233) CANNOT be found in node_revisions.nid

The node_revisions table lacks the row being called from node.nid(233) with it's matching node.vid. There is also not a node_revisions.vid(343) in node_revisions. One solution to resolve this is to insert a row into node_revisions where:

node_revisions.nid = 233
node_revisions.vid = 343
node_revisions.uid = 1
node_revisions.title = Leaders in Religion
node_revisions.body = This is a recovery for lost content.
node_revisions.teaser = This is a recovery for lost content.

Ayesh’s picture

marko42’s picture

Subscribing

mkogel’s picture

I am glad that experts find this module very useful. What about the newbies like me...

I have copied and pasted the code in to the correct files using the wordpad (I am not a developer so I have no cool tools to use for coding).
I have put the module in the modules directory.

That's it. I do not see the module among the modules from the admin view. I understand that cron must be run to generate reports. I use poormanscron. I look at the Report folder I do not see any there either.

How on eath am I supposed to use this - please give me "special_report module use for dummies" version. Many thanks in advance.

Btw, my problem shows on line 1242 - does this module resolve that, too?

I am not a developer so I need idiots guide sometimes

mkogel’s picture

I am glad that experts find this module very useful. What about the newbies like me...

I have copied and pasted the code in to the correct files using the wordpad (I am not a developer so I have no cool tools to use for coding).
I have put the module in the modules directory.

That's it. I do not see the module among the modules from the admin view. I understand that cron must be run to generate reports. I use poormanscron. I look at the Report folder I do not see any there either.

How on earth am I supposed to use this - please give me "special_report module use for dummies" version. Many thanks in advance.

Btw, my problem shows on line 1242 - does this module resolve that, too?

I am not a developer so I need idiots guide sometimes

David-F’s picture

I didn't know where to find it either, but it is rather obvious once you know.

If you have the "administration menu" module installed, it's under the reports tab. Otherwise, look in "dashboard" under the "reports" heading.

NROTC_Webmaster’s picture

Not sure if you figured it out yet or not, but enable the module as normal under the site building/modules section. Under the same section at the top of the page you can run update.php and then it should show up in the reports section under your admin menu if you have them organized by task.

What is the error you are getting on line 1242?

Let me know if you need more clarification.

mkogel’s picture

Module is not showing under the module list so cannot enable it. I ran the update.php nothing changed.

Under the reports section, the only place I can see the error is Log Entry.

Message shows - Invalid argument supplied for foreach() in /../modules/taxonomy/taxonomy.module on line 1242.

Location: /poormanscron/run-cron-check
Referrer: a content page - there is a series of independent pages under one primary link and randomly one of those pages is referred as Referrer.

I don't see any other report.

What does this mean? Perhaps I have no problems like mentioned above but always three messages at each cron run is visible to the anonymous users.

I am not a developer so I need idiots guide sometimes

mkogel’s picture

Ok, this newbie resolved the issue.

My issue was: warning: Invalid argument supplied for foreach() in ........ modules/taxonomy/taxonomy.module on line 1242

The Module did not show up under the modules. I am pretty sure it was due to copying and pasting the code from the screen.

DANNY, thank you for emailing me the module. That worked. I enabled the module and the report showed up under the reports section.

Looks like I had only missing nid problem in the node_revisions table. However, I did not insert lines into the node_revisions table as suggested. When I checked the "node" table I saw entries for two content page duplicated and one deleted content page. Obviously the deleted and duplicated pages did not have the corresponding entries in the node_revisions table. After deleting those three (redundant) entries from the "node" table, the special_reports did not show any other issue.

I am not a developer so I need idiots guide sometimes

Danny Englander’s picture

@mkogel -- great, glad what I sent you worked!

royerd’s picture

I know you figured it out, but also others make sure you are logged in as user number 1 so you have correct permissions.

plognark’s picture

This module helped me find and resolve one stupid missing row in node_revisions. Awesome!

Avaya’s picture

I'm glad some people have found it helpful.

I have a newer version I was trying to submit as an actual Drupal module. I have not had time to finish making the changes they requested.

royerd’s picture

Thanks so much for this module. I don't know how I would ever have found these database errors. I had looked in all the usual places, but your module reported exactly what I needed. It still shows this error

The following is a list of term_data.vid that are NOT in the vocabulary.vid. If a new vocabulary.vid is created all will be well.

this term_data.vid/vocabulary.vid 6 IS NOT in vocabulary

this term_data.vid/vocabulary.vid 6 IS NOT in vocabulary

But the 1241 error is gone in my logs, so I don't know if I need to investigate and fix this vid error or not. And I'm not quite sure how to fix it if I need to. The main point is that when I run cron, the 1241 error no longer appears. I had three missing rows from the revision table.

krisjahn’s picture

I had the same problem someday after using cron job.
The solution for me took a long time but it was very simple!
I had a nice try & error with my database.
Finally I found out, that there was only one node, that confused the search index routine while doing the cron job.

I found a node in my db (node table) that had an uid of 0 (zero).
Never know how it came there in, but erased it and build a new search index via cron.

No more error messages. huh!

Fertig! Done!

vonn.new’s picture

Thanks very much.
This module helped me find a problem I had been searching for.
One issue that others may run into:
As soon as I resolved the foreach() error in taxonomy by inserting a new row into node_revisions as recommended by this module, I got an even uglier error from xmlsitemap. Researching that, I found that it was known and updating to beta2 fixed it.

The moral of the story is don't panic, plan to update xmlsitemap if you aren't on the most recent version.

Vonn

jvieille’s picture

This module did not help for me, it was missing at least a particular situation which is well described here
http://drupal.org/node/839654#comment-4330760
and there
http://stream.zerolab.org/post/2419224606/invalid-argument-supplied-for-...

JV

CLKeenan’s picture

When I try to load the report, my server times out. Is that a representation of how bad of shape my database is?

mattcasey’s picture

No, try changing your server's memory limit to at least 100MB or as high as your host allows if you're on shared hosting. There's lots of tutorials how to do this. You can see what your current limit is by visiting yoursite.com/admin/reports/status

Also try flushing the cache first, this helps reduce the database size. To flush the cache, go to yoursite.com/admin/settings/performance

nzcodarnoc’s picture

Posting this as it might save someone some time.

My problem was that I had four or five nodes whose authors had been deleted.

I used the following query to look up the nids of the nodes:

select * from node as n1 
where n1.uid not in 
(select n.uid from node as n 
 join users as u on n.uid = u.uid
);

Once I checked that they weren't "mission critical" I deleted them, and my problem was solved.

ggevalt’s picture

Hi,

We persist with this error (1241) and have tried Avaya's module.
It took a while but realized that the node debug report can only be viewed if you are user 1
Report cannot be viewed -- it results in a WSOD time out.
We have memory boosted.
We have 300+ posts that had a uid 0, but created a user account as uid 0 but that didn't help. We think these were orphaned when we deleted some accounts a while ago.
Cron has failed for several weeks now. And it gives the 1241 error.
What adds to our bafflement is that cron worked fine up to a few weeks ago. No major changes to the site since then.

So questions are these:

  • Why are we getting the WSOD? And what can we do about it?
  • Any thought as to why we have so many nodes with uid 0 after account deletions?
  • Should we just bite the bullet and ascribe these nodes to uid1? Or should we just delete the nodes?

very frustrating. And we suspect it is at the root of some hangups our site has been experiencing.
thanks in advance,
geoff

soundboy89’s picture

Thanks a lot for this, I ran it and solved a few node_revisions issues. I stopped getting the infamous 1241 taxonomy error, but I still can't get my cron to execute :( I thought I'd seen the light but no dice. Thanks anyway!

NROTC_Webmaster’s picture

I just updated the the uid on all of mine to 1 and it solved the problem without the loss of content.

sridharpandu’s picture

I had a customer complaining that the SEARCH on the site was not functioning. So every time we attempted to reindex the site we noticed a funny behaviour, initially at every cron run the percentage of the site indexed would gradually increase and at a particular point it would start reducing gradually. I always thought that the SEARCH index was corrupt and would flush the SEARCH tables from the mysql command prompt.

But today when I checked watchdog I noticed this error and it misled me into thinking that it was some taxonomy term misbehaving, but then I had only one taxonomy term that was created by the simplenews module for identifying the newsletter. I checked all content types but couldn't home in on the problem. I went back to the SEARCH seeting screen (remember that I flushed the SEARCH tables) and to my surprise found that there were abou 22000+ items to reindex, on a site with about 1500+ users and very little content I had a doubt on the how the number of nodes increased to 22000+. So googling drupal with the "Invalid argument...taxonomy" string I landed on this post. So I quickly installed the special reports module and it threw a few misisng references in node_revisions. So I did a quick SELECT and then DELETE on all node_revision records with uid=0 then ran the special reports again now it pointed to the node table with uid=0 and missing node revisions. So did a quick SELECT and found content of the type MEMBER (this content type doesn't even exist) . So DELETED all of these misbehaving nodes. That left me with about 1600+ nodes. And I ran cron and search sailed through beautifully. Thank you.

Acer Aspire 5745
[i5 430M, 3GB, 320GB]
Ubuntu 12.04 (Precise Pangolin)
Drupal 6.15, 7.x
DigitalOcean, Go Daddy, Rackspace,