i added the post to twitter field to a node type and when i select it when create a new node i get this error:

Recoverable fatal error: Argument 1 passed to Entity::__construct() must be an array, boolean given, called in /home/admin/public_html/calpoly/sites/all/modules/twitter/twitter.module on line 457 and defined in Entity->__construct() (line 40 of /home/admin/public_html/calpoly/sites/all/modules/entity/includes/entity.inc).

CommentFileSizeAuthor
#15 twitter-error.patch1.55 KBSamLerner
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Issue summary: View changes

..

DamienMcKenna’s picture

Version: 7.x-6.0-alpha2 » 7.x-6.x-dev
waverate’s picture

Using 7.x-6.x-dev.

This error still exists. Any updates?

DamienMcKenna’s picture

Status: Active » Postponed (maintainer needs more info)

Can you please use the Devel module to identify what function called TwitterStatus::__construct()? To do so, enable the Devel module, go to the admin/config/development/devel settings page, change the error handler option to "Krumo backtrace in the message area" and see what is shown when the error is triggered again. Thanks.

DamienMcKenna’s picture

PS, if you can help me identify the cause of this I'll be happy to fix the bug, but I need a little more detail before I can fix it. Thanks.

DamienMcKenna’s picture

Priority: Critical » Normal
Hamulus’s picture

Got the same error

DamienMcKenna’s picture

@Hamulus: What version of the module are you using? Can you please post the exact error message as the line numbers have moved around since the issue was originally reported. Thanks.

cthshabel’s picture

Still getting this error with the latest dev version: 7.x-6.2+1-dev

Exact error message: Recoverable fatal error: Argument 1 passed to Entity::__construct() must be of the type array, boolean given, called in /var/www/html/example/sites/all/modules/contrib/twitter/twitter.module on line 679 and defined in Entity->__construct() (line 41 of /var/www/html/example/sites/all/modules/contrib/entity/includes/entity.inc).

Enabling krumo backtrace just shows that it was successful: Successfully posted to Twitter: https://twitter.com/example/status/654377250083741696

Not sure what is happening, but it does successfully post to twitter. Something on line 679 doesn't play nice?

parent::__construct($values, 'twitter_status');

kjl’s picture

$values = $this->call('statuses/update', $params, 'POST');

$values can be empty if the status update sent to twitter is identical to a previous status update.

This causes an exception when the boolean is passed to

return new TwitterStatus($values);

resulting in "recoverable fatal error: Argument 1 passed to Entity::__construct() must be of the type array, boolean given"

DamienMcKenna’s picture

Title: post to twitter causes fatal error » Post to Twitter causes fatal error if the message is a duplicate
Status: Postponed (maintainer needs more info) » Active

@kjl: Good catch. And yes, the API was updated at some point to detect duplicate messages. This needs fixing.

Rob T’s picture

I am running into this issue as error as well...

Recoverable fatal error: Argument 1 passed to Entity::__construct() must be of the type array, boolean given, called in .../sites/all/modules/twitter/twitter.module on line 679 and defined in Entity->__construct() (line 41 of .../sites/all/modules/entity/includes/entity.inc).

Rob T’s picture

This issue continues to bug my site.

Some Twitter posts process as expected, while others fail with this error. In my case the posts I aim to Tweet via Rules are never duplicates. Yet some go through, and some fail. Hence, I don't think the title of this issue is correct - "... if the message is a duplicate" - at least not for me.

One observation that may be the distinguishing factor in determining whether the content posts to Twitter (or fails) could be the length of the title. However, I am unqualified to make that determination, so it's really just a shot in the dark.

In my dblog report there are 2 errors reported side-by-side: (1) twitter error: "exception 'TwitterException'...", and (2) a php error "Recoverable fatal error". Here they are...

twitter

exception 'TwitterException' with message 'Forbidden' in /home/... /sites/all/modules/twitter/twitter.lib.php:159

Stack trace:
#0 /home/... /sites/all/modules/twitter/twitter.lib.php(119): Twitter->request('https://api.twi...', Array, 'POST')
#1 /home/... /sites/all/modules/twitter/twitter.lib.php(1273): Twitter->auth_request('https://api.twi...', Array, 'POST')
#2 /home/... /sites/all/modules/twitter/twitter.lib.php(407): Twitter->call('statuses/update', Array, 'POST')
#3 /home/... /sites/all/modules/twitter/twitter.inc(198): Twitter->statuses_update('Story Headline...')
#4 /home/... /sites/all/modules/twitter/twitter_actions/twitter_actions.module(277): twitter_set_status(Object(TwitterAccount), 'Story Headline...')
#5 /home/... /sites/all/modules/twitter/twitter_actions/twitter_actions.rules.inc(67): twitter_actions_tweet(Object(TwitterAccount), 'Story Headline...')
#6 [internal function]: twitter_actions_set_status('Story Headline...', 'MyTwitterUserName', Array, Object(RulesState), Object(RulesAction), 'execute')
#7 /home/... /sites/all/modules/rules/includes/faces.inc(123): call_user_func_array('twitter_actions...', Array)
#8 /home/... /sites/all/modules/rules/includes/rules.core.inc(362): FacesExtendable->__call('execute', Array)
#9 /home/... /sites/all/modules/rules/includes/rules.plugins.inc(20): RulesExtendable->__call('execute', Array)
#10 /home/... /sites/all/modules/rules/includes/rules.core.inc(1660): RulesAction->executeCallback(Array, Object(RulesState))
......

