PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.15.4
Independent Analytics – WordPress Analytics Plugin v2.15.4
2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / vendor / illuminate / database / Schema / MySqlSchemaState.php
independent-analytics / vendor / illuminate / database / Schema Last commit date
Grammars 3 weeks ago Blueprint.php 3 weeks ago Builder.php 3 weeks ago ColumnDefinition.php 3 weeks ago ForeignIdColumnDefinition.php 3 weeks ago ForeignKeyDefinition.php 3 weeks ago IndexDefinition.php 3 weeks ago MySqlBuilder.php 3 weeks ago MySqlSchemaState.php 3 weeks ago PostgresBuilder.php 3 weeks ago PostgresSchemaState.php 3 weeks ago SQLiteBuilder.php 3 weeks ago SchemaState.php 3 weeks ago SqlServerBuilder.php 3 weeks ago SqliteSchemaState.php 3 weeks ago
MySqlSchemaState.php
121 lines
1 <?php
2
3 namespace IAWPSCOPED\Illuminate\Database\Schema;
4
5 use Exception;
6 use IAWPSCOPED\Illuminate\Database\Connection;
7 use IAWPSCOPED\Illuminate\Support\Str;
8 use IAWPSCOPED\Symfony\Component\Process\Process;
9 /** @internal */
10 class MySqlSchemaState extends SchemaState
11 {
12 /**
13 * Dump the database's schema into a file.
14 *
15 * @param \Illuminate\Database\Connection $connection
16 * @param string $path
17 * @return void
18 */
19 public function dump(Connection $connection, $path)
20 {
21 $this->executeDumpProcess($this->makeProcess($this->baseDumpCommand() . ' --routines --result-file="${:LARAVEL_LOAD_PATH}" --no-data'), $this->output, \array_merge($this->baseVariables($this->connection->getConfig()), ['LARAVEL_LOAD_PATH' => $path]));
22 $this->removeAutoIncrementingState($path);
23 $this->appendMigrationData($path);
24 }
25 /**
26 * Remove the auto-incrementing state from the given schema dump.
27 *
28 * @param string $path
29 * @return void
30 */
31 protected function removeAutoIncrementingState(string $path)
32 {
33 $this->files->put($path, \preg_replace('/\\s+AUTO_INCREMENT=[0-9]+/iu', '', $this->files->get($path)));
34 }
35 /**
36 * Append the migration data to the schema dump.
37 *
38 * @param string $path
39 * @return void
40 */
41 protected function appendMigrationData(string $path)
42 {
43 $process = $this->executeDumpProcess($this->makeProcess($this->baseDumpCommand() . ' ' . $this->migrationTable . ' --no-create-info --skip-extended-insert --skip-routines --compact'), null, \array_merge($this->baseVariables($this->connection->getConfig()), []));
44 $this->files->append($path, $process->getOutput());
45 }
46 /**
47 * Load the given schema file into the database.
48 *
49 * @param string $path
50 * @return void
51 */
52 public function load($path)
53 {
54 $command = 'mysql ' . $this->connectionString() . ' --database="${:LARAVEL_LOAD_DATABASE}" < "${:LARAVEL_LOAD_PATH}"';
55 $process = $this->makeProcess($command)->setTimeout(null);
56 $process->mustRun(null, \array_merge($this->baseVariables($this->connection->getConfig()), ['LARAVEL_LOAD_PATH' => $path]));
57 }
58 /**
59 * Get the base dump command arguments for MySQL as a string.
60 *
61 * @return string
62 */
63 protected function baseDumpCommand()
64 {
65 $command = 'mysqldump ' . $this->connectionString() . ' --no-tablespaces --skip-add-locks --skip-comments --skip-set-charset --tz-utc --column-statistics=0';
66 if (!$this->connection->isMaria()) {
67 $command .= ' --set-gtid-purged=OFF';
68 }
69 return $command . ' "${:LARAVEL_LOAD_DATABASE}"';
70 }
71 /**
72 * Generate a basic connection string (--socket, --host, --port, --user, --password) for the database.
73 *
74 * @return string
75 */
76 protected function connectionString()
77 {
78 $value = ' --user="${:LARAVEL_LOAD_USER}" --password="${:LARAVEL_LOAD_PASSWORD}"';
79 $config = $this->connection->getConfig();
80 $value .= $config['unix_socket'] ?? \false ? ' --socket="${:LARAVEL_LOAD_SOCKET}"' : ' --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}"';
81 if (isset($config['options'][\PDO::MYSQL_ATTR_SSL_CA])) {
82 $value .= ' --ssl-ca="${:LARAVEL_LOAD_SSL_CA}"';
83 }
84 return $value;
85 }
86 /**
87 * Get the base variables for a dump / load command.
88 *
89 * @param array $config
90 * @return array
91 */
92 protected function baseVariables(array $config)
93 {
94 $config['host'] ??= '';
95 return ['LARAVEL_LOAD_SOCKET' => $config['unix_socket'] ?? '', 'LARAVEL_LOAD_HOST' => \is_array($config['host']) ? $config['host'][0] : $config['host'], 'LARAVEL_LOAD_PORT' => $config['port'] ?? '', 'LARAVEL_LOAD_USER' => $config['username'], 'LARAVEL_LOAD_PASSWORD' => $config['password'] ?? '', 'LARAVEL_LOAD_DATABASE' => $config['database'], 'LARAVEL_LOAD_SSL_CA' => $config['options'][\PDO::MYSQL_ATTR_SSL_CA] ?? ''];
96 }
97 /**
98 * Execute the given dump process.
99 *
100 * @param \Symfony\Component\Process\Process $process
101 * @param callable $output
102 * @param array $variables
103 * @return \Symfony\Component\Process\Process
104 */
105 protected function executeDumpProcess(Process $process, $output, array $variables)
106 {
107 try {
108 $process->setTimeout(null)->mustRun($output, $variables);
109 } catch (Exception $e) {
110 if (Str::contains($e->getMessage(), ['column-statistics', 'column_statistics'])) {
111 return $this->executeDumpProcess(Process::fromShellCommandLine(\str_replace(' --column-statistics=0', '', $process->getCommandLine())), $output, $variables);
112 }
113 if (\str_contains($e->getMessage(), 'set-gtid-purged')) {
114 return $this->executeDumpProcess(Process::fromShellCommandLine(\str_replace(' --set-gtid-purged=OFF', '', $process->getCommandLine())), $output, $variables);
115 }
116 throw $e;
117 }
118 return $process;
119 }
120 }
121