• Resolved kalligator

    (@kalligator)


    I get an activation problem on my live server running PHP Version 5.6.26.
    The table does not get created.

    WordPress database error Invalid default value for 'created' for query CREATE TABLE wp_lightbox_photoswipe_img (
    	  imgkey char(64) DEFAULT '' NOT NULL,
    	  created datetime DEFAULT NOW(),
    	  width mediumint(7),
    	  height mediumint(7),
    	  PRIMARY KEY  (imgkey),
    	  INDEX (created)
    	) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci made by activate_plugin, do_action('activate_lightbox-photoswipe/lightbox-photoswipe.php'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, lightbox_photoswipe_activate, lightbox_photoswipe_create_tables, dbDelta

    Even if I create it manually in PHPMyadmin when it comes to setting the default value for created to CURRENT_TIMESTAMP I get an error

    #1067 – Invalid default value for ‘created’

    If I don’t set a defalut value it doesn’t work either.

    On my local xampp with PHP Version 7.0.8 the plugin runs fine.

    • This topic was modified 7 years, 4 months ago by kalligator.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Arno Welzel

    (@awelzel)

    That’s indeed unexpected. I just pushed a new version which does not need default values for the “created” column.

    Plugin Author Arno Welzel

    (@awelzel)

    Well I forgot, that WordPress seems not to run the activation hook for the plugin when just updating – so another update will follow soon. But a complete fresh installation should work.

    Plugin Author Arno Welzel

    (@awelzel)

    I changed the database handling completely, so it should work now. Sorry for the trouble.

    Thread Starter kalligator

    (@kalligator)

    Thanks so getting back with the fixes.
    There was still a problem with the table creation.

    WordPress database error Incorrect index name '' for query ALTER TABLE wp_lightbox_photoswipe_img ADD KEY '' ('created') from require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('plugins_loaded'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, lightbox_photoswipe_init, lightbox_photoswipe_create_tables, dbDelta

    I turned lines 167 & 168 to:

    	  PRIMARY KEY imgkey (imgkey),
    	  INDEX created (created)

    which stopped the errors.

    However it was still not working. And as I found out, the culprit is that I am using a cdn for images, particularly jetpack’s photon!
    On sites on the same server that I don’t use photon the plugin works great.

    • This reply was modified 7 years, 4 months ago by kalligator.
    • This reply was modified 7 years, 4 months ago by kalligator.
    • This reply was modified 7 years, 4 months ago by kalligator.
    Plugin Author Arno Welzel

    (@awelzel)

    I finally sorted the problems out.

    The problem is, that it MySQL and MariaDB don’t require a name for index columns (also see https://dev.mysql.com/doc/refman/5.7/en/create-table.html) but dbDelta() expects secondary index colums to be named when you call it with existing tables during an update. So the first activation works, but the update doesn’t.

    The other problem is, that WordPress will not call the activation hook when updating an plugin in the backend – so I changed the complete database handling in that way that the table is created or updated (if required) during plugin initialisiation.

    I also integrated the supposed workaround for images served by Jetpack Photon.

    Thread Starter kalligator

    (@kalligator)

    Thanks, everything is ok!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Table not created’ is closed to new replies.