php

Recoverable fatal error: Argument 1 passed to Entity::__construct() must be of the type array, boolean given, called in /home/... /sites/all/modules/twitter/twitter.module on line 679 and defined in Entity->__construct() (line 41 of /home/... /sites/all/modules/entity/includes/entity.inc).

Could this be caused by a title that has too many characters (versus the initial suspicion of attempting to post duplicate messages)?

Rob T’s picture

Title: Post to Twitter causes fatal error if the message is a duplicate » Post to Twitter cause fatal error if the message is a duplicate or if message is too long

After observing a handful more Twitter posts fail with this error, I have become more convinced it is the result of a title that has too many characters (of which my Twitter post is set to "[node:title] [node:url:shorten] #SampleHashtag").

Between the messages that get Tweeted without issue, and the messages that fail with this error, the distinguishing factor looks to be the length of the message, or in my case [node:title].

I am changing the title of the issue. I'll still retain "if message is a duplicate" since that was an initial observation or assumption, but in my case there are no attempts to post duplicate messages.

SamLerner’s picture

FileSize
1.55 KB

This patch will keep the error from displaying and interrupting the post. However, the tweet will still not be sent, and no response is sent back to the user. So it's not an ideal situation if you want to inform users that they'll need to modify their tweet before submitting.

nickonom’s picture

Hitting the same wall here...

ianm’s picture

I suddenly starting getting the same error yesterday. I had published some tens of nodes each creating a tweet, when I started getting an error and the tweets were no longer posted although the node was published. I wondered whether I had triggered some Twitter limit so waited 24 hours before trying again, but still getting the error.

As people above, there are two errors in the log; one for twitter and one for php. These are:

exception 'TwitterException' with message 'Forbidden' in ../sites/all/modules/twitter/twitter.lib.php:159 Stack trace: #0 ../sites/all/modules/twitter/twitter.lib.php(119): Twitter->request('https://api.twi...', Array, 'POST') #1 ../sites/all/modules/twitter/twitter.lib.php(1273): Twitter->auth_request('https://api.twi...', Array, 'POST') #2 ../sites/all/modules/twitter/twitter.lib.php(407): Twitter->call('statuses/update', Array, 'POST') #3 ../sites/all/modules/twitter/twitter.inc(198): Twitter->statuses_update('New product: AT...') #4 ../sites/all/modules/twitter/twitter_post/twitter_post.module(64): twitter_set_status(Object(TwitterAccount), 'New product: AT...') #5 ../sites/all/modules/twitter/twitter_post/twitter_post.module(82): twitter_post_entity_insert(Object(stdClass), 'node') #6 [internal function]: twitter_post_entity_update(Object(stdClass), 'node') #7 ../includes/module.inc(965): call_user_func_array('twitter_post_en...', Array) #8 ../modules/node/node.module(1181): module_invoke_all('entity_update', Object(stdClass), 'node') #9 ../modules/node/node.pages.inc(459): node_save(Object(stdClass)) #10 ../includes/form.inc(1524): node_form_submit(Array, Array) #11 ../includes/form.inc(906): form_execute_handlers('submit', Array, Array) #12 ../includes/form.inc(386): drupal_process_form('products_node_f...', Array, Array) #13 ../includes/form.inc(131): drupal_build_form('products_node_f...', Array) #14 ../modules/node/node.pages.inc(14): drupal_get_form('products_node_f...', Object(stdClass)) #15 [internal function]: node_page_edit(Object(stdClass)) #16 ../includes/menu.inc(527): call_user_func_array('node_page_edit', Array) #17 ../index.php(21): menu_execute_active_handler() #18 {main}

Recoverable fatal error: Argument 1 passed to Entity::__construct() must be of the type array, boolean given, called in ../sites/all/modules/twitter/twitter.module on line 679 and defined in Entity->__construct() (line 201 of ../sites/all/modules/entity/includes/entity.inc).

This effects at least two different content types.

As I mentioned, this happened in the middle of publishing nodes, I had made no changes to the configuration before the errors started.

Happy to provide further information or test if it helps.