MG 2.2 Database Errors with Media Gallery

KensonPlays

Well-known member
I'm trying to add some images to a gallery category to add to a blog post I'm writing, but I keep getting a few errors relating to the database. Unsure how to fix?

XF\Db\DuplicateKeyException: MySQL query error [1062]: Duplicate entry '19f4ab7f75a3825913b255ec01b15b48' for key 'xf_mg_media_item.media_hash'
src/XF/Db/AbstractStatement.php:230
Stack Trace:
Code:
INSERT  INTO `xf_mg_media_item` (`media_hash`, `media_type`, `user_id`, `username`, `category_id`, `media_state`, `title`, `media_date`, `exif_data`, `rating_weighted`, `rating_avg`, `media_id`, `description`, `last_edit_date`, `album_id`, `ip_id`, `view_count`, `watermarked`, `custom_fields`, `warning_id`, `warning_message`, `position`, `imported`, `thumbnail_date`, `custom_thumbnail_date`, `poster_date`, `tags`, `last_comment_date`, `last_comment_id`, `last_comment_user_id`, `last_comment_username`, `rating_count`, `rating_sum`, `reaction_score`, `reactions`, `reaction_users`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
------------

#0 src/XF/Db/Mysqli/Statement.php(198): XF\Db\AbstractStatement->getException('MySQL query err...', 1062, '23000')
#1 src/XF/Db/Mysqli/Statement.php(79): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1062, '23000')
#2 src/XF/Db/AbstractAdapter.php(96): XF\Db\Mysqli\Statement->execute()
#3 src/XF/Db/AbstractAdapter.php(220): XF\Db\AbstractAdapter->query('INSERT  INTO `x...', Array)
#4 src/XF/Mvc/Entity/Entity.php(1521): XF\Db\AbstractAdapter->insert('xf_mg_media_ite...', Array, false)
#5 src/XF/Mvc/Entity/Entity.php(1253): XF\Mvc\Entity\Entity->_saveToSource()
#6 src/addons/XFMG/Service/Media/Creator.php(258): XF\Mvc\Entity\Entity->save()
#7 src/XF/Service/ValidateAndSavableTrait.php(42): XFMG\Service\Media\Creator->_save()
#8 src/addons/XFMG/Pub/Controller/Media.php(884): XFMG\Service\Media\Creator->save()
#9 src/XF/Mvc/Dispatcher.php(352): XFMG\Pub\Controller\Media->actionSaveMedia(Object(XF\Mvc\ParameterBag))
#10 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XFMG:Media', 'SaveMedia', Object(XF\Mvc\RouteMatch), Object(XFMG\Pub\Controller\Media), NULL)
#11 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XFMG\Pub\Controller\Media), NULL)
#12 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#13 src/XF/App.php(2483): XF\Mvc\Dispatcher->run()
#14 src/XF.php(524): XF\App->run()
#15 index.php(20): XF::runApp('XF\\Pub\\App')
#16 {main}

Request State:
Code:
array(4) {
  ["url"] => string(17) "/media/save-media"
  ["referrer"] => string(68) "https://mesozoichaven.com/media/categories/dino-game-pics-vids.2/add"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(9) {
    ["_xfToken"] => string(8) "********"
    ["attachment_hash"] => string(32) "d6a6b04cb9ec6bb11baf1b2cd78fd79f"
    ["attachment_hash_combined"] => string(91) "{"type":"xfmg_media","context":{"category_id":2},"hash":"d6a6b04cb9ec6bb11baf1b2cd78fd79f"}"
    ["media"] => array(10) {
      [2] => array(7) {
        ["title"] => string(28) "TallNeck - Horizon Zero Dawn"
        ["description"] => string(0) ""
        ["tags"] => string(42) "Horizon Zero Dawn, HZD, Tallneck, Sauropod"
        ["temp_media_id"] => string(1) "2"
        ["media_hash"] => string(32) "19f4ab7f75a3825913b255ec01b15b48"
        ["media_type"] => string(5) "image"
        ["attachment_id"] => string(3) "115"
      }
      [3] => array(7) {
        ["title"] => string(28) "Sawtooth - Horizon Zero Dawn"
        ["description"] => string(0) ""
        ["tags"] => string(32) "Horizon Zero Dawn, HZD, Sawtooth"
        ["temp_media_id"] => string(1) "3"
        ["media_hash"] => string(32) "970d7747b1393caf76c518e6a26a75ff"
        ["media_type"] => string(5) "image"
        ["attachment_id"] => string(3) "116"
      }
      [4] => array(7) {
        ["title"] => string(8) "Scorcher"
        ["description"] => string(0) ""
        ["tags"] => string(32) "Horizon Zero Dawn, HZD, Scorcher"
        ["temp_media_id"] => string(1) "4"
        ["media_hash"] => string(32) "bbcc6de39a8ac1ddae1fde544d6f0fbd"
        ["media_type"] => string(5) "image"
        ["attachment_id"] => string(3) "117"
      }
      [5] => array(7) {
        ["title"] => string(7) "Watcher"
        ["description"] => string(0) ""
        ["tags"] => string(31) "Horizon Zero Dawn, HZD, Watcher"
        ["temp_media_id"] => string(1) "5"
        ["media_hash"] => string(32) "3647f2efb33a6267c99d3ce1c5527731"
        ["media_type"] => string(5) "image"
        ["attachment_id"] => string(3) "118"
      }
      [6] => array(7) {
        ["title"] => string(11) "ShellWalker"
        ["description"] => string(0) ""
        ["tags"] => string(35) "Horizon Zero Dawn, HZD, ShellWalker"
        ["temp_media_id"] => string(1) "6"
        ["media_hash"] => string(32) "26664824682f7bc7a3dc92bd89d832ab"
        ["media_type"] => string(5) "image"
        ["attachment_id"] => string(3) "119"
      }
      [7] => array(7) {
        ["title"] => string(9) "Corruptor"
        ["description"] => string(0) ""
        ["tags"] => string(33) "Horizon Zero Dawn, HZD, Corruptor"
        ["temp_media_id"] => string(1) "7"
        ["media_hash"] => string(32) "993fbd75810c5f45fb40295cf344387a"
        ["media_type"] => string(5) "image"
        ["attachment_id"] => string(3) "120"
      }
      [8] => array(7) {
        ["title"] => string(7) "Strider"
        ["description"] => string(0) ""
        ["tags"] => string(31) "Horizon Zero Dawn, HZD, Strider"
        ["temp_media_id"] => string(1) "8"
        ["media_hash"] => string(32) "55c35c3eff70662bff6b0f279cfe00b0"
        ["media_type"] => string(5) "image"
        ["attachment_id"] => string(3) "121"
      }
      [9] => array(7) {
        ["title"] => string(7) "Snapmaw"
        ["description"] => string(0) ""
        ["tags"] => string(44) "Horizon Zero Dawn, HZD, Snapmaw, Crocodilian"
        ["temp_media_id"] => string(1) "9"
        ["media_hash"] => string(32) "bce67d61d44bad8ec23ef4b93edcc62d"
        ["media_type"] => string(5) "image"
        ["attachment_id"] => string(3) "122"
      }
      [10] => array(7) {
        ["title"] => string(9) "Lancehorn"
        ["description"] => string(0) ""
        ["tags"] => string(33) "Horizon Zero Dawn, HZD, Lancehorn"
        ["temp_media_id"] => string(2) "10"
        ["media_hash"] => string(32) "064560a87b817eb5f717b9f6b985f4bf"
        ["media_type"] => string(5) "image"
        ["attachment_id"] => string(3) "123"
      }
      [11] => array(7) {
        ["title"] => string(6) "Grazer"
        ["description"] => string(0) ""
        ["tags"] => string(30) "Horizon Zero Dawn, HZD, Grazer"
        ["temp_media_id"] => string(2) "11"
        ["media_hash"] => string(32) "5148e00557c31965e196a73a0223433c"
        ["media_type"] => string(5) "image"
        ["attachment_id"] => string(3) "124"
      }
    }
    ["tokens_select"] => string(6) "Grazer"
    ["category_id"] => string(1) "2"
    ["_xfRequestUri"] => string(43) "/media/categories/dino-game-pics-vids.2/add"
    ["_xfWithData"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"
  }
}

That's not the only error. There's another:
XF\Db\Exception: MySQL query error [1364]: Field 'pth_is_loner' doesn't have a default value
src/XF/Db/AbstractStatement.php:230
Stack Trace
Code:
INSERT  INTO `xf_tag` (`tag`, `tag_url`, `tag_id`, `use_count`, `last_use_date`, `permanent`) VALUES (?, ?, ?, ?, ?, ?)
------------

#0 src/XF/Db/Mysqli/Statement.php(198): XF\Db\AbstractStatement->getException('MySQL query err...', 1364, 'HY000')
#1 src/XF/Db/Mysqli/Statement.php(79): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1364, 'HY000')
#2 src/XF/Db/AbstractAdapter.php(96): XF\Db\Mysqli\Statement->execute()
#3 src/XF/Db/AbstractAdapter.php(220): XF\Db\AbstractAdapter->query('INSERT  INTO `x...', Array)
#4 src/XF/Mvc/Entity/Entity.php(1521): XF\Db\AbstractAdapter->insert('xf_tag', Array, false)
#5 src/XF/Mvc/Entity/Entity.php(1253): XF\Mvc\Entity\Entity->_saveToSource()
#6 src/XF/Repository/Tag.php(146): XF\Mvc\Entity\Entity->save()
#7 src/XF/Service/Tag/Changer.php(314): XF\Repository\Tag->createTag('horizon zero da...')
#8 src/addons/XFMG/Service/Media/Creator.php(266): XF\Service\Tag\Changer->save(true)
#9 src/XF/Service/ValidateAndSavableTrait.php(42): XFMG\Service\Media\Creator->_save()
#10 src/addons/XFMG/Pub/Controller/Media.php(884): XFMG\Service\Media\Creator->save()
#11 src/XF/Mvc/Dispatcher.php(352): XFMG\Pub\Controller\Media->actionSaveMedia(Object(XF\Mvc\ParameterBag))
#12 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XFMG:Media', 'SaveMedia', Object(XF\Mvc\RouteMatch), Object(XFMG\Pub\Controller\Media), NULL)
#13 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XFMG\Pub\Controller\Media), NULL)
#14 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#15 src/XF/App.php(2483): XF\Mvc\Dispatcher->run()
#16 src/XF.php(524): XF\App->run()
#17 index.php(20): XF::runApp('XF\\Pub\\App')
#18 {main}

Request State
Code:
INSERT  INTO `xf_tag` (`tag`, `tag_url`, `tag_id`, `use_count`, `last_use_date`, `permanent`) VALUES (?, ?, ?, ?, ?, ?)
------------

#0 src/XF/Db/Mysqli/Statement.php(198): XF\Db\AbstractStatement->getException('MySQL query err...', 1364, 'HY000')
#1 src/XF/Db/Mysqli/Statement.php(79): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1364, 'HY000')
#2 src/XF/Db/AbstractAdapter.php(96): XF\Db\Mysqli\Statement->execute()
#3 src/XF/Db/AbstractAdapter.php(220): XF\Db\AbstractAdapter->query('INSERT  INTO `x...', Array)
#4 src/XF/Mvc/Entity/Entity.php(1521): XF\Db\AbstractAdapter->insert('xf_tag', Array, false)
#5 src/XF/Mvc/Entity/Entity.php(1253): XF\Mvc\Entity\Entity->_saveToSource()
#6 src/XF/Repository/Tag.php(146): XF\Mvc\Entity\Entity->save()
#7 src/XF/Service/Tag/Changer.php(314): XF\Repository\Tag->createTag('horizon zero da...')
#8 src/addons/XFMG/Service/Media/Creator.php(266): XF\Service\Tag\Changer->save(true)
#9 src/XF/Service/ValidateAndSavableTrait.php(42): XFMG\Service\Media\Creator->_save()
#10 src/addons/XFMG/Pub/Controller/Media.php(884): XFMG\Service\Media\Creator->save()
#11 src/XF/Mvc/Dispatcher.php(352): XFMG\Pub\Controller\Media->actionSaveMedia(Object(XF\Mvc\ParameterBag))
#12 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XFMG:Media', 'SaveMedia', Object(XF\Mvc\RouteMatch), Object(XFMG\Pub\Controller\Media), NULL)
#13 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XFMG\Pub\Controller\Media), NULL)
#14 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#15 src/XF/App.php(2483): XF\Mvc\Dispatcher->run()
#16 src/XF.php(524): XF\App->run()
#17 index.php(20): XF::runApp('XF\\Pub\\App')
#18 {main}
 
Solution
Had to do this like the third time so far: disable every single addon, install ONLY media gallery, rebuild, then install rest.

It seems that if I try adding a tag, it doesn't upload, but if I have zero tags, it uploads fine. 🤔

Edit: Even though it was DISABLED, not enabled; it was @mazzly's Thread Tagging Improvements addon that was causing this. Guess I'll report it to them in the thread where addon disabled it was still breaking tags.
Had to do this like the third time so far: disable every single addon, install ONLY media gallery, rebuild, then install rest.

It seems that if I try adding a tag, it doesn't upload, but if I have zero tags, it uploads fine. 🤔

Edit: Even though it was DISABLED, not enabled; it was @mazzly's Thread Tagging Improvements addon that was causing this. Guess I'll report it to them in the thread where addon disabled it was still breaking tags.
 
Last edited:
Solution
Back
Top Bottom