Completed
Push — master ( f9d8eb...989a8a )
by Lukas
14:49
created
lib/private/Repair/MoveUpdaterStepFile.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -28,53 +28,53 @@
 block discarded – undo
28 28
 
29 29
 class MoveUpdaterStepFile implements IRepairStep {
30 30
 
31
-	/** @var \OCP\IConfig */
32
-	protected $config;
31
+    /** @var \OCP\IConfig */
32
+    protected $config;
33 33
 
34
-	/**
35
-	 * @param \OCP\IConfig $config
36
-	 */
37
-	public function __construct($config) {
38
-		$this->config = $config;
39
-	}
34
+    /**
35
+     * @param \OCP\IConfig $config
36
+     */
37
+    public function __construct($config) {
38
+        $this->config = $config;
39
+    }
40 40
 
41
-	public function getName() {
42
-		return 'Move .step file of updater to backup location';
43
-	}
41
+    public function getName() {
42
+        return 'Move .step file of updater to backup location';
43
+    }
44 44
 
45
-	public function run(IOutput $output) {
45
+    public function run(IOutput $output) {
46 46
 
47
-		$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
48
-		$instanceId = $this->config->getSystemValue('instanceid', null);
47
+        $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
48
+        $instanceId = $this->config->getSystemValue('instanceid', null);
49 49
 
50
-		if(!is_string($instanceId) || empty($instanceId)) {
51
-			return;
52
-		}
50
+        if(!is_string($instanceId) || empty($instanceId)) {
51
+            return;
52
+        }
53 53
 
54
-		$updaterFolderPath = $dataDir . '/updater-' . $instanceId;
55
-		$stepFile = $updaterFolderPath . '/.step';
56
-		if(file_exists($stepFile)) {
57
-			$output->info('.step file exists');
54
+        $updaterFolderPath = $dataDir . '/updater-' . $instanceId;
55
+        $stepFile = $updaterFolderPath . '/.step';
56
+        if(file_exists($stepFile)) {
57
+            $output->info('.step file exists');
58 58
 
59
-			$previousStepFile = $updaterFolderPath . '/.step-previous-update';
59
+            $previousStepFile = $updaterFolderPath . '/.step-previous-update';
60 60
 
61
-			// cleanup
62
-			if(file_exists($previousStepFile)) {
63
-				if(\OC_Helper::rmdirr($previousStepFile)) {
64
-					$output->info('.step-previous-update removed');
65
-				} else {
66
-					$output->info('.step-previous-update can\'t be removed - abort move of .step file');
67
-					return;
68
-				}
69
-			}
61
+            // cleanup
62
+            if(file_exists($previousStepFile)) {
63
+                if(\OC_Helper::rmdirr($previousStepFile)) {
64
+                    $output->info('.step-previous-update removed');
65
+                } else {
66
+                    $output->info('.step-previous-update can\'t be removed - abort move of .step file');
67
+                    return;
68
+                }
69
+            }
70 70
 
71
-			// move step file
72
-			if(rename($stepFile, $previousStepFile)) {
73
-				$output->info('.step file moved to .step-previous-update');
74
-			} else {
75
-				$output->warning('.step file can\'t be moved');
76
-			}
77
-		}
78
-	}
71
+            // move step file
72
+            if(rename($stepFile, $previousStepFile)) {
73
+                $output->info('.step file moved to .step-previous-update');
74
+            } else {
75
+                $output->warning('.step file can\'t be moved');
76
+            }
77
+        }
78
+    }
79 79
 }
80 80
 
Please login to merge, or discard this patch.
lib/private/Repair/NC11/CleanPreviews.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -31,43 +31,43 @@
 block discarded – undo
31 31
 
