ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 12793


Ignore:
Timestamp:
Sep 2, 2009, 6:57:01 PM (13 years ago)
Author:
fukamachi
Message:

db converter - added a convert for diary_comment_image. and added a method to print memory_get_usage()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/branches/fukamachi/db-convert-from-2.x/lib/task/openpneUpgradeFrom2Task.class.php

    r12792 r12793  
    2424  private $validatorFile        = null;
    2525
     26  private $memoryBuf            = 0;
     27
    2628  protected function configure()
    2729  {
     
    3941  protected function execute($arguments = array(), $options = array())
    4042  {
    41     ini_set('memory_limit', '1024M');
     43    ini_set('memory_limit', '512M');
    4244
    4345    // install needed plugins
     
    128130    print "converting DiaryAndImage : ".memory_get_usage()."\n";
    129131    $this->convertDiaryAndImage();
    130     print "converting DiaryComment : ".memory_get_usage()."\n";
    131     $this->convertDiaryComment();
     132    print "converting DiaryCommentAndImage : ".memory_get_usage()."\n";
     133    $this->convertDiaryCommentAndImage();
    132134
    133135    // delete models' cache
     
    11031105  }
    11041106
    1105   protected function convertDiaryComment()
     1107  protected function convertDiaryCommentAndImage()
    11061108  {
    11071109    $this->connectTo2();
     
    11201122      $diaryComment->setCreatedAt($cDiaryComment->getRDatetime());
    11211123      $diaryComment->setUpdatedAt($cDiaryComment->getRDatetime());
     1124
     1125      for ($i = 1; $i <= 3; ++$i)
     1126      {
     1127        if ($diaryCommentImage = $this->getImage('DiaryCommentImage', $cDiaryComment->{getImageFilename_.$i}(), false))
     1128        {
     1129          $diaryCommentImage->setDiaryCommentId($cDiaryComment->getCDiaryCommentId());
     1130          $diaryCommentImage->save();
     1131          $diaryCommentImage->free();
     1132        }
     1133      }
    11221134
    11231135      $diaryComment->save();
     
    13021314    return $image;
    13031315  }
     1316
     1317  protected function printMemoryUsage($msg = 'point: ')
     1318  {
     1319    $memory = memory_get_usage();
     1320    $diff = $memory - $this->memoryBuf;
     1321    printf(
     1322      "%s: %d (%s)\n",
     1323      $msg, $memory, $diff > 0 ? '+'.$diff : $diff
     1324    );
     1325    $this->memoryBuf = $memory;
     1326  }
    13041327}
Note: See TracChangeset for help on using the changeset viewer.