Announcement

Collapse
No announcement yet.

How to fix refcount for old attachments in database vBulletin 5.5.4

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to fix refcount for old attachments in database vBulletin 5.5.4

    Hello. Is it possible to fix old attachments in vBulletin 5.5.4?

    A bit of history:
    At the beginning of the year, I converted the forum from Phorum to vBulletin 5, since then the forum has been running with the cleanup_2 task turned off, because if I turn it on, old attachments are deleted


    My question is:
    I found a solution to fix this problem in vBulletin 4

    Code:
    UPDATE filedata
    LEFT JOIN (
       SELECT filedataid, COUNT(attachmentid) AS actual
       FROM attachment
       GROUP BY filedataid
    ) list USING (filedataid)
    SET refcount = IFNULL(actual, 0)
    WHERE refcount <> IFNULL(actual, 0)

    How to change this query for vbulletin 5.5.4 Database?

    PHP 7.3.9
    MariaDB 10.3
    Last edited by elektro-kot; Sat 12 Oct '19, 4:01am.

  • #2
    The attachment table is now named attach. I don't know why the name changed. Other than that, the query should work.
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API - Full / Mobile
    Vote for your favorite feature requests and the bugs you want to see fixed.

    Comment


    • #3
      Originally posted by Wayne Luke View Post
      The attachment table is now named attach. Other than that, the query should work.
      Ok Wayne, thank you.

      But, what about the "attachmentid" column? It does not exist in the attach table...

      Comment


      • #4
        It would be the attachid.
        Translations provided by Google.

        Wayne Luke
        The Rabid Badger - a vBulletin Cloud demonstration site.
        vBulletin 5 API - Full / Mobile
        Vote for your favorite feature requests and the bugs you want to see fixed.

        Comment


        • #5
          Originally posted by Wayne Luke View Post
          ...attachid.
          Thank you Wayne.
          I checked the database tables on some test-server for more details (please see the screenshots below).
          looks like it should be filedataid (not attachid) for the correctly update request. Right?



          ATTACH
          Click image for larger version  Name:	attach.jpg Views:	0 Size:	78.0 KB ID:	4424507

          FILEDATA
          Click image for larger version  Name:	filedata.jpg Views:	0 Size:	67.0 KB ID:	4424508
          Last edited by elektro-kot; Tue 15 Oct '19, 3:29pm.

          Comment

          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
          Working...
          X