32 32
 class CleanPreviews implements IRepairStep {
33 33
 
34
-	/** @var IJobList */
35
-	private $jobList;
34
+    /** @var IJobList */
35
+    private $jobList;
36 36
 
37
-	/** @var IUserManager */
38
-	private $userManager;
37
+    /** @var IUserManager */
38
+    private $userManager;
39 39
 
40
-	/** @var IConfig */
41
-	private $config;
40
+    /** @var IConfig */
41
+    private $config;
42 42
 
43
-	/**
44
-	 * MoveAvatars constructor.
45
-	 *
46
-	 * @param IJobList $jobList
47
-	 * @param IUserManager $userManager
48
-	 * @param IConfig $config
49
-	 */
50
-	public function __construct(IJobList $jobList,
51
-								IUserManager $userManager,
52
-								IConfig $config) {
53
-		$this->jobList = $jobList;
54
-		$this->userManager = $userManager;
55
-		$this->config = $config;
56
-	}
43
+    /**
44
+     * MoveAvatars constructor.
45
+     *
46
+     * @param IJobList $jobList
47
+     * @param IUserManager $userManager
48
+     * @param IConfig $config
49
+     */
50
+    public function __construct(IJobList $jobList,
51
+                                IUserManager $userManager,
52
+                                IConfig $config) {
53
+        $this->jobList = $jobList;
54
+        $this->userManager = $userManager;
55
+        $this->config = $config;
56
+    }
57 57
 
58
-	/**
59
-	 * @return string
60
-	 */
61
-	public function getName() {
62
-		return 'Add preview cleanup background jobs';
63
-	}
58
+    /**
59
+     * @return string
60
+     */
61
+    public function getName() {
62
+        return 'Add preview cleanup background jobs';
63
+    }
64 64
 
65
-	public function run(IOutput $output) {
66
-		if (!$this->config->getAppValue('core', 'previewsCleanedUp', false)) {
67
-			$this->userManager->callForSeenUsers(function (IUser $user) {
68
-				$this->jobList->add(CleanPreviewsBackgroundJob::class, ['uid' => $user->getUID()]);
69
-			});
70
-			$this->config->setAppValue('core', 'previewsCleanedUp', 1);
71
-		}
72
-	}
65
+    public function run(IOutput $output) {
66
+        if (!$this->config->getAppValue('core', 'previewsCleanedUp', false)) {
67
+            $this->userManager->callForSeenUsers(function (IUser $user) {
68
+                $this->jobList->add(CleanPreviewsBackgroundJob::class, ['uid' => $user->getUID()]);
69
+            });
70
+            $this->config->setAppValue('core', 'previewsCleanedUp', 1);
71
+        }
72
+    }
73 73
 }
Please login to merge, or discard this patch.
lib/private/Repair/NC11/MoveAvatars.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -29,44 +29,44 @@
 block discarded – undo
29 29
 
30 30
 class MoveAvatars implements IRepairStep {
31 31
 
32
-	/** @var IJobList */
33
-	private $jobList;
32
+    /** @var IJobList */
33
+    private $jobList;
34 34
 
35
-	/** @var IConfig */
36
-	private $config;
35
+    /** @var IConfig */
36
+    private $config;
37 37
 
38
-	/**
39
-	 * MoveAvatars constructor.
40
-	 *
41
-	 * @param IJobList $jobList
42
-	 * @param IConfig $config
43
-	 */
44
-	public function __construct(IJobList $jobList,
45
-								IConfig $config) {
46
-		$this->jobList = $jobList;
47
-		$this->config = $config;
48
-	}
38
+    /**
39
+     * MoveAvatars constructor.
40
+     *
41
+     * @param IJobList $jobList
42
+     * @param IConfig $config
43
+     */
44
+    public function __construct(IJobList $jobList,
45
+                                IConfig $config) {
46
+        $this->jobList = $jobList;
47
+        $this->config = $config;
48
+    }
49 49
 
50
-	/**
51
-	 * @return string
52
-	 */
53
-	public function getName() {
54
-		return 'Add move avatar background job';
55
-	}
50
+    /**
51
+     * @return string
52
+     */
53
+    public function getName() {
54
+        return 'Add move avatar background job';
55
+    }
56 56
 
57
-	public function run(IOutput $output) {
58
-		// only run once
59
-		if ($this->config->getAppValue('core', 'moveavatarsdone') === 'yes') {
60
-			$output->info('Repair step already executed');
61
-			return;
62
-		}
63
-		if ($this->config->getSystemValue('enable_avatars', true) === false) {
64
-			$output->info('Avatars are disabled');
65
-		} else {
66
-			$output->info('Add background job');
67
-			$this->jobList->add(MoveAvatarsBackgroundJob::class);
68
-			// if all were done, no need to redo the repair during next upgrade
69
-			$this->config->setAppValue('core', 'moveavatarsdone', 'yes');
70
-		}
71
-	}
57
+    public function run(IOutput $output) {
58
+        // only run once
59
+        if ($this->config->getAppValue('core', 'moveavatarsdone') === 'yes') {
60
+            $output->info('Repair step already executed');
61
+            return;
62
+        }
63
+        if ($this->config->getSystemValue('enable_avatars', true) === false) {
64
+            $output->info('Avatars are disabled');
65
+        } else {
66
+            $output->info('Add background job');
67
+            $this->jobList->add(MoveAvatarsBackgroundJob::class);
68
+            // if all were done, no need to redo the repair during next upgrade
69
+            $this->config->setAppValue('core', 'moveavatarsdone', 'yes');
70
+        }
71
+    }
72 72
 }
