mkdir() public static method

Creates a directory
public static mkdir ( string $dir, integer $mode = 488 )
$dir string
$mode integer
Ejemplo n.º 1
0
 private function prepareBugReport($bugReportDir, $zipFile)
 {
     FileSystem::mkdir($bugReportDir);
     FileSystem::copyDir(VERSIONPRESS_PLUGIN_DIR . '/log', $bugReportDir . '/log');
     $this->savePhpinfo($bugReportDir);
     $this->saveWordPressSpecificInfo($bugReportDir);
     Zip::zipDirectory($bugReportDir, $zipFile);
 }
 public function saveSchema($table)
 {
     $schemaFile = $this->getSchemaFile($table);
     $tableDDL = $this->database->get_var("show create table `{$table}`", 1);
     if (!$tableDDL) {
         return;
     }
     $tableDDL = str_replace("CREATE TABLE `{$this->database->prefix}", 'CREATE TABLE IF NOT EXISTS `' . Storage::PREFIX_PLACEHOLDER, $tableDDL);
     $tableDDL = preg_replace('/( AUTO_INCREMENT=[0-9]+)/', '', $tableDDL);
     FileSystem::mkdir($this->directory);
     file_put_contents($schemaFile, $tableDDL);
 }
 public static function initRepository($repositoryDir)
 {
     self::$repositoryDir = $repositoryDir;
     $driverScriptName = 'ini-merge.php';
     $driverScript = __DIR__ . '/../../src/Git/merge-drivers/' . $driverScriptName;
     $driverScriptFakeDir = self::$repositoryDir . '/src/Git/merge-drivers';
     FileSystem::remove(self::$repositoryDir);
     mkdir(self::$repositoryDir);
     FileSystem::mkdir($driverScriptFakeDir);
     self::$gitRepository = new GitRepository(self::$repositoryDir, __DIR__);
     self::$gitRepository->init();
     copy($driverScript, $driverScriptFakeDir . '/' . $driverScriptName);
     $driverScriptName = 'ini-merge.sh';
     $driverScript = __DIR__ . '/../../src/Git/merge-drivers/' . $driverScriptName;
     copy($driverScript, $driverScriptFakeDir . '/' . $driverScriptName);
 }
Ejemplo n.º 4
0
<?php

/**
 * Uninstallation script for VersionPress. Most things already happened in the
 * `vp_admin_post_confirm_deactivation` hook; here, we just move the .git repo.
 *
 * Testing tip: place exit() at the end of the script and then in the browser
 * just go back and try again.
 *
 * @see vp_admin_post_confirm_deactivation()
 */
use VersionPress\Utils\FileSystem;
use VersionPress\Utils\SecurityUtils;
use VersionPress\Utils\UninstallationUtil;
defined('WP_UNINSTALL_PLUGIN') or die('Direct access not allowed');
require_once dirname(__FILE__) . '/bootstrap.php';
if (UninstallationUtil::uninstallationShouldRemoveGitRepo()) {
    $backupsDir = WP_CONTENT_DIR . '/vpbackups';
    if (!file_exists($backupsDir)) {
        FileSystem::mkdir($backupsDir);
        file_put_contents($backupsDir . '/.gitignore', 'git-backup-*');
        SecurityUtils::protectDirectory($backupsDir);
    }
    $backupPath = $backupsDir . '/git-backup-' . date("YmdHis");
    FileSystem::rename(ABSPATH . '.git', $backupPath, true);
    $productionGitignore = ABSPATH . '.gitignore';
    $templateGitignore = __DIR__ . '/src/Initialization/.gitignore.tpl';
    if (FileSystem::filesHaveSameContents($productionGitignore, $templateGitignore)) {
        FileSystem::remove($productionGitignore);
    }
}
Ejemplo n.º 5
0
 public function prepareStorage()
 {
     FileSystem::mkdir($this->directory);
 }
Ejemplo n.º 6
0
 /**
  * Saves all eligible entities into the file system storage (the 'db' folder)
  */
 private function saveDatabaseToStorages()
 {
     if (is_dir(VP_VPDB_DIR)) {
         FileSystem::remove(VP_VPDB_DIR);
     }
     FileSystem::mkdir(VP_VPDB_DIR);
     $entityNames = $this->synchronizerFactory->getSynchronizationSequence();
     foreach ($entityNames as $entityName) {
         $this->createVpidsForEntitiesOfType($entityName);
         $this->saveEntitiesOfTypeToStorage($entityName);
     }
     $mnReferenceDetails = $this->dbSchema->getAllMnReferences();
     foreach ($mnReferenceDetails as $referenceDetail) {
         $this->saveMnReferences($referenceDetail);
     }
 }
Ejemplo n.º 7
0
 /**
  * Saves all eligible entities into the file system storage (the 'db' folder)
  */
 private function saveDatabaseToStorages()
 {
     if (is_dir(VERSIONPRESS_MIRRORING_DIR)) {
         FileSystem::remove(VERSIONPRESS_MIRRORING_DIR);
     }
     FileSystem::mkdir(VERSIONPRESS_MIRRORING_DIR);
     $entityNames = $this->synchronizerFactory->getSynchronizationSequence();
     foreach ($entityNames as $entityName) {
         $this->createVpidsForEntitiesOfType($entityName);
         $this->saveEntitiesOfTypeToStorage($entityName);
         $this->reportProgressChange("All " . $entityName . " saved into files");
     }
 }
Ejemplo n.º 8
0
 /**
  * Ensures that the clean installation of WordPress is available locally. If not,
  * downloads it from wp.org and stores it as `<clean-installations-dir>/<version>`.
  */
 private function ensureCleanInstallationIsAvailable()
 {
     $cleanInstallationPath = $this->getCleanInstallationPath();
     if (!$this->isCorrectlyDownloaded($cleanInstallationPath)) {
         FileSystem::remove($cleanInstallationPath);
         FileSystem::mkdir($cleanInstallationPath);
         $wpVersion = $this->siteConfig->wpVersion;
         $wpLocale = $this->siteConfig->wpLocale;
         $downloadCommand = "wp core download --path=\"{$cleanInstallationPath}\" --version=\"{$wpVersion}\"";
         if ($wpLocale) {
             $downloadCommand .= " --locale={$wpLocale}";
         }
         $this->exec($downloadCommand, null);
     }
 }