My site uses many views and cck field, and i18n

I've just upgrade from CCK 2-rc10 to CCK 2.0, and it works on my wamp, which has php 5.2.4. Both English and French works.

Then I uploaded to my CentOS 5 server, which has php 5.1.6. English is still fine, but the French site goes blank page, the error is:

PHP Fatal error: Cannot access empty property in sites/all/modules/cck/includes/views/handlers/content_handler_field.inc on line 162,

After some investigation I find that sometimes $this->aliases[$attributes['column']] was empty and that makes $values->{$this->aliases[$attributes['column']]} having PHP fatal error, in PHP 5.1.6.

I've try to debug this and find $this->aliases[$attributes['column']] has a value in many cases, but when it's empty the blank page error occurs. Maybe it's just a single improperly written cck module, but the whole site is down.

I'm not sure if it is a i18n problem or cck problem, but I write a workaround patch. As attached.

Comments

yched’s picture

Hm - hard for me to tell if this belongs to i18n, Views or CCK.

- Could you export your view and attach it as a text file ?
- also please temporarily add the following lines before the foreach :

if (user_access('administer site configuration')) {
  drupal_set_message(print_r($this->aliases, TRUE));
  drupal_set_message(print_r($values, TRUE));
}

Then visit both your english and french page logged in as user 1 and report the messages you get (regular users won't be affected)

Earl, if you're reading this and have suggestions ?

yched’s picture

edit : make that

if (user_access('administer site configuration')) {
  drupal_set_message(print_r($this->aliases, TRUE));
  drupal_set_message(print_r($this->additional_fields, TRUE));
  drupal_set_message(print_r($values, TRUE));
}

Thx :-)

yched’s picture

Status: Needs review » Postponed (maintainer needs more info)
corneverbruggen’s picture

subscribing

jaredonline’s picture

Fatal error: Cannot access empty property in /var/www/vhosts/drupal6.bookmanstestbed.com/sites/all/modules/cck/includes/views/handlers/content_handler_field.inc on line 162

I'm getting the same issue and rolled back to rc10.

Subscribing.

yched’s picture

@jaredonline: This doesn't help. As you see in the original post, yang_yi_cn is seeing this in a rather specific case, and he provides detailed information about it.
If you're seing this as well, you need to provide the maximum details as well, so that we can try to spot a pattern.
Besides, I asked for additional information in comments #3 / #4, why not try providing those ?

Just saying 'me too' is meaningless. You need to help us help you, folks.

corneverbruggen’s picture

StatusFileSize
new7.26 KB

I have this problem (that is: the same error message) when using a multilingual taxonomy term as an argument in a view. This was not the case in the last rc.
The view has two arguments. The first is the language (nl, en or de), the second is a taxonomy term. When using this argument in combination with the 'en' or 'de' language, the error occurres. Default language of the site is 'nl'.

Attached an export of the view.

The error also happens when running cron when the search module is enabled, so something goes wrong when indexing content.

yched’s picture

StatusFileSize
new5.56 KB