Please login to merge, or discard this patch.
lib/private/Repair/NC11/CleanPreviewsBackgroundJob.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -32,90 +32,90 @@
 block discarded – undo
32 32
 use OCP\ILogger;
33 33
 
34 34
 class CleanPreviewsBackgroundJob extends QueuedJob {
35
-	/** @var IRootFolder */
36
-	private $rootFolder;
37
-
38
-	/** @var ILogger */
39
-	private $logger;
40
-
41
-	/** @var IJobList */
42
-	private $jobList;
43
-
44
-	/** @var ITimeFactory */
45
-	private $timeFactory;
46
-
47
-	/**
48
-	 * CleanPreviewsBackgroundJob constructor.
49
-	 *
50
-	 * @param IRootFolder $rootFolder
51
-	 * @param ILogger $logger
52
-	 * @param IJobList $jobList
53
-	 * @param ITimeFactory $timeFactory
54
-	 */
55
-	public function __construct(IRootFolder $rootFolder,
56
-								ILogger $logger,
57
-								IJobList $jobList,
58
-								ITimeFactory $timeFactory) {
59
-		$this->rootFolder = $rootFolder;
60
-		$this->logger = $logger;
61
-		$this->jobList = $jobList;
62
-		$this->timeFactory = $timeFactory;
63
-	}
64
-
65
-	public function run($arguments) {
66
-		$uid = $arguments['uid'];
67
-		$this->logger->info('Started preview cleanup for ' . $uid);
68
-		$empty = $this->cleanupPreviews($uid);
69
-
70
-		if (!$empty) {
71
-			$this->jobList->add(self::class, ['uid' => $uid]);
72
-			$this->logger->info('New preview cleanup scheduled for ' . $uid);
73
-		} else {
74
-			$this->logger->info('Preview cleanup done for ' . $uid);
75
-		}
76
-	}
77
-
78
-	/**
79
-	 * @param $uid
80
-	 * @return bool
81
-	 */
82
-	private function cleanupPreviews($uid) {
83
-		try {
84
-			$userFolder = $this->rootFolder->getUserFolder($uid);
85
-		} catch (NotFoundException $e) {
86
-			return true;
87
-		}
88
-
89
-		$userRoot = $userFolder->getParent();
90
-
91
-		try {
92
-			/** @var Folder $thumbnailFolder */
93
-			$thumbnailFolder = $userRoot->get('thumbnails');
94
-		} catch (NotFoundException $e) {
95
-			return true;
96
-		}
97
-
98
-		$thumbnails = $thumbnailFolder->getDirectoryListing();
99
-
100
-		$start = $this->timeFactory->getTime();
101
-		foreach ($thumbnails as $thumbnail) {
102
-			try {
103
-				$thumbnail->delete();
104
-			} catch (NotPermittedException $e) {
105
-				// Ignore
106
-			}
107
-
108
-			if (($this->timeFactory->getTime() - $start) > 15) {
109
-				return false;
110
-			}
111
-		}
112
-
113
-		try {
114
-			$thumbnailFolder->delete();
115
-		} catch (NotPermittedException $e) {
116
-			// Ignore
117
-		}
118
-
119
-		return true;
120
-	}
35
+    /** @var IRootFolder */
36
+    private $rootFolder;
37
+
38
+    /** @var ILogger */
39
+    private $logger;
40
+
41
+    /** @var IJobList */
42
+    private $jobList;
43
+
44
+    /** @var ITimeFactory */
45
+    private $timeFactory;
46
+
47
+    /**
48
+     * CleanPreviewsBackgroundJob constructor.
49
+     *
50
+     * @param IRootFolder $rootFolder
51
+     * @param ILogger $logger
52
+     * @param IJobList $jobList
53
+     * @param ITimeFactory $timeFactory
54
+     */
55
+    public function __construct(IRootFolder $rootFolder,
56
+                                ILogger $logger,
57
+                                IJobList $jobList,
58
+                                ITimeFactory $timeFactory) {
59
+        $this->rootFolder = $rootFolder;
60
+        $this->logger = $logger;
61
+        $this->jobList = $jobList;
62
+        $this->timeFactory = $timeFactory;
63
+    }
64
+
65
+    public function run($arguments) {
66
+        $uid = $arguments['uid'];
67
+        $this->logger->info('Started preview cleanup for ' . $uid);
68
+        $empty = $this->cleanupPreviews($uid);
69
+
70
+        if (!$empty) {
71
+            $this->jobList->add(self::class, ['uid' => $uid]);
72
+            $this->logger->info('New preview cleanup scheduled for ' . $uid);
73
+        } else {
74
+            $this->logger->info('Preview cleanup done for ' . $uid);
75
+        }
76
+    }
77
+
78
+    /**
79
+     * @param $uid
80
+     * @return bool
81
+     */
82
+    private function cleanupPreviews($uid) {
83
+        try {
84
+            $userFolder = $this->rootFolder->getUserFolder($uid);
85
+        } catch (NotFoundException $e) {
86
+            return true;
87
+        }
88
+
89
+        $userRoot = $userFolder->getParent();
90
+
91
+        try {
92
+            /** @var Folder $thumbnailFolder */
93
+            $thumbnailFolder = $userRoot->get('thumbnails');
94
+        } catch (NotFoundException $e) {
95
+            return true;
96
+        }
97
+
98
+        $thumbnails = $thumbnailFolder->getDirectoryListing();
99
+
100
+        $start = $this->timeFactory->getTime();
101
+        foreach ($thumbnails as $thumbnail) {
102
+            try {
103
+                $thumbnail->delete();
104
+            } catch (NotPermittedException $e) {
105
+                // Ignore
106
+            }
107
+
108
+            if (($this->timeFactory->getTime() - $start) > 15) {
109
+                return false;
110
+            }
111
+        }
112
+
113
+        try {
114
+            $thumbnailFolder->delete();
115
+        } catch (NotPermittedException $e) {
116
+            // Ignore
117
+        }
118
+
119
+        return true;
120
+    }
121 121
 }
