protected function processSubmit()
 {
     $req = $this->getRequest();
     $out = $this->getOutput();
     $jobs = array();
     $jobs[] = MessageIndexRebuildJob::newJob();
     $changefile = TranslateUtils::cacheFile(self::CHANGEFILE);
     $reader = CdbReader::open($changefile);
     $groups = unserialize($reader->get('#keys'));
     $postponed = array();
     foreach ($groups as $groupId) {
         $group = MessageGroups::getGroup($groupId);
         $changes = unserialize($reader->get($groupId));
         foreach ($changes as $code => $subchanges) {
             foreach ($subchanges as $type => $messages) {
                 foreach ($messages as $index => $params) {
                     $id = self::changeId($groupId, $code, $type, $params['key']);
                     if ($req->getVal($id) === null) {
                         // We probably hit the limit with number of post parameters.
                         $postponed[$groupId][$code][$type][$index] = $params;
                         continue;
                     }
                     if ($type === 'deletion' || $req->getCheck("i/{$id}")) {
                         continue;
                     }
                     $fuzzy = $req->getCheck("f/{$id}") ? 'fuzzy' : false;
                     $key = $params['key'];
                     $title = Title::makeTitleSafe($group->getNamespace(), "{$key}/{$code}");
                     $jobs[] = MessageUpdateJob::newJob($title, $params['content'], $fuzzy);
                 }
             }
             if (!isset($postponed[$groupId][$code])) {
                 $cache = new MessageGroupCache($groupId, $code);
                 $cache->create();
             }
         }
     }
     JobQueueGroup::singleton()->push($jobs);
     $reader->close();
     rename($changefile, $changefile . '-' . wfTimestamp());
     if (count($postponed)) {
         $changefile = TranslateUtils::cacheFile(self::CHANGEFILE);
         $writer = CdbWriter::open($changefile);
         $keys = array_keys($postponed);
         $writer->set('#keys', serialize($keys));
         foreach ($postponed as $groupId => $changes) {
             $writer->set($groupId, serialize($changes));
         }
         $writer->close();
         $this->showChanges(true, $this->getLimit());
     } else {
         $out->addWikiMsg('translate-smg-submitted');
     }
 }
 /**
  * Creates jobs needed to create or update all translation page definitions.
  * @param TranslatablePage $page
  * @param array $sections
  * @return Job[]
  * @since 2013-01-28
  */
 public static function getTranslationUnitJobs(TranslatablePage $page, array $sections)
 {
     $jobs = array();
     $code = $page->getSourceLanguageCode();
     $prefix = $page->getTitle()->getPrefixedText();
     foreach ($sections as $s) {
         $unit = $s->name;
         $title = Title::makeTitle(NS_TRANSLATIONS, "{$prefix}/{$unit}/{$code}");
         $fuzzy = $s->type === 'changed';
         $jobs[] = MessageUpdateJob::newJob($title, $s->getTextWithVariables(), $fuzzy);
     }
     return $jobs;
 }