array_shift error in ajax_comments.module line 118
drupalina - March 24, 2009 - 17:22
| Project: | AJAX Comments |
| Version: | 6.x-1.8 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | CanOne |
| Status: | needs work |
Description
I've installed AJAX_comment 1.7 on my dev site today. At the beggining all seems to work fine.
Then problems kicked in:
When I try to reply to a comments it it opens the ajax form ok, but when I click the "Save" button the form throws a popup warning with a message
"An error occured
/ajax_comments/js "
In my log I can see the following errors:
array_shift() [function.array-shift]: The argument should be an array in /home/hostaccountname/public_html/my_dev_site/sites/all/modules/ajax_comments/ajax_comments.module on line 109.

#1
sorry, that error message didn't post correctly. I forgot the < code > tags.
It should read
array_shift() [<a href='function.array-shift'>function.array-shift</a>]: The argument should be an array in /home/my_host_account/public_html/my_dev_site/sites/all/modules/ajax_comments/ajax_comments.module on line 109.Plus: it also happens with the latest .dev version and also 1.6
#2
Yes, I found this bug yesterday too. I'm working on resolving this issue. Thanks for your report.
#3
Noticed it as well, only since the latest dev. It's somewhere in the latest js file.
#4
This happens for me as well but seems to only be happening on the translated version of the page. Posting on the original English version of the node worked.
#5
subscribing
#6
Subscribing.. Was working fine yesterday, not today
#7
Not sure if something changed but this article was just recently updated... http://drupal.org/node/331941
#8
Периодически выскакивают ошибки.
Такая:
* warning: array_shift() [function.array-shift]: The argument should be an array in /home/quqiru/data/www/kprazdnikam.ru/sites/all/modules/ajax_comments/ajax_comments.module on line 109.* warning: Invalid argument supplied for foreach() in /home/quqiru/data/www/kprazdnikam.ru/sites/all/modules/cck/content.module on line 1278.
И такая:
warning: array_shift() [function.array-shift]: The argument should be an array in /home/quqiru/data/www/kprazdnikam.ru/sites/all/modules/ajax_comments/ajax_comments.module on line 109.#9
warning: array_shift() [function.array-shift]: The argument should be an array in /www/sites/all/modules/ajax_comments/ajax_comments.module on line 118.This bug happens after I try to post two comments in a row... the first comment gets posted, the second outputs this error
using latest development version
#10
Updating the title to be more clear where the error is.
#11
Если при добавлении нажимать "Предпросмотр" ошибка такая
warning: Invalid argument supplied for foreach() in Z:\home\about\www\sites\all\modules\cck\content.module on line 1278.У меня из кода темы верезан участок, который выводит заголовок комента. В настройках темы заголовок отключен.
Может в этом проблема?!
зы: модули стоят такие: ajax_comments, auto_nodetitle, bookmarks, bueditor, cck, dhtml_menu, filefield, imageapi, imagecache, imagefield, pathauto, privatemsg, token, user_karma, views, vote_up_down, votingapi.
(самые последние версии;)
ззы: надеюсь помог, а не рассмешил
#12
a.mohax: English, please.
#13
Translation using Google:
If you are adding to click "Preview" error, such
warning: Invalid argument supplied for foreach() in Z:\home\about\www\sites\all\modules\cck\content.module on line 1278.
I have a poster of the code verezan plot, which displays the title комента. In the settings of the topic title is off.
Can this problem?
threat: modules are as follows: ajax_comments, auto_nodetitle, bookmarks, bueditor, cck, dhtml_menu, filefield, imageapi, imagecache, imagefield, pathauto, privatemsg, token, user_karma, views, vote_up_down, votingapi.
(latest version;)
zzy: hope to help and not laugh
#14
subscribing
When I try to post a comment, I see this error:
warning: array_shift() [function.array-shift]: The argument should be an array in /www/sites/all/modules/ajax_comments/ajax_comments.module on line 118.When I try to make a preview of a comment, I see this error:
warning: array_shift() [function.array-shift]: The argument should be an array in /www/sites/all/modules/ajax_comments/ajax_comments.module on line 118.warning: Invalid argument supplied for foreach() in /www/sites/all/modules/cck/content.module on line 1278.
Any suggestion?
#15
I'm also getting the same thing as the op. However it doesn't look like all the posts in this issue are about the same issue?
#16
#17
@Flying: I think there are multiple issues that boil down to a simple fact that ajax_comments needs to be updated to work cleanly with the proper APIs, and that should take care of most of these issues, and from there we could see what was left.
#18
Thanks, well explained.
#19
Same issue.
Subscribing.
#20
I have the same issue also, with both the 1.7 and dev release
subscribing
#21
Sorry, guys, I was too far from my work place this month to fix this stuff. Anyway, I finally did it. You may find a fix in dev. version (for 21-Apr). I'll fix some other issues in the queue and than make a release. Please, test dev and tell me your results.
Thank you very much for pattience and sorry for inconvenience.
#22
Only the dev version from Mar 25 is on http://drupal.org/project/ajax_comments right now.
#23
You need to wait for the package to be built in a few hours, or you can grab it from cvs.
Thanks neochief!
#24
I just had the same problem, updated to today's dev version and now works like a charm. Thanks a lot, that's really a useful module, especially for the use inside forums :)
#25
Automatically closed -- issue fixed for 2 weeks with no activity.
#26
same issues.
first time preview -> OK
second time preview -> array_shift error
#27
What version do you use?
#28
thanks your reply.
re-test it, it cause by called drupal_rebuild_theme_registry(). i del it and works.
but another bug found.
it not work with comments_form_alter()
for example,
$form['preview'] = array('#type' => 'button', '#value' => t('GO'), '#weight' => 20);
if I change the #value, it will be error
maybe cause by ajax_comments.module
if ($form_state['values']['op'] == t('Preview')) {
(not the Ajax comments issue)
#29
still getting this error with dev version from 2009-Apr-22
#30
subscribing
#31
also having this error with dev version from 2009-Apr-22. First comment works fine then I get
warning: array_shift() [function.array-shift]: The argument should be an array in C:\xampp\htdocs\test\sites\all\modules\contrib\ajax_comments\ajax_comments.module on line 118.#32
subscribing
#33
im uninstalling this til a solution is made. No one can comment on my forums.
#34
Suppose problem caused by caching...
This patch solves this problem.
#35
changing status
#36
Patch don't work for me.
#37
patch didn't work. and this was on a test site that has no caching enabled.
#38
patch made against -dev version
and it does not depends on site caching at all - form should be cached to use ahah
For example http://api.drupal.org/api/function/poll_form/6
#39
I installed the patch from #34 over the dev version from May-21 (newest) and getting the same error, now on line 119 (because of the line added by the path).
Thank you andypost for your work. Great module.
#40
Эта проблема была решена?
This problem has been solved?
#41
I am having this issue after upgrading to Drupal 6.13
#42
i get the same error with 1.7 version
#43
Hey guys, I came to fix this finally. If you want this problem to be resolved, please provide me with the installation (files + database dump) on which it can be reproduced, as it can't be reproduced on vanilla installation. You can send me download links via my contact form.
PS. Of course, I respect your privacy.
#44
#45
Installing a dev version completely solved the problem.
Thanks for a nice module a lot.
#46
I see this error when module memcache enabled. If I turn off memcache module, error gone away.
#47
have the same issue
warning: array_shift() [function.array-shift]: The argument should be an array in /home/gamebus5/public_html/sites/all/modules/ajax_comments/ajax_comments.module on line 109.subscribe
#48
Using last dev version still doesn't work if Authcache is enabled.
#49
I think Authcache has a list of what should not be cached. You should try to get it added there.
#50
I get this warning when I try to reply to a comment:
warning: array_shift() [function.array-shift]: The argument should be an array in /var/www/drupal/sites/all/modules/ajax_comments/ajax_comments.module on line 109.When I am just replying to the node itself ajax_comments works fine.
/** AHAH callback
*/
Line 103: function ajax_comments_js() {
Line 104: $form_state = array('storage' => NULL, 'submitted' => FALSE);
Line 105: $form_build_id = $_POST['form_build_id'];
Line 106: $form = form_get_cache($form_build_id, $form_state);
Line 107:
Line 108: $args = $form['#parameters'];
Line 109: $form_id = array_shift($args);
#51
If I show comments like this:
print $content;
Ajax comments works perfect. But if I show them this way:
print $node->body;
if(arg(0) == 'node' && is_numeric(arg(1))&& !arg(2)) {
$t_node = node_load(arg(1));
if (function_exists('comment_render') && $t_node->comment) {
print comment_render($t_node);
}
}
Then I get this awful error:
warning: array_shift() [function.array-shift]: The argument should be an array in C:\xampp\htdocs\intereconomia\sites\default\modules\ajax_comments\ajax_comments.module on line 120
This is with the dev version. With the standard version, y was getting the same error on other line number. How could I fix my problem? I need to show comments and comment form separated from the node content.
Thanks.
#52
same problem, it's effectively a cache problem because i use authcache to increase the speed of authenticated users on my site.
when i switch off authcache module, ajax comment works
I will try some paths in the settings of authcache module to desactivate cache for ajax comment
hum
I have try a lot of path :
ajax_comments/*
ajax_comments
*/ajax_comments/*
ajax_comments/instant_delete/*
ajax_comments/js
ajax_comments/js*
ajax_comments/js_reload/*
to exclude from cached page for authcache
always :
warning: array_shift(): The argument should be an array in /www/htdocs/production/sites/all/modules/ajax_comments/ajax_comments.module on line 120.have you an idea of another path to exclude ?
#53
Subscribing, same issue. But I don't have authcache installed
#54
Subscribing. I have authcache installed and eAccelerator on Drupal 6.13.
If I turn off the cache everything works just fine.
It's a real shame because the commenting is so nice when it works, hopefully someone is going to find out how to fix this.
#55
In my case it's happenning only when after deleting comment tries add a new one without refreshing page first.
#56
After install the 6.x-1.x-dev. Its fine..
But after I install http://drupal.org/project/comment_form_above_comments
The problem "array_shift() [function.array-shift]:" It's show again...
How to fix this..?
Thanks
#57
Maybe this will help: This module was working fine. We had a user request come in to change the "save" button name. Using form_alter, I changed the "Save" button to "Post" (
$form['submit']['#value'] = "Post";) and started seeing this exact popup error ("An error occured .. /ajax_comments/js"). I changed my "Post" button back to the original "Save" and the error went away.I know the error for this thread stated they were using the original "Save" button label so it won't solve it, but it might help others. Not sure how this submit value might affect the code, but it removed the error for me.
#58
Ive been looking at the code and it seems when you click on save on an internal comment the $form variable on line 106 doesn't get filled. If you just post your comment in the standard comment form this variable does get filled on line 106.
Anyway that's why it can't do the array shift, because there is nothing in the $form['#parameter'] variable to shift as the $form variable itself is empty.
#59
Been looking more at it and went into the form_get_cache function which in turn calls the get_cache function. On line 26 of cache.inc there following code is run
$cache = db_fetch_object(db_query("SELECT data, created, headers, expire, serialized FROM {". $table ."} WHERE cid = '%s'", $cid));The $cache variable created here differs depending on if I am submitting with the standard comment form (which works) or if I am submitting with an internal comment form (which doesn't work and gives the array_shift error)
It's too big to print as when I submit the standard comment form the $cache['data'] variable is about 2300 characters long. However when I submit an internal comment form the $cache['data'] variable is about 170000 characters long. So something has to be going wrong here. I have no experience with drupal's cache handling so there isn't really anymore I can do. Maybe someone with more knowledge of this area could have a look at it.
#60
Also running Drupal 6.13 on a clean install, no memcache and sill getting the error. It pops up for me after I delete a comment and try to post another.
#61
Hooray, I was able to reproduce it with cache minimal lifetime set.
#62
Okay, released a new version. To upgrade:
1. Remove old module's instance completelly from your modules folder.
2. Download 1.8 version and place it in modules.
3. Flush drupal caches.
4. Go to your nodes and try ajax comments.
If error persists, give me your drupal version, cache settings and is the any cache module are enabled at your site.
#63
Nice work mate, what was causing the error in the end, was it due to other modules interfering with cache?
#64
Updated to 1.8 and added comment and when tried delete it (w/out page refreshing), got error "Sorry, token error."
#65
-Shaman-, Flush caches, reload the page. Error should gone. I bet you had outdated page.
#66
I truncated cache tables at phpmyadmin, which always does the job, then reloaded page.
#67
hi
the preview function works fine
but i cant save the comment
nothing happens if i click the button for saving!?
that problem also with newest dev version..
#68
Ajax comments is fixed!!! Very nice work neochief, this is one of my favorite drupal modules, great to see it working again!!
#69
For those using third-party caching systems such as Memcache, CacheRouter, Authcache, etc, this patch may help:
http://drupal.org/node/395394#comment-1987804
#70
Hi,
I have Drupal 6.10 and it's not a fresh install it's an upgraded one. I have tried both versions dev as well as stable. But the problem still persists.
It results in following:
I have no cache enabled. Can you address this ?
#71
Hi,I have the same promblem with 6.x-1.8 2009-Aug-26 ,can somebody help ?
#72
After experimenting with this I found that cache must be completely disabled at /admin/settings/performance otherwise the error will persist.
#73
the cache are all disabled,and the module still can not work ...May be it's the time to disable this module until the problem be sloved......
#74
the cache are all disabled,and the module still can not work ...May be it's the time to disable this module until the problem be sloved......
#75
Yes you should disable it for your site, if you're not able to describe step-by-step reproducing routine.
#76
Greate module, but the same problems on submitting, replying, editing comments (however comments deleting workgin fine) :(
Here is the outline of conditions:
drupal 6.14, cck, views, disabled all caches, no installed any caches modules (except blockcache module), threaded comments view, bueditor, voting_api+voting up_down modules enabled for comments, button_style module enabled (it makes styled the forms buttons), flag module enabled (for node bookmarking feature).
#77
Same problem(s) with 6.x-1.8, no cache modules installed.
In Firefox 3.5.5 for Mac, I submit a comment, the 'progress bar' goes eternally and the comments don't update. Reload page and comment is posted. This happens in my custom theme, in Garland, with Dev module turned off. With all caching enabled or disabled.
In Safari 4.0.3, with normal caching on and block cache enabled, I get the:
warning: array_shift() [function.array-shift]: The argument should be an array in /blahblahblah/sites/all/modules/ajax_comments/ajax_comments.module on line 119I disable the cache, reload the node that has the comment form on it - notice my previous comment DID make it to DB and is on the page, and try posting a comment again.
I get a js alert box:
an error occurred
/ajax_comments/js
I hit the OK button and the 'progress bar' runs eternally.
THEN, I turn off a custom module we have running that replaces form buttons with images. Much like 'button_style'.
Suddenly, it works! (though it's putting new comments at the bottom of my date desc comment display instead of at the top, but that's a different issue.)
I turn all my caching back on, and it still works!!!
So, the issue seems to have as much to do with the replacing of buttons as with anything.
@godewebog - try disabling button_style and see if the comments posting works.
#78
Chris, you're Awesome! It's certainly can be root of evil. Could you please attach here part of your module which prevents ajax comments from working?
#79
Thanks, Alexandr. Your friendly words prove you're not my ex-wife!
The custom module (imgbutton) is just a form_alter hook function. Here are the parts that pertain to the comments form:
function imgbutton_form_alter(&$form, $form_state, $form_id) {
$img_path = path_to_theme().'/images/';
// Comment edit forms
if ($form_id == 'comment_form') {
unset($form['preview']);
unset($form['submit']['#value']);
$form['submit']['#type'] = 'image_button';
$form['submit']['#title'] = t('Save');
$form['submit']['#src'] = $img_path . 'save.gif';
$form['submit']['#name'] = 'gopreview';
$form['submit']['#attributes'] = array('class' => 'commsubmit');
}
}
Which results in the Save button being replaced with an image and the Preview button disappearing. I wonder if the problem is from unsetting submit #value.
Anyway, I hope this helps!
#80
This error does not fixed.
After submit error:
warning: array_shift() [function.array-shift]: The argument should be an array in /host/htdocs/modules/ajax_comments/ajax_comments.module on line 119.And after preview error:
warning: array_shift() [function.array-shift]: The argument should be an array in /host/htdocs/modules/ajax_comments/ajax_comments.module on line 119.warning: Invalid argument supplied for foreach() in /host/htdocs/modules/cck/content.module on line 1284.
I used last version FCKeditor and memcahed.
#81
@chilic: If you turn off the FCKEditor for your comment form, just use plain textarea, do you still get the error? Are you replacing any of the form's buttons with images?
I'm not using a cache module, nor am I using a WYSIWYG implementation for my textarea. I got the same error. For me, the difference was that I have image buttons instead of standard buttons on my form. Putting them back to standard, the error goes away and the comment posts onscreen.
#82
@ccshannon: I turn off the FCKEditor for comment form, use standart resizable textarea. And no image button. =(
#83
I disable memcahed and module is work! But how to use them together?
#84
@chilic - I don't have much experience with memcached, but possibly cache_exclude.module could help...