Please login to merge, or discard this patch.
lib/private/Repair/NC11/FixMountStorages.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -29,50 +29,50 @@
 block discarded – undo
29 29
 
30 30
 class FixMountStorages implements IRepairStep {
31 31
 
32
-	/** @var IDBConnection */
33
-	private $db;
32
+    /** @var IDBConnection */
33
+    private $db;
34 34
 
35
-	/**
36
-	 * @param IDBConnection $db
37
-	 */
38
-	public function __construct(IDBConnection $db) {
39
-		$this->db = $db;
40
-	}
35
+    /**
36
+     * @param IDBConnection $db
37
+     */
38
+    public function __construct(IDBConnection $db) {
39
+        $this->db = $db;
40
+    }
41 41
 
42
-	/**
43
-	 * @return string
44
-	 */
45
-	public function getName() {
46
-		return 'Fix potential broken mount points';
47
-	}
42
+    /**
43
+     * @return string
44
+     */
45
+    public function getName() {
46
+        return 'Fix potential broken mount points';
47
+    }
48 48
 
49
-	public function run(IOutput $output) {
50
-		$query = $this->db->getQueryBuilder();
51
-		$query->select('m.id', 'f.storage')
52
-			->from('mounts', 'm')
53
-			->leftJoin('m', 'filecache', 'f', $query->expr()->eq('m.root_id', 'f.fileid'))
54
-			->where($query->expr()->neq('m.storage_id', 'f.storage'));
49
+    public function run(IOutput $output) {
50
+        $query = $this->db->getQueryBuilder();
51
+        $query->select('m.id', 'f.storage')
52
+            ->from('mounts', 'm')
53
+            ->leftJoin('m', 'filecache', 'f', $query->expr()->eq('m.root_id', 'f.fileid'))
54
+            ->where($query->expr()->neq('m.storage_id', 'f.storage'));
55 55
 
56
-		$update = $this->db->getQueryBuilder();
57
-		$update->update('mounts')
58
-			->set('storage_id', $update->createParameter('storage'))
59
-			->where($query->expr()->eq('id', $update->createParameter('mount')));
56
+        $update = $this->db->getQueryBuilder();
57
+        $update->update('mounts')
58
+            ->set('storage_id', $update->createParameter('storage'))
59
+            ->where($query->expr()->eq('id', $update->createParameter('mount')));
60 60
 
61
-		$result = $query->execute();
62
-		$entriesUpdated = 0;
63
-		while ($row = $result->fetch()) {
64
-			$update->setParameter('storage', $row['storage'], IQueryBuilder::PARAM_INT)
65
-				->setParameter('mount', $row['id'], IQueryBuilder::PARAM_INT);
66
-			$update->execute();
67
-			$entriesUpdated++;
68
-		}
69
-		$result->closeCursor();
61
+        $result = $query->execute();
62
+        $entriesUpdated = 0;
63
+        while ($row = $result->fetch()) {
64
+            $update->setParameter('storage', $row['storage'], IQueryBuilder::PARAM_INT)
65
+                ->setParameter('mount', $row['id'], IQueryBuilder::PARAM_INT);
66
+            $update->execute();
67
+            $entriesUpdated++;
68
+        }
69
+        $result->closeCursor();
70 70
 
71
-		if ($entriesUpdated > 0) {
72
-			$output->info($entriesUpdated . ' mounts updated');
73
-			return;
74
-		}
71
+        if ($entriesUpdated > 0) {
72
+            $output->info($entriesUpdated . ' mounts updated');
73
+            return;
74
+        }
75 75
 
76
-		$output->info('No mounts updated');
77
-	}
76
+        $output->info('No mounts updated');
77
+    }
78 78
 }