OK, for all people seeing this - we need the following informations to be able to move on :
- Provide an export of the view that raises the error (thks farbridges)
- Specify whether or not you use i18n module
- Rename the attached file below to 'content_handler_field.inc' and use it to replace the one in the cck/includes/views/handlers/ folder.
Then display your view, and please report the messages that are displayed (be sure to be logged in as user 1, regular users won't see them).

Thanks, we won't be able to fix properly this without your help.

eagereyes’s picture

StatusFileSize
new2.5 KB

I'm getting the same message, but under different conditions: my view shows a list of nodes that are referenced through a CCK nodereference field that I added to the Story type. When the current page has related pages, it works. When it doesn't, I get the error message. I also get the error on pages that are not Story nodes (like Biblio, etc.). I'm not using i18n.

The exported view is attached.

When using yched's content-hander-field.inc on a node without a related field, the problem simply shifts: Cannot access empty property in [...]/sites/all/modules/views/modules/node/views_handler_field_node.inc on line 45

When viewing my frontpage, I get this:
Array ( [vid] => node_vid [type] => node_type )
Array ( [vid] => Array ( [table] => node [field] => vid ) [type] => Array ( [table] => node [field] => type ) )
stdClass Object ( [nid] => 237 [node_vid] => 237 [node_type] => biblio [type] => biblio [build_mode] => 0 )

I can't make it show me the debug information on any other page - I've turned off my block cache and cleared the caches, but I don't see it on any other pages. Any idea how I can get it to show up again?

tech4him’s picture

StatusFileSize
new3.11 KB
new5.67 KB

Another report of the same error. Not multilingual in my case. Attached I believe is what you are requesting, the view debug output as well as the view definition. Hope that helps. Thanks for the great work!

No I do not use the i18n module.

tech4him’s picture

StatusFileSize
new1.73 KB

Hmmm...updated my View definition and simplified by removing the three fields that were taxonomies and voila, the view is now working with the regular content_handler_field.inc file. Attached is the working view def.

corneverbruggen’s picture

StatusFileSize
new4.26 KB
new7.23 KB

I am using i18n.
I also have a nodereference field in the view. When I remove it, the error disappears. And - as said - the error only happens when using the taxonomy argument in the view.

Attached the required files. I attached the views export again as well.

Yched, when using the content_handler_field.inc_.debug, the error disappears! (without removing the nodereference field or taxonomy term argument). I guess, this debug code has already some sort of patches in it?

Thanks for all your work.

spopovits’s picture

StatusFileSize
new7.62 KB

This is my view that does not work with same error. Not using i18n, not using multilanguage.
I have two similar views one works one doesnt. The one that doesnt has empty file_field the one that works has values.
I hope this gives you more information.
I get the same error PHP Fatal error: Cannot access empty property in sites/all/modules/cck/includes/views/handlers/content_handler_field.inc on line 162
my site is http://www.screenprocess.com

spopovits’s picture

I removed the FileField from the view and the view works. It appears that as long as there were some values in the FileField the view works if not the fatal error occurs.

yched’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new1.04 KB

OK, I tried with the example provided by eagereyes in #9 (simplest one), couldn't reproduce at first, and after a little head-scratching, managed to figure it out.
Happens with empty multiple fields, when there is no 'NULL' row for the node in the field's table. content_handler_field_multiple::render() needlessly deferred to content_handler_field::render(), which doesn't find the values it expects.

Fixed this in latest -dev.
Before closing this and rolling a new release, I'd appreciate if the various reporters above confirmed that it does fix their own case.
Attached is the patch I committed, so that people can test without waiting for the -dev tarball to be refreshed.

Obviously, this should be tested with the original content_handler_field.inc file, NOT the debug one I provided in #8 :-)

yang_yi_cn’s picture

#15 fixed the issue for me.

eagereyes’s picture

Works for me too, thanks for the quick fix!

spopovits’s picture

I do not know how to do the patches do I assume that the - in the patch is remove the line and + is to add the line.
I am willing to manually change the code in the file to test if you could just clarify the fix for me.

yched’s picture

@spopovits ; that's it.
The patch just replaces

if (!$this->defer_query || empty($this->field_values)) {

with

if (!$this->defer_query) {

in content_handler_field_multiple.inc

More generally, see http://drupal.org/patch/apply for more informations on how to apply patches.

garbanzito’s picture

just reporting that i too observed this same error message upon upgrading to 6.x-2.0; i have so many views it was hard to pin down, so i just applied the patch from #15 and it resolved the error on my site, and i could then see it was probably a view involving a nodereference field

corneverbruggen’s picture

The patch solved to problem for me. Perfect!
Thanks!

yched’s picture

Status: Needs review » Fixed

OK, I think we can consider this fixed :-)
Thanks all.

I just released CCK 2.1.

Status: Fixed » Closed (fixed)

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