Index: plugin.php
===================================================================
--- plugin.php	(revision 8399)
+++ plugin.php	(working copy)
@@ -7,25 +7,24 @@
  */
 
 /**
- * plugin_get_contents() - Retrieve enough of the plugin file to get plugin data.
+ * Retrieve enough of the plugin file to get plugin data.
  *
  * Some users have issues with opening large files and manipulating the
  * contents for want is usually the first 1kiB or 2kiB. This function
  * stops pulling in the plugin contents when it has all of the required
  * plugin data.
  *
- * It also adds a little bit of padding for fudging the version info
- * and to make sure that we grab absolutely everything, in case of a
- * long description.
+ * The first 8kiB of the file will be pulled in and if the plugin data is not
+ * within that first 8kiB, then the plugin author should correct their plugin
+ * and move the plugin data headers to the top.
  *
  * The plugin file is assumed to have permissions to allow for scripts to
  * read the file. This is not checked however and the file is only opened
  * for reading.
  *
  * @link http://trac.wordpress.org/ticket/5651 Purpose of function.
+ * @link http://trac.wordpress.org/ticket/7372 Optimization of function.
  * @since 2.7.0
- * @uses plugin_has_required_fields() Checks for all of the required plugin
- *		data fields.
  *
  * @param string $plugin_file Path to plugin file to open
  * @return string Plugin file contents retrieved
@@ -35,50 +34,17 @@
 	// We don't need to write to the file, so just open for reading.
 	$fp = fopen($plugin_file, 'r');
 
-	// Store the contents of the plugin file here.
-	$contents = '';
+	// Pull only the first 8kiB of the file in.
+	$contents = fread( $fp, 8192 );
 
-	// Keep reading the contents of the file until End of File is
-	// reached, or we grabbed all of the required plugin data.
-	while( !feof($fp) && !plugin_has_required_fields($contents) )
-		$contents .= fread( $fp, 1024 );
-
-	// Make sure that any padding is adding for long descriptions
-	// and grabbing any optional plugin data, not checked for.
-	if( !feof($fp) )
-		$contents .= fread( $fp, 512 );
-
 	// PHP will close file handle, but we are good citizens
 	fclose($fp);
 	return $contents;
 }
 
 /**
- * plugin_has_required_fields() - Checks plugin contents for required plugin data
+ * Parse the plugin contents to retrieve plugin's metadata.
  *
- * @since 2.7.0
- * @usedby plugin_get_contents()
- *
- * @param string $plugin_contents Plugin file contents
- * @return bool Whether contents has all plugin data.
- */
-function plugin_has_required_fields($plugin_contents) {
-	$hasName = stripos($plugin_contents, 'plugin name:');
-	$hasPluginURI = stripos($plugin_contents, 'plugin uri:');
-	$hasDescription = stripos($plugin_contents, 'description:');
-	$hasAuthor = stripos($plugin_contents, 'author:');
-	$hasAuthorURI = stripos($plugin_contents, 'author uri:');
-
-	if( false !== $hasName && false !== $hasPluginURI && false !== $hasDescription &&
-		false !== $hasAuthor && false !== $hasAuthorURI)
-		return true;
-
-	return false;
-}
-
-/**
- * get_plugin_data() - Parse the plugin contents to retrieve plugin's metadata
- *
  * The metadata of the plugin's data searches for the following in the plugin's
  * header.
  *
@@ -104,8 +70,12 @@
  *		'Title' - Title of the plugin and the link to the plugin's web site.
  *		'Description' - Description of what the plugin does and/or notes
  *		from the author.
- *		'Author' - The author's name and web site link.
+ *		'Author' - The author's name
+ *		'AuthorURI' - The authors web site address.
  *		'Version' - The plugin version number.
+ *		'PluginURI' - Plugin web site address.
+ *		'TextDomain' - Plugin's text domain for localization.
+ *		'DomainPath' - Plugin's relative directory path to .mo files.
  *
  * @param string $plugin_file Path to the plugin file
  * @return array See above for description.