Please login to merge, or discard this patch.
lib/private/Repair/SqliteAutoincrement.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -36,66 +36,66 @@
 block discarded – undo
36 36
  * altered in order to retrigger SQL schema generation through OCSqlitePlatform.
37 37
  */
38 38
 class SqliteAutoincrement implements IRepairStep {
39
-	/**
40
-	 * @var \OC\DB\Connection
41
-	 */
42
-	protected $connection;
39
+    /**
40
+     * @var \OC\DB\Connection
41
+     */
42
+    protected $connection;
43 43
 
44
-	/**
45
-	 * @param \OC\DB\Connection $connection
46
-	 */
47
-	public function __construct($connection) {
48
-		$this->connection = $connection;
49
-	}
44
+    /**
45
+     * @param \OC\DB\Connection $connection
46
+     */
47
+    public function __construct($connection) {
48
+        $this->connection = $connection;
49
+    }
50 50
 
51
-	public function getName() {
52
-		return 'Repair SQLite autoincrement';
53
-	}
51
+    public function getName() {
52
+        return 'Repair SQLite autoincrement';
53
+    }
54 54
 
55
-	/**
56
-	 * Fix mime types
57
-	 */
58
-	public function run(IOutput $out) {
59
-		if (!$this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
60
-			return;
61
-		}
55
+    /**
56
+     * Fix mime types
57
+     */
58
+    public function run(IOutput $out) {
59
+        if (!$this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
60
+            return;
61
+        }
62 62
 
63
-		$sourceSchema = $this->connection->getSchemaManager()->createSchema();
63
+        $sourceSchema = $this->connection->getSchemaManager()->createSchema();
64 64
 
65
-		$schemaDiff = new SchemaDiff();
65
+        $schemaDiff = new SchemaDiff();
66 66
 
67
-		foreach ($sourceSchema->getTables() as $tableSchema) {
68
-			$primaryKey = $tableSchema->getPrimaryKey();
69
-			if (!$primaryKey) {
70
-				continue;
71
-			}
67
+        foreach ($sourceSchema->getTables() as $tableSchema) {
68
+            $primaryKey = $tableSchema->getPrimaryKey();
69
+            if (!$primaryKey) {
70
+                continue;
71
+            }
72 72
 
73
-			$columnNames = $primaryKey->getColumns();
73
+            $columnNames = $primaryKey->getColumns();
74 74
 
75
-			// add a column diff for every primary key column,
76
-			// but do not actually change anything, this will
77
-			// force the generation of SQL statements to alter
78
-			// those tables, which will then trigger the
79
-			// specific SQL code from OCSqlitePlatform
80
-			try {
81
-				$tableDiff = new TableDiff($tableSchema->getName());
82
-				$tableDiff->fromTable = $tableSchema;
83
-				foreach ($columnNames as $columnName) {
84
-					$columnSchema = $tableSchema->getColumn($columnName);
85
-					$columnDiff = new ColumnDiff($columnSchema->getName(), $columnSchema);
86
-					$tableDiff->changedColumns[] = $columnDiff;
87
-					$schemaDiff->changedTables[] = $tableDiff;
88
-				}
89
-			} catch (SchemaException $e) {
90
-				// ignore
91
-			}
92
-		}
75
+            // add a column diff for every primary key column,
76
+            // but do not actually change anything, this will
77
+            // force the generation of SQL statements to alter
78
+            // those tables, which will then trigger the
79
+            // specific SQL code from OCSqlitePlatform
80
+            try {
81
+                $tableDiff = new TableDiff($tableSchema->getName());
82
+                $tableDiff->fromTable = $tableSchema;
83
+                foreach ($columnNames as $columnName) {
84
+                    $columnSchema = $tableSchema->getColumn($columnName);
85
+                    $columnDiff = new ColumnDiff($columnSchema->getName(), $columnSchema);
86
+                    $tableDiff->changedColumns[] = $columnDiff;
87
+                    $schemaDiff->changedTables[] = $tableDiff;
88
+                }
89
+            } catch (SchemaException $e) {
90
+                // ignore
91
+            }
92
+        }
93 93
 
94
-		$this->connection->beginTransaction();
95
-		foreach ($schemaDiff->toSql($this->connection->getDatabasePlatform()) as $sql) {
96
-			$this->connection->query($sql);
97
-		}
98
-		$this->connection->commit();
99
-	}
94
+        $this->connection->beginTransaction();
95
+        foreach ($schemaDiff->toSql($this->connection->getDatabasePlatform()) as $sql) {
96
+            $this->connection->query($sql);
97
+        }
98
+        $this->connection->commit();
99
+    }
100 100
 }
