{"id":11069741,"date":"2019-01-09T16:54:12","date_gmt":"2019-01-09T16:54:12","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/bug-in-sql-query-when-creating-galleries\/"},"modified":"2019-01-09T19:12:39","modified_gmt":"2019-01-09T19:12:39","slug":"bug-in-sql-query-when-creating-galleries","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/bug-in-sql-query-when-creating-galleries\/","title":{"rendered":"Bug in SQL query when creating galleries"},"content":{"rendered":"<p>When I try to create a new gallery using nextgen, it is trying to add a new gallery to the database using a primary key of zero.<\/p>\n<p><code>[09-Jan-2019 16:48:04 UTC] WordPress database error Duplicate entry &#039;0&#039; for key &#039;PRIMARY&#039; for query INSERT INTO<\/code>wp_ngg_gallery<code>(<\/code>title<code>,<\/code>author<code>,<\/code>extras_post_id<code>,<\/code>gid<code>,<\/code>name<code>,<\/code>slug<code>,<\/code>path<code>,<\/code>pageid<code>,<\/code>previewpic<code>) VALUES (&#039;Test Gallery 3&#039;, &#039;1&#039;, &#039;61&#039;, &#039;0&#039;, &#039;test-gallery-3&#039;, &#039;Test-Gallery-3-1&#039;, &#039;\/wp-content\/gallery\/test-gallery-3-1\/&#039;, &#039;0&#039;, &#039;0&#039;) made by require(&#039;wp-blog-header.php&#039;), require_once(&#039;wp-load.php&#039;), require_once(&#039;wp-config.php&#039;), require_once(&#039;wp-settings.php&#039;), do_action(&#039;init&#039;), WP_Hook-&gt;do_action, WP_Hook-&gt;apply_filters, call_user_func_array, M_Ajax-&gt;serve_ajax_request, C_Ajax_Controller-&gt;index_action, ExtensibleObject-&gt;call_method, ExtensibleObject-&gt;__call, ExtensibleObject-&gt;_exec_cached_method, ReflectionMethod-&gt;invokeArgs, A_NextGen_AddGallery_Ajax-&gt;upload_image_action, C_DataMapper_Model-&gt;save, C_Gallery_Mapper-&gt;save, ExtensibleObject-&gt;__call, ExtensibleObject-&gt;_exec_cached_method, ReflectionMethod-&gt;invokeArgs, Mixin_DataMapper_Driver_Base-&gt;save, C_Gallery_Mapper-&gt;_save_entity, ExtensibleObject-&gt;__call, ExtensibleObject-&gt;_exec_cached_method, ReflectionMethod-&gt;invokeArgs, Mixin_Gallery_Mapper-&gt;_save_entity, Mixin-&gt;call_parent, ExtensibleObject-&gt;call_method, ExtensibleObject-&gt;__call, ExtensibleObject-&gt;_exec_cached_method, ReflectionMethod-&gt;invokeArgs, C_CustomTable_DataMapper_Driver_Mixin-&gt;_save_entity, C_Gallery_Mapper-&gt;_create, ExtensibleObject-&gt;__call, ExtensibleObject-&gt;_exec_cached_method, ReflectionMethod-&gt;invokeArgs, Mixin_NextGen_Table_Extras-&gt;_create, Mixin-&gt;call_parent, ExtensibleObject-&gt;call_method, ExtensibleObject-&gt;__call, ExtensibleObject-&gt;_exec_cached_method, ReflectionMethod-&gt;invokeArgs, C_CustomTable_DataMapper_Driver_Mixin-&gt;_create<\/code><\/p>\n<p>Brand new installation, running twenty16. From the debug log, it is explicitly trying to set gid to zero, which should not be happening. NULL would be fine, but zero is going to cause problems. I haven&#8217;t dug through the actual code in the plugin, but something isn&#8217;t right here.<\/p>\n","protected":false},"template":"","class_list":["post-11069741","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11069741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11069741\/revisions"}],"predecessor-version":[{"id":11070183,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11069741\/revisions\/11070183"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=11069741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}