The main reason for introducing this class was to remove the dependency of storages on DbSchemaInfo and ActionsInfoProvider which are on a different level of abstraction.
 /**
  * @param $changeInfoList
  * @param array $indicies
  * @param string $resultAction
  */
 private function replaceChangeInfosCombination(&$changeInfoList, $indicies, $resultAction)
 {
     $entities = $this->getChangeInfosByIndicies($changeInfoList, $indicies);
     foreach ($entities as $entityId => $changeInfos) {
         if (count($changeInfos) == 2) {
             /** @var EntityChangeInfo $sourceChangeInfo */
             $sourceChangeInfo = $changeInfoList[$changeInfos[$indicies[0]][0]];
             $this->removeChangeInfos($changeInfoList, $changeInfos);
             $fakeEntity = ['vp_id' => $sourceChangeInfo->getId()];
             $changeInfoList[] = $this->changeInfoFactory->createEntityChangeInfo($fakeEntity, 'post', $resultAction, $sourceChangeInfo->getCustomTags(), $sourceChangeInfo->getChangedFiles());
         }
     }
 }
Пример #2
0
 private function doInitializationCommit($isUpdate)
 {
     $this->checkTimeout();
     // Since WP-217 the `.active` file contains not the SHA1 of the first commit that VersionPress
     // created but the one before that (which may be an empty string if VersionPress's commit
     // was the first one in the repository).
     $lastCommitHash = $this->repository->getLastCommitHash();
     file_put_contents(VERSIONPRESS_ACTIVATION_FILE, $lastCommitHash);
     $this->reportProgressChange(InitializerStates::CREATING_INITIAL_COMMIT);
     $action = $isUpdate ? 'update' : 'activate';
     $committedFiles = [["type" => "path", "path" => "*"]];
     $changeInfo = $this->changeInfoFactory->createTrackedChangeInfo('versionpress', $action, VersionPress::getVersion(), [], $committedFiles);
     $currentUser = wp_get_current_user();
     /** @noinspection PhpUndefinedFieldInspection */
     $authorName = $currentUser->display_name;
     /** @noinspection PhpUndefinedFieldInspection */
     $authorEmail = $currentUser->user_email;
     if (defined('WP_CLI') && WP_CLI) {
         $authorName = GitConfig::$wpcliUserName;
         $authorEmail = GitConfig::$wpcliUserEmail;
     }
     try {
         $this->adjustGitProcessTimeout();
         $this->repository->stageAll();
         $this->adjustGitProcessTimeout();
         $this->repository->commit($changeInfo->getCommitMessage(), $authorName, $authorEmail);
     } catch (ProcessTimedOutException $ex) {
         $this->abortInitialization();
     }
 }
 private function createChangeInfo($oldEntity, $newEntity, $action)
 {
     $entityName = $this->entityInfo->entityName;
     $entity = array_merge($oldEntity, $newEntity);
     $changeInfo = $this->changeInfoFactory->createEntityChangeInfo($entity, $entityName, $action);
     $files = $changeInfo->getChangedFiles();
     $action = apply_filters("vp_entity_action_{$entityName}", $action, $oldEntity, $newEntity);
     $tags = apply_filters("vp_entity_tags_{$entityName}", $changeInfo->getCustomTags(), $oldEntity, $newEntity, $action);
     $files = apply_filters("vp_entity_files_{$entityName}", $files, $oldEntity, $newEntity);
     return $this->changeInfoFactory->createEntityChangeInfo($entity, $entityName, $action, $tags, $files);
 }