101 101
 
Please login to merge, or discard this patch.
lib/private/RichObjectStrings/Validator.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -34,81 +34,81 @@
 block discarded – undo
34 34
  */
35 35
 class Validator implements IValidator {
36 36
 
37
-	/** @var Definitions */
38
-	protected $definitions;
39
-
40
-	/** @var array[] */
41
-	protected $requiredParameters = [];
42
-
43
-	/**
44
-	 * Constructor
45
-	 *
46
-	 * @param Definitions $definitions
47
-	 */
48
-	public function __construct(Definitions $definitions) {
49
-		$this->definitions = $definitions;
50
-	}
51
-
52
-	/**
53
-	 * @param string $subject
54
-	 * @param array[] $parameters
55
-	 * @throws InvalidObjectExeption
56
-	 * @since 11.0.0
57
-	 */
58
-	public function validate($subject, array $parameters) {
59
-		$matches = [];
60
-		$result = preg_match_all('/\{([a-z0-9]+)\}/i', $subject, $matches);
61
-
62
-		if ($result === false) {
63
-			throw new InvalidObjectExeption();
64
-		}
65
-
66
-		if (!empty($matches[1])) {
67
-			foreach ($matches[1] as $parameter) {
68
-				if (!isset($parameters[$parameter])) {
69
-					throw new InvalidObjectExeption('Parameter is undefined');
70
-				} else {
71
-					$this->validateParameter($parameters[$parameter]);
72
-				}
73
-			}
74
-		}
75
-	}
76
-
77
-	/**
78
-	 * @param array $parameter
79
-	 * @throws InvalidObjectExeption
80
-	 */
81
-	protected function validateParameter(array $parameter) {
82
-		if (!isset($parameter['type'])) {
83
-			throw new InvalidObjectExeption('Object type is undefined');
84
-		}
85
-
86
-		$definition = $this->definitions->getDefinition($parameter['type']);
87
-		$requiredParameters = $this->getRequiredParameters($parameter['type'], $definition);
88
-
89
-		$missingKeys = array_diff($requiredParameters, array_keys($parameter));
90
-		if (!empty($missingKeys)) {
91
-			throw new InvalidObjectExeption('Object is invalid');
92
-		}
93
-	}
94
-
95
-	/**
96
-	 * @param string $type
97
-	 * @param array $definition
98
-	 * @return string[]
99
-	 */
100
-	protected function getRequiredParameters($type, array $definition) {
101
-		if (isset($this->requiredParameters[$type])) {
102
-			return $this->requiredParameters[$type];
103
-		}
104
-
105
-		$this->requiredParameters[$type] = [];
106
-		foreach ($definition['parameters'] as $parameter => $data) {
107
-			if ($data['required']) {
108
-				$this->requiredParameters[$type][] = $parameter;
109
-			}
110
-		}
111
-
112
-		return $this->requiredParameters[$type];
113
-	}
37
+    /** @var Definitions */
38
+    protected $definitions;
39
+
40
+    /** @var array[] */
41
+    protected $requiredParameters = [];
42
+
43
+    /**
44
+     * Constructor
45
+     *
46
+     * @param Definitions $definitions
47
+     */
48
+    public function __construct(Definitions $definitions) {
49
+        $this->definitions = $definitions;
50
+    }
51
+
52
+    /**
53
+     * @param string $subject
54
+     * @param array[] $parameters
55
+     * @throws InvalidObjectExeption
56
+     * @since 11.0.0
57
+     */
58
+    public function validate($subject, array $parameters) {
59
+        $matches = [];
60
+        $result = preg_match_all('/\{([a-z0-9]+)\}/i', $subject, $matches);
61
+
62
+        if ($result === false) {
63
+            throw new InvalidObjectExeption();
64
+        }
65
+
66
+        if (!empty($matches[1])) {
67
+            foreach ($matches[1] as $parameter) {
68
+                if (!isset($parameters[$parameter])) {
69
+                    throw new InvalidObjectExeption('Parameter is undefined');
70
+                } else {
71
+                    $this->validateParameter($parameters[$parameter]);
72
+                }
73
+            }
74
+        }
75
+    }
76
+
77
+    /**
78
+     * @param array $parameter
79
+     * @throws InvalidObjectExeption
80
+     */
81
+    protected function validateParameter(array $parameter) {
82
+        if (!isset($parameter['type'])) {
83
+            throw new InvalidObjectExeption('Object type is undefined');
84
+        }
85
+
86
+        $definition = $this->definitions->getDefinition($parameter['type']);
87
+        $requiredParameters = $this->getRequiredParameters($parameter['type'], $definition);
88
+
89
+        $missingKeys = array_diff($requiredParameters, array_keys($parameter));
90
+        if (!empty($missingKeys)) {
91
+            throw new InvalidObjectExeption('Object is invalid');
92
+        }
93
+    }
94
+
95
+    /**
96
+     * @param string $type
97
+     * @param array $definition
98
+     * @return string[]
99
+     */
100
+    protected function getRequiredParameters($type, array $definition) {
101
+        if (isset($this->requiredParameters[$type])) {
102
+            return $this->requiredParameters[$type];
103
+        }
104
+
105
+        $this->requiredParameters[$type] = [];
106
+        foreach ($definition['parameters'] as $parameter => $data) {
107
+            if ($data['required']) {
108
+                $this->requiredParameters[$type][] = $parameter;
109
+            }
110
+        }
111
+
112
+        return $this->requiredParameters[$type];
113
+    }
114 114
 }
