Announcement

Collapse
No announcement yet.

3.8->4.1.10 step 102 in 4.0a was skipped. plz help run manually

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

  • ru55ian
    replied
    can anyone help?

    Leave a comment:


  • 3.8->4.1.10 step 102 in 4.0a was skipped. plz help run manually

    Gents, i have recently perfomed an upgrade from 3.8 to 4.1 in the upgrade to 4.0.a there was a step 102, where everytime i ran it, it would give me memory errors. I had to skip it and continue. Everything is working great, however in that step 102 was crusial adjustments to attchements, since i am not able to view most of the attachements.
    here is the code for that step 102, anyone can help me apply it manually?

    Code:
    /**
     * Step #102
     *
     */
     function step_102()
     {
      $this->show_message(sprintf($this->phrase['vbphrase']['update_table'], TABLE_PREFIX . 'attachment'));
      require_once(DIR . '/includes/adminfunctions_attachment.php');
      build_attachment_permissions();
      // Kill duplicate files in the filedata table
      $files = $this->db->query_read("
       SELECT count(*) AS count, filehash, filesize
       FROM " . TABLE_PREFIX . "filedata
       GROUP BY filehash, filesize
       HAVING count > 1
      ");
      while ($file = $this->db->fetch_array($files))
      {
       $refcount = 0;
       $filedataid = 0;
       $killfiles = array();
       $files2 = $this->db->query("
        SELECT
         filedataid, refcount, userid
        FROM " . TABLE_PREFIX . "filedata
        WHERE
         filehash = '$file[filehash]'
          AND
         filesize = $file[filesize]
       ");
       while ($file2 = $this->db->fetch_array($files2))
       {
        $refcount += $file2['refcount'];
        if (!$filedataid)
        {
         $filedataid = $file2['filedataid'];
        }
        else
        {
         $killfiles[$file2['filedataid']] = $file2['userid'];
        }
       }
       $this->db->query_write("UPDATE " . TABLE_PREFIX . "filedata SET refcount = $refcount WHERE filedataid = $filedataid");
       $this->db->query_write("UPDATE " . TABLE_PREFIX . "attachment SET filedataid = $filedataid WHERE filedataid IN (" . implode(",", array_keys($killfiles)) . ")");
       $this->db->query_write("DELETE FROM " . TABLE_PREFIX . "filedata WHERE filedataid IN (" . implode(",", array_keys($killfiles)) . ")");
       foreach ($killfiles AS $filedataid => $userid)
       {
        if ($this->registry->GPC['attachtype'] == ATTACH_AS_FILES_NEW)
        {
         $path = $this->registry->options['attachpath'] . '/' . implode('/', preg_split('//', $userid,  -1, PREG_SPLIT_NO_EMPTY));
        }
        else
        {
         $path = $this->registry->options['attachpath'] . '/' . $userid;
        }
        @unlink($path . '/' . $filedataid . '.attach');
        @unlink($path . '/' . $filedataid . '.thumb');
       }
      }
     }
     /**
     * Step #103
     *
     */
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X