- Content Construction Kit (CCK) 5.x-1.7
- ImageField 5.x-2.1
- Token 5.x-1.11
- Automatic Nodetitles 5.x-1.1
- imagefield config:
- Enable custom title text
- Multiple values

I have installed the modules above and the following setting:
- imagefield
- auto node activated with token
- few text fields
- tmp permission 775
- downloaded method public

I noticed the following.

- If I upload an image with auto title active I get the error below.
- If I upload an image with auto title no active I don't get any error
- If I create the node with all the fields but no image I don't get any error.

To note the error is only after i click submit.
If I return to the node everything is fine.

I think this is a bug

    * warning: Invalid argument supplied for foreach() in /home/cargen/public_html/drupal/vio3/modules/node/node.module on line 561.
    * warning: implode() [function.implode]: Invalid arguments passed in /home/cargen/public_html/drupal/vio3/modules/node/node.module on line 565.
    * user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM node n INNER JOIN users u ON u.uid = n.uid INNER JOIN node_revisions r ON r.vid = n.vid WHERE in /home/cargen/public_html/drupal/vio3/includes/database.mysql.inc on line 172.
    * warning: Invalid argument supplied for foreach() in /home/cargen/public_html/drupal/vio3/modules/node/node.module on line 561.
    * warning: implode() [function.implode]: Invalid arguments passed in /home/cargen/public_html/drupal/vio3/modules/node/node.module on line 565.
    * user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM node n INNER JOIN users u ON u.uid = n.uid INNER JOIN node_revisions r ON r.vid = n.vid WHERE in /home/cargen/public_html/drupal/vio3/includes/database.mysql.inc on line 172.

Comments

Vuds’s picture

I've got that too. The error doesn't appear at upload for me, but when trying to save the node. It doesn't save any information in the node, it's created empty. If I go inside and edit the created node, it saves normally.

For me, disable Automatic Nodetitles doesn't make any difference. And it was working right before, maybe it's linked to the fact of the new version (5.8) of Drupal.

The warnings for me:

* warning: Invalid argument supplied for foreach() in /var/www/html/modules/node/node.module on line 561.
* warning: implode() [function.implode]: Bad arguments. in /var/www/html/modules/node/node.module on line 565.
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM node n INNER JOIN users u ON u.uid = n.uid INNER JOIN node_revisions r ON r.vid = n.vid WHERE in /var/www/html/includes/database.mysql.inc on line 172.

Vuds’s picture

i have just tested with my old backups and now I can confirm that is not related with the 5.8 Drupal version.

Created another node with just the field (beyond title and body) and apparently it worked.

I will test more tomorrow.

Vuds’s picture

@carlogen: Are you using Lightbox2 too?

carlogen’s picture

Project: ImageField » Lightbox2
Version: 5.x-2.1 » 5.x-2.8

Yes,

I am using lightbox2.
I did furthers test and I think this is some problem in Token module and Lightbox2

I did the following test.
Same content type ad same fields, only difference in my display fields I changed the previous setting in the full side:
It was a Lightbox setting
I changed in a normal image show.

I did not get any error message after I created the node.

I am going to move bug log to Lightbox.

stella’s picture

Status: Active » Postponed (maintainer needs more info)

I don't see how this is a lightbox2 bug. The lightbox2 module does not run any mysql queries nor does it try to rewrite them. Can you provide more information on why you think it may be a lightbox2 bug?

Cheers,
Stella

Vuds’s picture

Well, I can't say that is exactly a Lightbox2 error. But it's related to.

It happens when we configure the display of a full CCK node to use Lightbox2 in any situation (original to scaled, scaled to original, scaled to scaled and so on). The teaser setting doesn't affects it.

With this display setting, I go to create a node of this type, upload a image normally, put data in others fields normally, and when I go trying to submit it, it appears all the warnings as above showing the node created empty (I think that Carlogen may have 2 imagefields, since he receives it doubled). None of the information is saved. If I go there after that and edit this node, then it works normal.

If I change the full node display setting for another than Lightbox2 (original, or any image of Imagecache, with or without links to node or image), the node creation returns to work normally.

Vuds’s picture

Status: Postponed (maintainer needs more info) » Active
stella’s picture

Status: Active » Postponed (maintainer needs more info)

What version of imagecache are you using? If you select an imagecache formatter (that's isn't a lightbox2 one), do you receive the errors?

Can you provide information on your cck node settings so I can try to reproduce the issue? You may need to provide your imagefield and imagecache settings too.

Cheers,
Stella

carlogen’s picture

Hi Stella,

Please find below my content type setting