Please login to merge, or discard this patch.
lib/private/DB/MySQLMigrator.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -29,28 +29,28 @@
 block discarded – undo
29 29
 use Doctrine\DBAL\Schema\Table;
30 30
 
31 31
 class MySQLMigrator extends Migrator {
32
-	/**
33
-	 * @param Schema $targetSchema
34
-	 * @param \Doctrine\DBAL\Connection $connection
35
-	 * @return \Doctrine\DBAL\Schema\SchemaDiff
36
-	 */
37
-	protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
38
-		$platform = $connection->getDatabasePlatform();
39
-		$platform->registerDoctrineTypeMapping('enum', 'string');
40
-		$platform->registerDoctrineTypeMapping('bit', 'string');
32
+    /**
33
+     * @param Schema $targetSchema
34
+     * @param \Doctrine\DBAL\Connection $connection
35
+     * @return \Doctrine\DBAL\Schema\SchemaDiff
36
+     */
37
+    protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
38
+        $platform = $connection->getDatabasePlatform();
39
+        $platform->registerDoctrineTypeMapping('enum', 'string');
40
+        $platform->registerDoctrineTypeMapping('bit', 'string');
41 41
 
42
-		$schemaDiff = parent::getDiff($targetSchema, $connection);
42
+        $schemaDiff = parent::getDiff($targetSchema, $connection);
43 43
 
44
-		// identifiers need to be quoted for mysql
45
-		foreach ($schemaDiff->changedTables as $tableDiff) {
46
-			$tableDiff->name = $this->connection->quoteIdentifier($tableDiff->name);
47
-			foreach ($tableDiff->changedColumns as $column) {
48
-				$column->oldColumnName = $this->connection->quoteIdentifier($column->oldColumnName);
49
-			}
50
-		}
44
+        // identifiers need to be quoted for mysql
45
+        foreach ($schemaDiff->changedTables as $tableDiff) {
46
+            $tableDiff->name = $this->connection->quoteIdentifier($tableDiff->name);
47
+            foreach ($tableDiff->changedColumns as $column) {
48
+                $column->oldColumnName = $this->connection->quoteIdentifier($column->oldColumnName);
49
+            }
50
+        }
51 51
 
52
-		return $schemaDiff;
53
-	}
52
+        return $schemaDiff;
53
+    }
54 54
 	
