コード例 #1
0
ファイル: maintenance.php プロジェクト: eFFemeer/seizamcore
 public function execute_fix_wpw_date_expires()
 {
     $dbw = wfGetDB(DB_MASTER);
     $dbw->begin();
     $this->output("looking for wikiplace records to fix...\n");
     $cond = 'wpw_date_expires > DATE_ADD(wpw_report_updated,INTERVAL 1 MONTH)';
     $wikiplaces = WpWikiplace::search($cond, true);
     foreach ($wikiplaces as $wikiplace) {
         $subscription = WpSubscription::newFromId($wikiplace->getSubscriptionId());
         $should_ends = WpWikiplace::calculateNextDateExpiresFromSubscription($subscription);
         if ($subscription->isActive() && $subscription->getTmrStatus() == 'OK' && $wikiplace->getDateExpires() != $should_ends) {
             $this->output("wpw_id=" . $wikiplace->getId() . "\tupdated=" . $wikiplace->getReportUpdated() . "\texpires=" . $wikiplace->getDateExpires() . "\n");
             $this->output(" > wps\t\tstarts=" . $subscription->getStart() . "\tends=" . $subscription->getEnd() . "\n");
             $this->output(" > should expire {$should_ends}\n");
             if (!$this->isTest()) {
                 $this->output(" > fixing...\n");
                 $success = $dbw->update('wp_wikiplace', array('wpw_date_expires' => $should_ends), array('wpw_id' => $wikiplace->getId()));
                 if (!$success) {
                     $this->error("Error while updating wikiplace id=" . $wikiplace->getId(), true);
                 }
                 $this->output(" > fixed :)\n");
             }
             $this->output("\n");
         }
     }
     $this->output("end\n");
     $dbw->commit();
 }