Simple Machines Community Forum

SMF Support => SMF 2.1.x Support => Topic started by: mrnuke on March 05, 2023, 12:51:55 PM

Title: Error after upgrade : Wrong value type sent to the database. Array of integer...
Post by: mrnuke on March 05, 2023, 12:51:55 PM
Getting this error when trying to open and post/thread :

Wrong value type sent to the database. Array of integers expected. (preview_attachments)

I have just updated to 2.1.3 and everything seems ok, but when I enable attachments, I get the above error.
I disable attachments and the posts / threads work again.

This error occurs even with no mods at all.

I searched for it and found one topic which is unrelated to my issue.

Thank you.
Title: Re: Error after upgrade : Wrong value type sent to the database. Array of integer...
Post by: Sir Osis of Liver on March 05, 2023, 12:58:06 PM
Post the complete error.
Title: Re: Error after upgrade : Wrong value type sent to the database. Array of integer...
Post by: mrnuke on March 06, 2023, 03:34:42 AM
Quote from: mrnuke on March 05, 2023, 12:51:55 PMWrong value type sent to the database. Array of integers expected. (preview_attachments)

I did.. This..
Title: Re: Error after upgrade : Wrong value type sent to the database. Array of integer...
Post by: mrnuke on March 06, 2023, 03:39:04 AM
Here is the complete error from the log :

Quotedfbd6de84786367f553f9ebc8f393d6e
 http://guntalk.club/smf/index.php?topic=64467.0
 /home/guntalkc/public_html/smf/Sources/Subs-Attachments.php (Line 1402)  Backtrace information

Type of error: Critical
Error messageSelect
Wrong value type sent to the database. Array of integers expected. (preview_attachments)
Function: prepareAttachsByMsg
Title: Re: Error after upgrade : Wrong value type sent to the database. Array of integer...
Post by: Sir Osis of Liver on March 06, 2023, 11:55:49 AM
preview_attachments is not a core field in 2.1.  Which mods are installed?
Title: Re: Error after upgrade : Wrong value type sent to the database. Array of integer...
Post by: Doug Heffernan on March 06, 2023, 12:37:14 PM
Can you attach here the Subs-Attachments.php file? It can be found inside the /Sources/ folder.
Title: Re: Error after upgrade : Wrong value type sent to the database. Array of integer...
Post by: Arantor on March 06, 2023, 12:45:14 PM
Quote from: Sir Osis of Liver on March 06, 2023, 11:55:49 AMpreview_attachments is not a core field in 2.1.  Which mods are installed?


It's not a field but that's not what it's complaining about. The relevant function accepts an array of attachments to preview and the name of that array is preview_attachments, where it can be inserted safely into the relevant database query.
Title: Re: Error after upgrade : Wrong value type sent to the database. Array of integer...
Post by: Sir Osis of Liver on March 06, 2023, 07:39:50 PM
Hmm, this problem has been reported previously, but haven't found the solution.
Title: Re: Error after upgrade : Wrong value type sent to the database. Array of integer...
Post by: mrnuke on March 09, 2023, 11:56:11 PM
Quote from: Sir Osis of Liver on March 06, 2023, 11:55:49 AMpreview_attachments is not a core field in 2.1.  Which mods are installed?


I upgraded to 2.1.3 and had zero Mods installed after, so it must have come with 2.1.3 .
Title: Re: Error after upgrade : Wrong value type sent to the database. Array of integer...
Post by: mrnuke on March 09, 2023, 11:59:56 PM
I have since added some mods that don't affect anything negatively, but people are missing the attachments.  ;D 
Title: Re: Error after upgrade : Wrong value type sent to the database. Array of integer...
Post by: Sir Osis of Liver on March 10, 2023, 12:04:29 PM
Search comes up with these, neither has a solution.

https://www.simplemachines.org/community/index.php?topic=584588.msg4142143#msg4142143
https://www.simplemachines.org/community/index.php?topic=584809.msg4143600#msg4143600

