@@ -79,10 +79,10 @@ protected function createTables(): void
79
79
*/
80
80
private function unsetStatsExpiry ()
81
81
{
82
- $ isMariaDb = strpos ( $ this ->getDatabaseVariable ('version_comment ' ), ' MariaDB ' ) !== false ;
83
- $ version = $ this ->getDatabaseVariable ('version ' );
82
+ $ expiry = $ this ->getDatabaseVariable ('information_schema_stats_expiry ' ) ;
83
+ $ version = ( string ) $ this ->getDatabaseVariable ('version ' );
84
84
85
- if (! $ isMariaDb && version_compare ($ version , '8.0.0 ' , '>= ' ) && version_compare ( $ version , ' 10.0.0 ' , ' < ' )) {
85
+ if ($ expiry !== null && version_compare ($ version , '8.0.0 ' , '>= ' )) {
86
86
$ this ->getConnection ()->exec ('SET information_schema_stats_expiry=0; ' );
87
87
}
88
88
}
@@ -92,9 +92,9 @@ private function unsetStatsExpiry()
92
92
*
93
93
* @param string $variable The variable
94
94
*
95
- * @return string The value
95
+ * @return string|null The value
96
96
*/
97
- protected function getDatabaseVariable (string $ variable ): string
97
+ protected function getDatabaseVariable (string $ variable ): ? string
98
98
{
99
99
$ statement = $ this ->getConnection ()->prepare ('SHOW VARIABLES LIKE ? ' );
100
100
if (!$ statement || $ statement ->execute ([$ variable ]) === false ) {
@@ -104,7 +104,8 @@ protected function getDatabaseVariable(string $variable): string
104
104
$ row = $ statement ->fetch (PDO ::FETCH_ASSOC );
105
105
106
106
if ($ row === false ) {
107
- throw new UnexpectedValueException (sprintf ('Database variable not defined: %s ' , $ variable ));
107
+ // Database variable not defined
108
+ return null ;
108
109
}
109
110
110
111
return (string )$ row ['Value ' ];
0 commit comments