Index: tests/option/transient.php
===================================================================
--- tests/option/transient.php	(revision 1169)
+++ tests/option/transient.php	(working copy)
@@ -33,4 +33,66 @@
 		$this->assertEquals( $value, get_transient( $key ) );
 		$this->assertTrue( delete_transient( $key ) );
 	}
+
+	/**
+	 * Test for problems with a long transient base key and a longer 
+	 * key that starts with the base key.
+	 *
+	 * @ticket 15058
+	 **/
+	function test_long_and_longer_transient_key() {
+		$base_key = str_repeat('-', 45);
+		$base_value = rand_str();
+		
+		foreach ( array( 44, 45, 53, 65, 255, 256, 257 ) as $length ) {
+			wp_cache_flush();
+			set_transient( $base_key, $base_value );
+			$key = $base_key . $length;
+			$key = str_pad( $key, $length, "-", STR_PAD_LEFT );
+			$value = rand_str();
+			$transient_result = set_transient( $key, $value );
+			wp_cache_flush();
+			$this->assertEquals( $base_value, get_transient( $base_key ),
+				"Base key should remain the same at len $length" );
+			if ( $transient_result ) {
+				$this->assertEquals( $value, get_transient( $key ),
+					"Long key should remain the same at len $length" );
+			}
+		}
+	}
+
+	/**
+	 * Test for problems with two transient keys of equivalent length.
+	 *
+	 * @ticket 15058
+	 **/
+	function test_long_transient_keys() {
+		foreach ( array( 44, 45, 53, 65, 255, 256, 257 ) as $length ) {
+			$key1 = rand_str( 32 ) . "X";
+			$key1 = str_pad( $key1, $length, "-", STR_PAD_LEFT );
+			$key1 = substr( $key1, 0, $length );
+			
+			// Second key: Replace the last character to detect truncation
+			$key2 = substr( $key1, 0, $length - 1 ) . "Y";
+
+			$value1 = rand_str();
+			$value2 = rand_str();
+
+			$transient_result = set_transient( $key1, $value1 );
+			if ($transient_result) {
+				$transient_result2 = set_transient( $key2, $value2 );
+				if ($transient_result2) {
+					wp_cache_flush();
+					$this->assertEquals( $value1, get_transient( $key1 ),
+						"Length $length, first transient should work" );
+					$this->assertEquals( $value2, get_transient( $key2 ),
+						"Length $length, second transient should work" );
+				}
+			}
+			else {
+				$this->assertFalse( get_transient( $key1 ),
+					"transient keylen $length set failed, get should fail" );
+			}
+		}
+	}
 }