Smells like a server related bug, as it only happens infrequently.  Have devs looked at it?
Title: Re: Error after upgrade : Wrong value type sent to the database. Array of integer...
Post by: mrnuke on March 21, 2023, 12:48:26 AM
Any Devs that can help? It's pretty annoying, no attachments and no custom avatars, etc..
Title: Re: Error after upgrade : Wrong value type sent to the database. Array of integer...
Post by: shawnb61 on March 21, 2023, 01:06:30 AM
PHP version?
MySQL version?
Did you have attachments & avatars before the upgrade?
Did the upgrade provide you with any errors or warnings?   (Esp. with regards to attachments/avatars folders?)
Do your attachments have a .dat extension on them in your attachments folder now?  Or no extension?
Have you run repair_settings.php to confirm all your folders are set correctly?


In general, if your attachments don't have a .dat extension, 99% of the time what you need to do is:
 - Confirm/validate folder settings for attachments & avatars in repair_settings.php
 - Rerun the 2.1.3 upgrader, & be sure to check the box to reprocess attachments
Title: Re: Error after upgrade : Wrong value type sent to the database. Array of integer...
Post by: digger on August 16, 2023, 05:56:30 PM
Just encountered this error after moderating a post without attachments

QuoteWrong value type sent to the database. Array of integers expected. (preview_attachments)
Function: prepareAttachsByMsg

DB query
        $request = $smcFunc['db_query']('', '
            SELECT
                a.id_attach, a.id_folder, a.id_msg, a.filename, a.file_hash, COALESCE(a.size, 0) AS filesize, a.downloads, a.approved, m.id_topic AS topic, m.id_board AS board, m.id_member, a.mime_type,
                a.mime_type, a.proper_rotation, a.jpeg_quality, a.width, a.height' . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' : ',
                thumb.id_folder AS thumb_folder, thumb.file_hash AS thumb_hash, thumb.filename AS thumb_name,
                thumb.mime_type AS thumb_mime, thumb.proper_rotation AS thumb_rotation, thumb.size AS thumb_size,
                COALESCE(thumb.id_attach, 0) AS id_thumb, thumb.width AS thumb_width, thumb.height AS thumb_height') . '
            FROM {db_prefix}attachments AS a' . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' : '
                LEFT JOIN {db_prefix}attachments AS thumb ON (thumb.id_attach = a.id_thumb)') . '
                LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg)
            WHERE a.attachment_type = {int:attachment_type}
                AND (' . $msg_or_att . ')',
            array(
                'message_id' => $msgIDs,
                'attachment_type' => 0,
                'preview_attachments' => !empty($_SESSION['attachments_can_preview']) ? array_keys(array_filter($_SESSION['attachments_can_preview'])) : array(0),
            )
        );

$_SESSION['attachments_can_preview']contains
array(1) { [""]=> bool(true) }
array_keys(array_filter($_SESSION['attachments_can_preview']))returns
array(1) { [0]=> string(0) "" }
SMF: 2.1.4
MySQL: 10.5.18-MariaDB
PHP: 7.4.33
Title: Re: Error after upgrade : Wrong value type sent to the database. Array of integer...
Post by: szinski on July 02, 2024, 03:09:27 PM
I'm seeing the same error on my forum too.

/home/bci/public_html/forum/Sources/Subs-Attachments.php (Line 1460)

Wrong value type sent to the database. Array of integers expected. (preview_attachments)
Function: prepareAttachsByMsg

Error happens even with my Image Attachment & Rotation plug-in disabled.
Title: Re: Error after upgrade : Wrong value type sent to the database. Array of integer...
Post by: szinski on July 02, 2024, 04:02:03 PM
Interesting turn of events. I had my user try a different browser when attaching images and he is getting no errors using Chrome (he had been using Firefox). He then rebooted his computer and now the issue has disappeared completely, even using Firefox. So this was caused by a client-side issue.