Hi,

I'm getting an Integrity constraint violation in certain circumstances. To reproduce:

(1) brand new drupal 7 site with ajax_example and simplenews_content_selection (scs)
(2) log in as user 1
(3) create 40 articles
(4) go to admin/content/scs_node_selection
(5) click on the administration link in the error message
(6) check the articles checkbox
(7) go to admin/content/scs_node_selection
(8) select three random articles and give a title
(9) click sort nodes
(11) click create newsletter

Now I'm getting this error (see also image):

Error
Error message
Notice: Undefined property: stdClass::$ajax_example in ajax_example_node_insert() (line 114 of /path/to/drupal/sites/all/modules/contrib/examples/ajax_example/ajax_example_node_form_alter.inc).
Notice: Undefined property: stdClass::$ajax_example in ajax_example_node_insert() (line 115 of /path/to/drupal/sites/all/modules/contrib/examples/ajax_example/ajax_example_node_form_alter.inc).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'example_1' cannot be null: INSERT INTO {ajax_example_node_form_alter} (nid, example_1, example_2) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 43 [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => ) in ajax_example_node_insert() (line 117 of /path/to/drupal/sites/all/modules/contrib/examples/ajax_example/ajax_example_node_form_alter.inc).
The website encountered an unexpected error. Please try again later.

I'm aware that ajax_example is meant solely as a example, not a robust full-fledged module. Still, we might want to avoid such ugly errors.

Cheers,

Albert

Comments

SebCorbin’s picture

Status: Active » Fixed

The error is caused by the examples module, not Simplenews Content Selection. You'll get the same error if you try to create a node, even if SCS is disabled.

Just disable all your example modules.

alberto56’s picture

@SebCorbin thanks! Must have been tired yesterday, I did not notice the clear reference to the examples module.

Albert

alberto56’s picture

Project: Simplenews Content Selection » Examples for Developers
Component: Code » AJAX Example
Status: Fixed » Needs review
StatusFileSize
new937 bytes

Here is a patch for the examples module -- I'm just checking if the property exists before writing to the database. This is a more graceful way of dealing with it, perhaps.

alberto56’s picture

Title: Integrity constraint violation » site should not crash when $node->ajax_example is not set during ajax_example_node_insert()
mile23’s picture

Title: site should not crash when $node->ajax_example is not set during ajax_example_node_insert() » Site should not crash when $node->ajax_example is not set during ajax_example_node_insert()
Status: Needs review » Fixed

"Site should not crash when..."

Agreed. :-)

Committed: http://drupalcode.org/project/examples.git/commitdiff/0379bcd9722d5679a6...

dsteplight’s picture

I got this error by accidentally enabling the uuid_services_example and uuid_default_entities_example modules without realizing that he Examples module was already disabled. I found myself in a scenario where this error message was getting in the way of me trying enabling the Examples module via the Module Listing page. It was also preventing me from using drush to enable the Examples module. To solve the problem, I had to enable the Examples module via the command line in mysql. I was able to refresh the page and could visually verify the error message was no longer a problem.

You can check to see the state of your modules in mysql by running this command "SELECT name,status FROM system WHERE type='module';" . Make sure "xamples" is set to "1" using an UPDATE sql statement, and that should allow you to refresh your page and disable any example modules that you need via your site admin pages.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

issue has changed projects