$content[type]  = array (
  'name' => 'Annuncio',
  'type' => 'annuncio',
  'description' => '',
  'title_label' => 'Title',
  'body_label' => '',
  'min_word_count' => '0',
  'help' => '',
  'node_options' => 
  array (
    'status' => true,
    'promote' => true,
    'sticky' => false,
    'revision' => false,
  ),
  'comment' => '2',
  'upload' => '1',
  'scheduler' => 1,
  'scheduler_touch' => 1,
  'old_type' => 'annuncio',
  'orig_type' => '',
  'module' => 'node',
  'custom' => '1',
  'modified' => '1',
  'locked' => '0',
  'location_maxnum' => '0',
  'location_defaultnum' => '0',
  'location_weight' => '1',
  'location_collapsible' => 1,
  'location_collapsed' => 1,
  'location_rss' => 'w3c',
  'location_display_teaser' => 0,
  'location_display_full' => 0,
  'ant' => '1',
  'ant_pattern' => '[field_tipo_annuncio-term] - [field_nazione-term] - [field_prezzo-formatted]',
  'ant_php' => 1,
);
$content[fields]  = array (
  0 => 
  array (
    'widget_type' => 'image',
    'label' => 'Foto',
    'weight' => '9',
    'max_resolution' => 0,
    'max_filesize' => 0,
    'max_number_images' => '9',
    'image_path' => 'foto',
    'file_extensions' => 'jpg jpeg png gif',
    'custom_alt' => 0,
    'custom_title' => 1,
    'description' => '',
    'group' => false,
    'required' => '0',
    'multiple' => '1',
    'use_default_image' => 0,
    'default_image_upload' => '',
    'default_image' => NULL,
    'field_name' => 'field_foto',
    'field_type' => 'image',
    'module' => 'imagefield',
    'display_settings' => 
    array (
      'label' => 
      array (
        'format' => 'hidden',
      ),
      'teaser' => 
      array (
        'format' => 'thumbnail_linked',
      ),
      'full' => 
      array (
        'format' => 'lightbox2][thumbnail][normal',
      ),
    ),
  ),
);

for imagecache (version 5.x-2.1) I have two setting:

1) normal
Scale width: 500, height: , upscale: No
Crop width: 490, height: , xoffset: center, yoffset: center

2) thumbnail
Scale width: 100, height: 100, upscale: Yes

If in cck display fields I use a formatter different from Lightbox2, I don't get any error.

Thanks a lot for your help

Vuds’s picture

Hi Stella,

I had created two CCK types, one that's the normal for my system, and another just to test this. Both are very simple, they have just one imagefield (no multiple values) and a cck text field to put some commentary about the image. For my system it will have more things but I haven't added yet.

I'm using Imagecache 2.1 also, and have 5 presets configured, but sincerely for this case I'm using just two, more the original file format:

Preview (this one was to go inside the node):
Scale And Crop width: 160, height: 120

Full_Image (the one to show on Lightbox2):
Scale And Crop width: 800, height: 600

In Content Types, the CCK Node type, Display Settings for the image:
Label:
Teaser: Preview as link to node;
Full: Lightbox2: Preview->Full_Image

Other relevants versions: Drupal 5.8, Imagefield 2.1, ImageAPI 1.2, Lightbox2 2.8 (and also tried 2.x-dev), CCK 1.7.
I also use automatic nodetitles, token, etc. as Carlogen does, and many other more, but I think that it should be easy to reproduce the problem with only the above ones.

stella’s picture

I can't reproduce the issue. I've a Drupal 5.8 installation, with the following modules installed:

* Lightbox2 5.x-2.x-dev (latest)
* ImageAPI 1.2
* Imagecache 2.1
* CCK 5.x-1.x
* Imagefield 2.1
* Token 5.x-1.11
* Automatic Node Titles 5.x-1.1

I still don't think it's a lightbox2 issue because it doesn't do any mysql queries and you're seeing mysql errors. It may be a conflict between some of the other modules.

Cheers,
Stella

Vuds’s picture

Status: Postponed (maintainer needs more info) » Fixed

I got it, but it's a very very weird error.

After 2 hours spent playing with a backup version of development from my site system (which also presented the problem, but it has less modules), I found some real "misunderstanding" between Lightbox2 and Token (as Carlogen had said first).

When I disabled Tokens module, it started to create the nodes normally, without any error. Turned it on again, and errors returned also.

Using devel module, tried to reinstall Tokens. Nothing happened, errors yet.

Then I reinstall Lightbox2. And it started working!

So Stella, be aware that there is something about Lightbox2 installation that sometimes works (like you) and sometimes not (like me and Carlo). I had installed it just once, and just the 2.8 version (after that I tried dev, but it probably used the same configurations and made it presents the same errors at all).

