epts an array. * @return bool True if of type, False if not */ private function is_type( $type = '' ) { // If string, cast to array if ( is_string( $type ) ) { $type = (array) $type; } // Make them lowercase $types = array_map( 'strtolower', $type ); // Return if match or not return (bool) in_array( strtolower( $this->type ), $types, true ); } /** Private Sanitizers ****************************************************/ /** * Sanitize capabilities array * * @since 1.0.0 * @param array $caps Default empty array. * @return array */ private function sanitize_capabilities( $caps = array() ) { return wp_parse_args( $caps, array( 'select' => 'exist', 'insert' => 'exist', 'update' => 'exist', 'delete' => 'exist' ) ); } /** * Sanitize aliases array using `sanitize_key()` * * @since 1.0.0 * @param array $aliases Default empty array. * @return array */ private function sanitize_aliases( $aliases = array() ) { return array_map( 'sanitize_key', $aliases ); } /** * Sanitize relationships array * * @todo * @since 1.0.0 * @param array $relationships Default empty array. * @return array */ private function sanitize_relationships( $relationships = array() ) { return array_filter( $relationships ); } /** * Sanitize the default value * * @since 1.0.0 * @param string $default * @return string|null */ private function sanitize_default( $default = '' ) { // Null if ( ( true === $this->allow_null ) && is_null( $default ) ) { return null; // String } elseif ( is_string( $default ) ) { return wp_kses_data( $default ); // Integer } elseif ( $this->is_numeric() ) { return (int) $default; } // @todo datetime, decimal, and other column types // Unknown, so return the default's default return ''; } /** * Sanitize the pattern * * @since 1.0.0 * @param string $pattern * @return string */ private function sanitize_pattern( $pattern = '%s' ) { // Allowed patterns $allowed_patterns = array( '%s', '%d', '%f' ); // Return pattern if allowed if ( in_array( $pattern, $allowed_patterns, true ) ) { return $pattern; } // Fallback to digit or string return $this->is_numeric() ? '%d' : '%s'; } /** * Sanitize the validation callback * * @since 1.0.0 * @param string $callback Default empty string. A callable PHP function name or method * @return string The most appropriate callback function for the value */ private function sanitize_validation( $callback = '' ) { // Return callback if it's callable if ( is_callable( $callback ) ) { return $callback; } // UUID special column if ( true === $this->uuid ) { $callback = array( $this, 'validate_uuid' ); // Datetime fallback } elseif ( $this->is_type( 'datetime' ) ) { $callback = array( $this, 'validate_datetime' ); // Decimal fallback } elseif ( $this->is_type( 'decimal' ) ) { $callback = array( $this, 'validate_decimal' ); // Intval fallback } elseif ( $this->is_numeric() ) { $callback = 'intval'; } // Return the callback return $callback; } /** Public Validators *****************************************************/ /** * Fallback to validate a datetime value if no other is set. * * This assumes NO_ZERO_DATES is off or overridden. * * If MySQL drops support for zero dates, this method will need to be * updated to support different default values based on the environment. * * @since 1.0.0 * @param string $value Default ''. A datetime value that needs validating * @return string A valid datetime value */ public function validate_datetime( $value = '' ) { // Handle "empty" values if ( empty( $value ) || ( '0000-00-00 00:00:00' === $value ) ) { $value = ! empty( $this->default ) ? $this->default : ''; // Convert to MySQL datetime format via gmdate() && strtotime } elseif ( function_exists( 'gmdate' ) ) { $value = gmdate( 'Y-m-d H:i:s', strtotime( $value ) ); } // Return the validated value return $value; } /** * Validate a decimal * * (Recommended decimal column length is '18,9'.) * * This is used to validate a mixed value before it is saved into a decimal * column in a database table. * * Uses number_format() which does rounding to the last decimal if your * value is longer than specified. * * @since 1.0.0 * @param mixed $value Default empty string. The decimal value to validate * @param int $decimals Default 9. The number of decimal points to accept * @return float */ public function validate_decimal( $value = 0, $decimals = 9 ) { // Protect against non-numeric values if ( ! is_numeric( $value ) ) { $value = 0; } // Protect against non-numeric decimals if ( ! is_numeric( $decimals ) ) { $decimals = 9; } // Is the value negative? $negative_exponent = ( $value < 0 ) ? -1 : 1; // Only numbers and period $value = preg_replace( '/[^0-9\.]/', '', (string) $value ); // Format to number of decimals, and cast as float $formatted = number_format( $value, $decimals, '.', '' ); // Adjust for negative values $retval = $formatted * $negative_exponent; // Return return $retval; } /** * Validate a UUID. * * This uses the v4 algorithm to generate a UUID that is used to uniquely * and universally identify a given database row without any direct * connection or correlation to the data in that row. * * From http://php.net/manual/en/function.uniqid.php#94959 * * @since 1.0.0 * @param string $value The UUID value (empty on insert, string on update) * @return string Generated UUID. */ public function validate_uuid( $value = '' ) { // Default URN UUID prefix $prefix = 'urn:uuid:'; // Bail if not empty and correctly prefixed // (UUIDs should _never_ change once they are set) if ( ! empty( $value ) && ( 0 === strpos( $value, $prefix ) ) ) { return $value; } // Put the pieces together $value = sprintf( "{$prefix}%04x%04x-%04x-%04x-%04x-%04x%04x%04x", // 32 bits for "time_low" mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), // 16 bits for "time_mid" mt_rand( 0, 0xffff ), // 16 bits for "time_hi_and_version", // four most significant bits holds version number 4 mt_rand( 0, 0x0fff ) | 0x4000, // 16 bits, 8 bits for "clk_seq_hi_res", // 8 bits for "clk_seq_low", // two most significant bits holds zero and one for variant DCE1.1 mt_rand( 0, 0x3fff ) | 0x8000, // 48 bits for "node" mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) ); // Return the new UUID return $value; } /** Table Helpers *********************************************************/ /** * Return a string representation of what this column's properties look like * in a MySQL. * * @todo * @since 1.0.0 * @return string */ public function get_create_string() { // Default return val $retval = ''; // Bail if no name if ( ! empty( $this->name ) ) { $retval .= $this->name; } // Type if ( ! empty( $this->type ) ) { $retval .= " {$this->type}"; } // Length if ( ! empty( $this->length ) ) { $retval .= '(' . $this->length . ')'; } // Unsigned if ( ! empty( $this->unsigned ) ) { $retval .= " unsigned"; } // Zerofill if ( ! empty( $this->zerofill ) ) { // TBD } // Binary if ( ! empty( $this->binary ) ) { // TBD } // Allow null if ( ! empty( $this->allow_null ) ) { $retval .= " NOT NULL "; } // Default if ( ! empty( $this->default ) ) { $retval .= " default '{$this->default}'"; // A literal false means no default value } elseif ( false !== $this->default ) { // Numeric if ( $this->is_numeric() ) { $retval .= " default '0'"; } elseif ( $this->is_type( 'datetime' ) ) { $retval .= " default '0000-00-00 00:00:00'"; } else { $retval .= " default ''"; } } // Extra if ( ! empty( $this->extra ) ) { $retval .= " {$this->extra}"; } // Encoding if ( ! empty( $this->encoding ) ) { } else { } // Collation if ( ! empty( $this->collation ) ) { } else { } // Return the create string return $retval; } }
Fatal error: Uncaught Error: Class 'WP_Rocket\Dependencies\Database\Column' not found in /home/merciket/public_html/wp-content/plugins/wp-rocket/inc/Dependencies/Database/Schema.php:54 Stack trace: #0 /home/merciket/public_html/wp-content/plugins/wp-rocket/inc/Dependencies/Database/Query.php(407): WP_Rocket\Dependencies\Database\Schema->__construct() #1 /home/merciket/public_html/wp-content/plugins/wp-rocket/inc/Dependencies/Database/Query.php(326): WP_Rocket\Dependencies\Database\Query->set_columns() #2 /home/merciket/public_html/wp-content/plugins/wp-rocket/inc/Engine/Preload/Database/Queries/Cache.php(111): WP_Rocket\Dependencies\Database\Query->__construct(Array) #3 [internal function]: WP_Rocket\Engine\Preload\Database\Queries\Cache->__construct(Object(WP_Rocket\Logger\Logger)) #4 /home/merciket/public_html/wp-content/plugins/wp-rocket/inc/Dependencies/League/Container/Definition/Definition.php(256): ReflectionClass->newInstanceArgs(Array) #5 /home/merciket/public_html/wp-content/plugins/wp-rocket/inc/Dependencies/Le in /home/merciket/public_html/wp-content/plugins/wp-rocket/inc/Dependencies/Database/Schema.php on line 54