After I installed i18 on my fresh D6.2 I got white page with no data and then I restart the site and I got this error

warning: Invalid argument supplied for foreach() in xxxxxxxxxx/sites/all/modules/i18n/i18ntaxonomy/i18ntaxonomy.module on line
578.

Shall I just remove the module, to fix the problem?

CommentFileSizeAuthor
#9 i18ntaxonomy_viewspreview.patch1.32 KBbforchhammer

Comments

ali_b’s picture

I have the same problem. Everything working great, i have this message after adding a view.

Wutimer’s picture

Same here, things work well other than that error message.

Wutimer’s picture

Well, there's a quick hack to get rid of the error message; though it does involve editing the core of i18ntaxonomy.module:

Wrap the funciton in [ if (is_array($view->field)) { ]

Line 575:

function i18ntaxonomy_views_pre_view(&$view, &$items) {
  //var_dump($view);
  $translate = variable_get('i18ntaxonomy_vocabularies', array());
  
  if (is_array($view->field)) {
      foreach($view->field as $index => $data) {
        $matches = array();
        if($data['id'] == 'term_node.name') {
          // That's a full taxonomy box
          $view->field[$index]['handler'] = 'i18ntaxonomy_views_handler_field_allterms';
        } elseif(preg_match("/term_node_(\d+)\.name/", $data['id'], $matches)) {
          $vid = $matches[1];
          if ($translate[$vid]) { 
            // Set new handler for this field
            $view->field[$index]['handler'] = 'i18ntaxonomy_views_handler_field_allterms';
          }
        }
      } 
  }


}
droshani’s picture

This is too technical, how should I be able to implement your suggestion?

Wutimer’s picture

Honestly, it's not very graceful; I would say ignore my suggestion and do one of the following:

  1. Wait for the next release of the module and install (likely to be resolved)
  2. Or, under "Error Reporting" turn of "show messages to screen" and select "log only" (it'll remove the error message from being displayed to visitors)
Alice Heaton’s picture

@Wutime : I had the same error - and did a similar patch. I don't think your version isn't gracefull -- that's exactly what needs to be done. As far as I can see, the code that generates the error translates the field titles when called from a view ; and doesn't work when your view doesn't have fields. This needs to be tested for, which is what you are doing.

@all : I would suggest changing the title of this issue to "Error when displaying view without field titles" or something ? What do people think ?

@koyauni : Don't fear, it's not that technical. If it's not urgent, wait for an update but if you really need this fixed, do the following :

1. Do this on your TEST site, not on a live site.
2. Go in your drupal directory.
3. Navigate to modules/i18n/i18ntaxonomy
4. Edit the file i18ntaxonomy.module
5. In that file, go to line 572 ; which should be the following :

function i18ntaxonomy_views_pre_view(&$view, &$items) {

6. Just BELOW that line, add the following lines :

if (!isset($view->field)) {
return;
}

7. That's it. This is a similar patch to Wutime's - it's just slightly easier for you to see what needs to be changed !

droshani’s picture

Title: error message line 578 » Error when displaying view without field titles

I am fine with it if you wan to chnage the name of this post so it will attract more respond from developer.

Than you for your easy steps I will do this see what will happen.

Wutimer’s picture

@Anselm Heaton : A nice touch in your changes and easier to follow; thanks for following up!

bforchhammer’s picture

Version: 6.x-1.0-beta1 » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new1.32 KB

I had the same error, thanks!

Attached is the respective patch file, patched against current 6.x-1.x-dev-version (25/06/2008).

metabits’s picture

I am having a similar problem. Each time I am updating a node, I am getting this warning:

warning: Invalid argument supplied for foreach() in xxx/sites/all/modules/i18n/i18ntaxonomy/i18ntaxonomy.module on line 554.
warning: Invalid argument supplied for foreach() in xxx/sites/all/modules/i18n/i18nsync/i18nsync.module on line 192.

Any idea where is this coming from? I am not using views and my site works fine, so I think I will wait for an update of the i18n module, but it will be good to know why. Anyway, I thought it could interest to those that care for the module.

jose reyero’s picture

Status: Needs review » Fixed

Moved it to a different module (so you can enable/disable it), and added some aditional check so this error won't happen anymore.

I don't think any of these patches really works though. Views-taxonomy translation needs to be reimplemented.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.