diff --git a/inc/media_rename/attachment_db_renamer.php b/inc/media_rename/attachment_db_renamer.php index 5d5d9aba..9e69d335 100644 --- a/inc/media_rename/attachment_db_renamer.php +++ b/inc/media_rename/attachment_db_renamer.php @@ -33,6 +33,13 @@ class Optml_Attachment_Db_Renamer { */ private $handle_image_sizes = false; + /** + * How many serialized values nested in strings are rewritten as data. + * + * Each level reads a copy of the string, so the cap bounds memory. + */ + private const MAX_NESTED_DEPTH = 3; + /** * Constructor */ @@ -180,7 +187,7 @@ private function process_column( $table, $column, $primary_keys, $old_url, $new_ // Check for serialized data $has_serialized = $wpdb->get_var( 'SELECT COUNT(' . esc_sql( $this->quote_identifier( $column ) ) . ') FROM ' . esc_sql( $this->quote_identifier( $table ) ) . - ' WHERE ' . esc_sql( $this->quote_identifier( $column ) ) . " REGEXP '^[aiO]:[1-9]' LIMIT 1" + ' WHERE ' . esc_sql( $this->quote_identifier( $column ) ) . " REGEXP '^[aiOCEs]:[0-9]' LIMIT 1" ); // Process with PHP if serialized data is found @@ -411,13 +418,18 @@ private function php_handle_column( $table, $column, $primary_keys, $old_url, $n private function replace_urls_in_value( $value, $old_url, $new_url ) { // Check if the value is serialized if ( $this->is_serialized( $value ) ) { - $unserialized = @unserialize( $value ); + $unserialized = $this->read_serialized( $value ); + if ( null === $unserialized ) { + return $value; + } - // If unserialize successful, process the data - if ( $unserialized !== false ) { - $replaced = $this->replace_in_data( $unserialized, $old_url, $new_url ); - return serialize( $replaced ); + // Plain text can start like a serialized string, such as `s:3:"foo"; see …`, and keeps its text after + // the first value. + if ( is_string( $unserialized ) && $this->has_text_after_string( trim( $value ) ) ) { + return $this->replace_image_urls( $value, $old_url, $new_url ); } + + return serialize( $this->replace_in_data( $unserialized, $old_url, $new_url, 0 ) ); } return $this->replace_image_urls( $value, $old_url, $new_url ); @@ -527,33 +539,160 @@ function ( $matches ) use ( $new_base, $new_domain, $new_dir, $new_ext ) { return $content; } + /** + * Check whether unserialized data holds an object other than stdClass, such as an incomplete object or an enum. + * + * @param mixed $data The unserialized data, without references. + * + * @return bool True when the data holds such an object. + */ + private function holds_other_objects( $data ): bool { + if ( is_object( $data ) && ! $data instanceof stdClass ) { + return true; + } + if ( is_array( $data ) || is_object( $data ) ) { + foreach ( $data as $value ) { + if ( $this->holds_other_objects( $value ) ) { + return true; + } + } + } + + return false; + } + /** * Recursively replace URLs in data structure * * @param mixed $data The data to process. * @param string $old_url Old URL. * @param string $new_url New URL. + * @param int $depth How many serialized strings hold this data. * * @return mixed The processed data */ - private function replace_in_data( $data, $old_url, $new_url ) { + private function replace_in_data( $data, $old_url, $new_url, int $depth ) { if ( is_array( $data ) ) { // Process arrays recursively foreach ( $data as $key => $value ) { - $data[ $key ] = $this->replace_in_data( $value, $old_url, $new_url ); + $data[ $key ] = $this->replace_in_data( $value, $old_url, $new_url, $depth ); } } elseif ( is_object( $data ) ) { // Process objects recursively foreach ( $data as $key => $value ) { - $data->$key = $this->replace_in_data( $value, $old_url, $new_url ); + $data->$key = $this->replace_in_data( $value, $old_url, $new_url, $depth ); } } elseif ( is_string( $data ) ) { - $data = $this->replace_image_urls( $data, $old_url, $new_url ); + $data = $this->replace_in_string( $data, $old_url, $new_url, $depth ); + } + + return $data; + } + + /** + * Replace URLs in a string read from serialized data. + * + * Plugins can store a serialized value in a string of another one. That value is rewritten as data, so its + * declared lengths stay right, but only when it reads back to the same text. A serialized value that cannot + * be read safely stays as stored, as at the top level. Other text that only starts like serialized data gets + * the plain replacement. + * + * @param string $value The string. + * @param string $old_url Old URL. + * @param string $new_url New URL. + * @param int $depth How many serialized strings hold the data this string is in. + * + * @return string The processed string. + */ + private function replace_in_string( string $value, string $old_url, string $new_url, int $depth ): string { + if ( $this->is_serialized( $value ) ) { + $inner = $this->read_serialized( $value ); + if ( null === $inner ) { + return $value; + } + if ( $this->reads_back( $inner, $value ) ) { + // Past the cap the value is kept as stored, because a text replacement would break its lengths. + return $depth < self::MAX_NESTED_DEPTH ? serialize( $this->replace_in_data( $inner, $old_url, $new_url, $depth + 1 ) ) : $value; + } + } + + return $this->replace_image_urls( $value, $old_url, $new_url ); + } + + /** + * Read a serialized value when the URL walk can rewrite it safely. + * + * The value is left as stored when this returns null: + * - It has references (r: or R:), which can point back at their own value, so the walk cannot end. + * - It cannot be read, such as one naming an enum that is not loaded. + * - It holds an object other than stdClass. Such an object read without its class could not be written back + * unchanged, and an enum cannot change. + * A raw text replacement would break its declared lengths. + * + * @param string $value The serialized value. + * + * @return mixed|null The data, or null when the value is left as stored. + */ + private function read_serialized( string $value ) { + if ( preg_match( '/[;{][rR]:\d+;/', $value ) ) { + return null; + } + + // Any table can hold the URL, including values visitors write, so stored data must not create objects + // whose class runs code. + $data = @unserialize( $value, [ 'allowed_classes' => [ 'stdClass' ] ] ); + if ( false === $data || $this->holds_other_objects( $data ) ) { + return null; } return $data; } + /** + * Check whether text follows the first value of a serialized string, which unserialize() ignores. + * + * Lengths can have leading zeros, such as `s:027:"…";`, which serialize() does not write. + * + * @param string $value A serialized string that unserializes. + * + * @return bool True when text follows the string. + */ + private function has_text_after_string( string $value ): bool { + preg_match( '/^s:(\d+):"/', $value, $matches ); + + return strlen( $value ) > strlen( $matches[0] ) + (int) $matches[1] + 2; + } + + /** + * Check whether unserialized data serializes back to the stored text. + * + * Floats were written with 17 digits, such as `d:0.10000000000000001;`, by PHP 7.0 and earlier or with that + * setting, and in the shortest form since, so both precisions are tried. Lengths can have leading zeros, + * such as `s:062:"…";`, which serialize() does not write. + * + * @param mixed $data The unserialized data. + * @param string $stored The stored text. + * + * @return bool True when the data serializes to the stored text. + */ + private function reads_back( $data, string $stored ): bool { + $unpadded = preg_replace( '/(^|[;{}])([saOCE]):0+(?=\d)/', '$1$2:', $stored ); + $precision = ini_get( 'serialize_precision' ); + + try { + foreach ( [ $precision, '17', '-1' ] as $try ) { + ini_set( 'serialize_precision', $try ); + if ( in_array( serialize( $data ), [ $stored, $unpadded ], true ) ) { + return true; + } + } + } finally { + ini_set( 'serialize_precision', $precision ); + } + + return false; + } + /** * Check if a string is serialized * @@ -594,6 +733,8 @@ private function is_serialized( $data ) { // Fall through case 'a': case 'O': + case 'C': + case 'E': case 'i': case 'd': return (bool) preg_match( "/^{$token}:[0-9]+:/", $data ); diff --git a/tests/media_rename/test-db-renamer.php b/tests/media_rename/test-db-renamer.php index 34776908..c3233b56 100644 --- a/tests/media_rename/test-db-renamer.php +++ b/tests/media_rename/test-db-renamer.php @@ -445,6 +445,331 @@ public function test_replace_updates_serialized_user_meta(): void { $this->assertSame( [ 'url' => $new_url ], get_user_meta( $user_id, 'optml_test_avatar', true ) ); } + public function test_replace_keeps_stored_objects_of_other_classes_unchanged(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/object-photo.jpg'; + $stored = 'O:' . strlen( Optml_Test_Renamer_Stored_Object::class ) . ':"' . Optml_Test_Renamer_Stored_Object::class . '":1:{s:3:"url";s:' . strlen( $old_url ) . ':"' . $old_url . '";}'; + $comment_id = self::factory()->comment->create( + [ + 'comment_post_ID' => self::$post_id, + 'comment_content' => $stored, + ] + ); + Optml_Test_Renamer_Stored_Object::$woken = false; + + self::$replacer->replace( $old_url, 'http://om-wp.test/wp-content/uploads/2026/10/object-renamed.jpg' ); + clean_comment_cache( $comment_id ); + + $this->assertFalse( Optml_Test_Renamer_Stored_Object::$woken, 'The stored object must not be created.' ); + $this->assertSame( $stored, get_comment( $comment_id )->comment_content ); + } + + public function test_replace_keeps_values_with_custom_serialized_objects_unchanged(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/custom-photo.jpg'; + // An array with the URL next to an object in the Serializable format, whose payload only its class can read. + $stored = 'a:2:{s:5:"image";s:' . strlen( $old_url ) . ':"' . $old_url . '";s:6:"widget";C:21:"Optml_Test_Not_Loaded":7:{payload}}'; + $comment_id = self::factory()->comment->create( + [ + 'comment_post_ID' => self::$post_id, + 'comment_content' => $stored, + ] + ); + + self::$replacer->replace( $old_url, 'http://om-wp.test/wp-content/uploads/2026/10/custom-renamed.jpg' ); + clean_comment_cache( $comment_id ); + + $this->assertSame( $stored, get_comment( $comment_id )->comment_content ); + } + + public function test_replace_updates_serialized_std_class(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/std-photo.jpg'; + $new_url = 'http://om-wp.test/wp-content/uploads/2026/10/std-renamed.jpg'; + update_post_meta( self::$post_id, 'optml_test_object', (object) [ 'image' => $old_url ] ); + + self::$replacer->replace( $old_url, $new_url ); + wp_cache_flush(); + + $this->assertEquals( (object) [ 'image' => $new_url ], get_post_meta( self::$post_id, 'optml_test_object', true ) ); + } + + public function test_replace_keeps_a_std_class_that_refers_to_itself_unchanged(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/cycle-photo.jpg'; + $value = (object) [ 'image' => $old_url ]; + $value->self = $value; + $stored = serialize( $value ); + $comment_id = self::factory()->comment->create( + [ + 'comment_post_ID' => self::$post_id, + 'comment_content' => $stored, + ] + ); + + self::$replacer->replace( $old_url, 'http://om-wp.test/wp-content/uploads/2026/10/cycle-renamed.jpg' ); + clean_comment_cache( $comment_id ); + + $this->assertSame( $stored, get_comment( $comment_id )->comment_content ); + } + + public function test_replace_keeps_a_custom_serialized_object_unchanged(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/custom-top-photo.jpg'; + $payload = '{' . $old_url . '}'; + $stored = 'C:21:"Optml_Test_Not_Loaded":' . ( strlen( $payload ) - 2 ) . ':' . $payload; + $comment_id = self::factory()->comment->create( + [ + 'comment_post_ID' => self::$post_id, + 'comment_content' => $stored, + ] + ); + + self::$replacer->replace( $old_url, 'http://om-wp.test/wp-content/uploads/2026/10/custom-top-renamed.jpg' ); + clean_comment_cache( $comment_id ); + + $this->assertSame( $stored, get_comment( $comment_id )->comment_content ); + } + + public function test_replace_keeps_a_custom_serialized_object_next_to_other_serialized_rows_unchanged(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/custom-mixed-photo.jpg'; + $payload = '{' . $old_url . '}'; + $stored = 'C:21:"Optml_Test_Not_Loaded":' . ( strlen( $payload ) - 2 ) . ':' . $payload; + // Another row in the column that starts like an array, so the column is read row by row in PHP. + self::factory()->comment->create( + [ + 'comment_post_ID' => self::$post_id, + 'comment_content' => serialize( [ 'image' => $old_url ] ), + ] + ); + $comment_id = self::factory()->comment->create( + [ + 'comment_post_ID' => self::$post_id, + 'comment_content' => $stored, + ] + ); + + self::$replacer->replace( $old_url, 'http://om-wp.test/wp-content/uploads/2026/10/custom-mixed-renamed.jpg' ); + clean_comment_cache( $comment_id ); + + $this->assertSame( $stored, get_comment( $comment_id )->comment_content ); + } + + public function test_replace_keeps_values_with_an_enum_that_is_not_loaded_unchanged(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/enum-photo.jpg'; + $stored = 'a:2:{s:5:"image";s:' . strlen( $old_url ) . ':"' . $old_url . '";s:4:"kind";E:20:"Optml_Test_No_Enum:A";}'; + $comment_id = self::factory()->comment->create( + [ + 'comment_post_ID' => self::$post_id, + 'comment_content' => $stored, + ] + ); + + self::$replacer->replace( $old_url, 'http://om-wp.test/wp-content/uploads/2026/10/enum-renamed.jpg' ); + clean_comment_cache( $comment_id ); + + $this->assertSame( $stored, get_comment( $comment_id )->comment_content ); + } + + public function test_replace_updates_serialized_text_that_looks_like_an_object(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/text-photo.jpg'; + $new_url = 'http://om-wp.test/wp-content/uploads/2026/10/text-renamed.jpg'; + update_post_meta( self::$post_id, 'optml_test_notes', [ 'image' => $old_url, 'note' => 'O:4:"Test":0:{}' ] ); + + self::$replacer->replace( $old_url, $new_url ); + wp_cache_flush(); + + $this->assertSame( [ 'image' => $new_url, 'note' => 'O:4:"Test":0:{}' ], get_post_meta( self::$post_id, 'optml_test_notes', true ) ); + } + + public function test_replace_updates_a_serialized_string_inside_a_serialized_option(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/nested-photo.jpg'; + $new_url = 'http://om-wp.test/wp-content/uploads/2026/10/nested-renamed-photo.jpg'; + update_option( 'optml_test_nested', [ 'data' => serialize( [ 'url' => $old_url ] ) ] ); + + self::$replacer->replace( $old_url, $new_url ); + wp_cache_flush(); + + $this->assertSame( [ 'url' => $new_url ], unserialize( get_option( 'optml_test_nested' )['data'] ) ); + } + + public function test_replace_keeps_serialized_strings_past_the_nesting_cap_as_stored(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/deep-photo.jpg'; + $new_url = 'http://om-wp.test/wp-content/uploads/2026/10/deep-renamed-photo.jpg'; + $deepest = serialize( [ 'url' => $old_url ] ); + $value = $deepest; + for ( $level = 0; $level < 3; $level++ ) { + $value = serialize( [ 'data' => $value, 'url' => $old_url ] ); + } + update_option( 'optml_test_deep', [ 'data' => $value, 'url' => $old_url ] ); + + self::$replacer->replace( $old_url, $new_url ); + wp_cache_flush(); + + // Three nested levels are rewritten, and the fourth stays as stored. + $stored = get_option( 'optml_test_deep' ); + for ( $level = 0; $level < 3; $level++ ) { + $stored = unserialize( $stored['data'] ); + $this->assertSame( $new_url, $stored['url'] ); + } + $this->assertSame( $deepest, $stored['data'] ); + } + + public function test_replace_does_not_create_objects_nested_in_strings(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/nested-object-photo.jpg'; + $object = 'O:' . strlen( Optml_Test_Renamer_Stored_Object::class ) . ':"' . Optml_Test_Renamer_Stored_Object::class . '":1:{s:3:"url";s:' . strlen( $old_url ) . ':"' . $old_url . '";}'; + update_option( 'optml_test_nested_object', [ 'data' => $object, 'url' => $old_url ] ); + Optml_Test_Renamer_Stored_Object::$woken = false; + + self::$replacer->replace( $old_url, 'http://om-wp.test/wp-content/uploads/2026/10/nested-object-renamed.jpg' ); + wp_cache_flush(); + + $this->assertFalse( Optml_Test_Renamer_Stored_Object::$woken, 'The nested object must not be created.' ); + $this->assertSame( $object, get_option( 'optml_test_nested_object' )['data'] ); + } + + public function test_replace_updates_nested_text_that_starts_like_a_serialized_string(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/note-photo.jpg'; + $new_url = 'http://om-wp.test/wp-content/uploads/2026/10/note-renamed-photo.jpg'; + update_option( + 'optml_test_note', + [ + 'note' => 's:3:"foo"; see "' . $old_url . '";', + 'data' => serialize( [ 'url' => $old_url ] ), + ] + ); + + self::$replacer->replace( $old_url, $new_url ); + wp_cache_flush(); + + $stored = get_option( 'optml_test_note' ); + $this->assertSame( 's:3:"foo"; see "' . $new_url . '";', $stored['note'] ); + $this->assertSame( [ 'url' => $new_url ], unserialize( $stored['data'] ) ); + } + + public function test_replace_keeps_nested_values_it_cannot_read_safely_as_stored(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/nested-unsafe-photo.jpg'; + $new_url = 'http://om-wp.test/wp-content/uploads/2026/10/nested-unsafe-renamed.jpg'; + $url = 's:3:"url";s:' . strlen( $old_url ) . ':"' . $old_url . '";'; + $custom = 'a:2:{' . $url . 's:6:"widget";C:21:"Optml_Test_Not_Loaded":7:{payload}}'; + $enum = 'a:2:{' . $url . 's:4:"kind";E:20:"Optml_Test_No_Enum:A";}'; + update_option( + 'optml_test_nested_unsafe', + [ + 'custom' => $custom, + 'enum' => $enum, + 'url' => $old_url, + ] + ); + + self::$replacer->replace( $old_url, $new_url ); + wp_cache_flush(); + + $this->assertSame( + [ + 'custom' => $custom, + 'enum' => $enum, + 'url' => $new_url, + ], + get_option( 'optml_test_nested_unsafe' ) + ); + } + + public function test_replace_updates_columns_whose_only_serialized_values_have_padded_lengths(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/padded-photo.jpg'; + $new_url = 'http://om-wp.test/wp-content/uploads/2026/10/padded-renamed-photo.jpg'; + $comment_id = self::factory()->comment->create( + [ + 'comment_post_ID' => self::$post_id, + 'comment_content' => 's:0' . strlen( $old_url ) . ':"' . $old_url . '";', + ] + ); + + self::$replacer->replace( $old_url, $new_url ); + clean_comment_cache( $comment_id ); + + $this->assertSame( $new_url, unserialize( get_comment( $comment_id )->comment_content ) ); + } + + public function test_replace_updates_nested_values_with_padded_lengths(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/nested-padded-photo.jpg'; + $new_url = 'http://om-wp.test/wp-content/uploads/2026/10/nested-padded-renamed.jpg'; + update_option( 'optml_test_nested_padded', [ 'data' => 'a:1:{s:3:"url";s:0' . strlen( $old_url ) . ':"' . $old_url . '";}' ] ); + + self::$replacer->replace( $old_url, $new_url ); + wp_cache_flush(); + + $this->assertSame( [ 'url' => $new_url ], unserialize( get_option( 'optml_test_nested_padded' )['data'] ) ); + } + + public function test_replace_updates_nested_floats_when_the_site_uses_precision_17(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/precision-photo.jpg'; + $new_url = 'http://om-wp.test/wp-content/uploads/2026/10/precision-renamed-photo.jpg'; + $precision = ini_get( 'serialize_precision' ); + update_option( 'optml_test_precision', [ 'data' => 'a:2:{s:3:"url";s:' . strlen( $old_url ) . ':"' . $old_url . '";s:5:"ratio";d:0.1;}' ] ); + + ini_set( 'serialize_precision', '17' ); + try { + self::$replacer->replace( $old_url, $new_url ); + $this->assertSame( '17', ini_get( 'serialize_precision' ) ); + } finally { + ini_set( 'serialize_precision', $precision ); + } + wp_cache_flush(); + + $this->assertSame( [ 'url' => $new_url, 'ratio' => 0.1 ], unserialize( get_option( 'optml_test_precision' )['data'] ) ); + } + + public function test_replace_keeps_nested_values_with_references_as_stored(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/nested-reference-photo.jpg'; + $new_url = 'http://om-wp.test/wp-content/uploads/2026/10/nested-reference-renamed.jpg'; + $inner = 'O:8:"stdClass":2:{s:3:"url";s:' . strlen( $old_url ) . ':"' . $old_url . '";s:4:"self";r:1;}'; + // The escaped string format hides the reference from the check on the outer value. + $escaped = str_replace( ';', '\\3b', $inner ); + $comment_id = self::factory()->comment->create( + [ + 'comment_post_ID' => self::$post_id, + 'comment_content' => 'a:2:{s:3:"url";s:' . strlen( $old_url ) . ':"' . $old_url . '";s:4:"data";S:' . strlen( $inner ) . ':"' . $escaped . '";}', + ] + ); + + self::$replacer->replace( $old_url, $new_url ); + clean_comment_cache( $comment_id ); + + $this->assertSame( [ 'url' => $new_url, 'data' => $inner ], unserialize( get_comment( $comment_id )->comment_content ) ); + } + + public function test_replace_updates_nested_values_with_old_float_precision(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/float-photo.jpg'; + $new_url = 'http://om-wp.test/wp-content/uploads/2026/10/float-renamed-photo.jpg'; + update_option( 'optml_test_float', [ 'data' => 'a:2:{s:3:"url";s:' . strlen( $old_url ) . ':"' . $old_url . '";s:5:"ratio";d:0.10000000000000001;}' ] ); + $precision = ini_get( 'serialize_precision' ); + + self::$replacer->replace( $old_url, $new_url ); + wp_cache_flush(); + + $this->assertSame( $precision, ini_get( 'serialize_precision' ) ); + $this->assertSame( [ 'url' => $new_url, 'ratio' => 0.1 ], unserialize( get_option( 'optml_test_float' )['data'] ) ); + } + + public function test_replace_updates_columns_whose_only_serialized_values_are_strings(): void { + $old_url = 'http://om-wp.test/wp-content/uploads/2026/10/string-photo.jpg'; + $new_url = 'http://om-wp.test/wp-content/uploads/2026/10/string-renamed-photo.jpg'; + $string = self::factory()->comment->create( + [ + 'comment_post_ID' => self::$post_id, + 'comment_content' => serialize( 'see ' . $old_url ), + ] + ); + $text = self::factory()->comment->create( + [ + 'comment_post_ID' => self::$post_id, + 'comment_content' => 's:3:"foo"; see "' . $old_url . '";', + ] + ); + + self::$replacer->replace( $old_url, $new_url ); + clean_comment_cache( [ $string, $text ] ); + + $this->assertSame( 'see ' . $new_url, unserialize( get_comment( $string )->comment_content ) ); + $this->assertSame( 's:3:"foo"; see "' . $new_url . '";', get_comment( $text )->comment_content ); + } + public function test_replace_updates_size_variants_in_serialized_meta(): void { update_post_meta( self::$post_id, 'optml_test_thumbnail', [ 'image' => 'http://om-wp.test/wp-content/uploads/2026/10/sized-photo-300x200.jpg' ] ); @@ -574,3 +899,26 @@ public function prepare( $query, ...$args ) { return parent::prepare( str_replace( '%i', '%%i', $query ), ...$args ); } } + +/** + * A class whose code runs when a stored value creates it. + */ +class Optml_Test_Renamer_Stored_Object { + /** + * Whether a stored value created an instance. + * + * @var bool + */ + public static $woken = false; + + /** + * URL the stored value carries. + * + * @var string + */ + public $url = ''; + + public function __wakeup() { + self::$woken = true; + } +}