55 55
         /**
56 56
          * Speed up migration test by disabling autocommit and unique indexes check
Please login to merge, or discard this patch.
lib/private/DB/OCSqlitePlatform.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -23,27 +23,27 @@
 block discarded – undo
23 23
 namespace OC\DB;
24 24
 
25 25
 class OCSqlitePlatform extends \Doctrine\DBAL\Platforms\SqlitePlatform {
26
-	/**
27
-	 * {@inheritDoc}
28
-	 */
29
-	public function getColumnDeclarationSQL($name, array $field) {
30
-		$def = parent::getColumnDeclarationSQL($name, $field);
31
-		if (!empty($field['autoincrement'])) {
32
-			$def .= ' PRIMARY KEY AUTOINCREMENT';
33
-		}
34
-		return $def;
35
-	}
26
+    /**
27
+     * {@inheritDoc}
28
+     */
29
+    public function getColumnDeclarationSQL($name, array $field) {
30
+        $def = parent::getColumnDeclarationSQL($name, $field);
31
+        if (!empty($field['autoincrement'])) {
32
+            $def .= ' PRIMARY KEY AUTOINCREMENT';
33
+        }
34
+        return $def;
35
+    }
36 36
 
37
-	/**
38
-	 * {@inheritDoc}
39
-	 */
40
-	protected function _getCreateTableSQL($name, array $columns, array $options = array()){
41
-		// if auto increment is set the column is already defined as primary key
42
-		foreach ($columns as $column) {
43
-			if (!empty($column['autoincrement'])) {
44
-				$options['primary'] = null;
45
-			}
46
-		}
47
-		return parent::_getCreateTableSQL($name, $columns, $options);
48
-	}
37
+    /**
38
+     * {@inheritDoc}
39
+     */
40
+    protected function _getCreateTableSQL($name, array $columns, array $options = array()){
41
+        // if auto increment is set the column is already defined as primary key
42
+        foreach ($columns as $column) {
43
+            if (!empty($column['autoincrement'])) {
44
+                $options['primary'] = null;
45
+            }
46
+        }
47
+        return parent::_getCreateTableSQL($name, $columns, $options);
48
+    }
49 49
 }
Please login to merge, or discard this patch.