@ Carlogen, install the devel module to reinstall Lightbox2 by using its tools, it worked for me and now it's perfect.

Thanks for attention and patience!

carlogen’s picture

Stella,

If you want I can send you by email my drupal folder and the database.
So you can see by yourself.

Let me know
Cheers
Carlo

stella’s picture

Project: Lightbox2 » Token
Version: 5.x-2.8 » 5.x-1.11
Status: Fixed » Active

I think this might be an error with the Token module then, because lightbox2 doesn't do any mysql queries. Re-assigning to the token module's issue queue.

Cheers,
Stella

drew reece’s picture

I also get this error, with Drupal 5.9 and everything up to date.

For me it happens when submitting a cck type with a link feild with the option to 'allow user submitted tokens' enabled for the field.

It could either be Token, link or auto node title module.

There seems to be a few posts related to this error…

http://drupal.org/node/142286
http://drupal.org/node/283805
http://drupal.org/node/285293

Drew

rokr’s picture

I think this is NOT a lightbox issue. May be an token issue or (what i think) an auto nodetitle issue. I filed this over there:
#294993: Imagefield Title -> Node Title = Errors in Log
Let me know if this sounds similar to your behaviour.

cheers, Ronald

rootwork’s picture

Priority: Normal » Critical

It's Token. I have it showing up on several nodes and I don't even have auto_nodetitle installed. When I turned off Token, the errors went away. I tried installing the dev version of Token in case it was patched at some point, but that didn't have any effect.

Per earlier discussions above and on the issues Drew linked to, I ruled out this being caused by link.module, imagecache or lightbox. It seems pretty clearly tied to Token.

I'm running D5.10

Vuds’s picture

Title: Error when image uploaded » Errors when using tokens with modules that are form/node generating content

I have tracked down a little bit more this error (since it had returned to me with no greater modifications in my system; also, I'm understanding a bit better Drupal's way of work).

For my case, I had discovered that Automatic Node Titles with Token (yes, it will be always one module + Token) is causing the problem. It's really a sequence problem. Basically, the line of Drupal's create content is:

- Suppose a new node is being created;
- Then the user submit this form;
- This form pass through validation functions and if it's all ok it pass to next step, or return to edit the form;
- This form pass through submit functions and only then it'll be transformed into a node (and that means, receive an nid);
- The user will be redicted to the node recently created.

Automatic Node Titles, for example, does its magic when *validating* the form (with formapi). So, if you are creating a node, you don't have a nid yet, but with Tokens activated, it will go behind the node tokens that are offered for the user (value from fields, the nid itself, etc.). Then, warnings of invalid foreach(), error on the MySQL syntax and so on.

Even if you are not using any token for evaluation (like me, who for diverse problems with Tokens had opted to use PHP evaluation in AutoNT), the code will evaluate for tokens because the architecture built in most part of modules says to use tokens transparently. For that occurs, it'll run the evaluation code always.

I temporarily solved my problem commenting the lines in AutoNT that tests conditions for Token functions and Module (like: if (module_exists ('token')) then blablabla), leaving the 'else' content uncommented, and, of course, not using any token in any circunstance inside a form/node content.

My vision to solve these problems:

The developers of modules that use Tokens for form/node content (AutoNT, imagefield, and more few ones) should pay attention about that sequence and try to evaluate your module needs only in the end of the process; or to try not to use node tokens.

While that, the Token developers should warn about this issue, and put some protection code to avoid load node tokens if the nid is not informed.

In some cases, I think that maybe a weight system module manipulation between the modules evolved can solve the problem, but it's really a "maybe", and it would happens in very rare circumstances.

rokr’s picture

Vuds, thanks for investigating that issue. That helps of course to understand what happens.
At one point i also only use php for a NAT. And i didn't understand the error messages kept going on.
At my site the error occurs with token+NAT and token+imagefield.
Have there been updates to token dev-version or any similar issues?

asak’s picture

I don't have NAT installed - but this getting these errors.

I'll look into this.

greggles’s picture

Status: Active » Postponed (maintainer needs more info)

put some protection code to avoid load node tokens if the nid is not informed

I'm not sure that is a valid analysis. The token module doesn't do node_load nor does it execute a query that looks like the original post nor the initial comments.

I think some module which provides tokens (maybe imagefield) needs to do its own protection.

dave reid’s picture

Maybe give #207768: Token malfunction with Auto NodeTitle and Imagefield-Node-Tokens a try. If it fixes this issue for you, please mark this issue as a duplicate.

dave reid’s picture

Status: Postponed (maintainer needs more info) » Fixed

Status: Fixed » Closed (fixed)

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