wp/wp-includes/class-wp.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
--- a/wp/wp-includes/class-wp.php	Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-includes/class-wp.php	Wed Sep 21 18:19:35 2022 +0200
@@ -83,7 +83,7 @@
 	public $did_permalink = false;
 
 	/**
-	 * Add name to list of public query variables.
+	 * Adds a query variable to the list of public query variables.
 	 *
 	 * @since 2.1.0
 	 *
@@ -107,7 +107,7 @@
 	}
 
 	/**
-	 * Set the value of a query variable.
+	 * Sets the value of a query variable.
 	 *
 	 * @since 2.3.0
 	 *
@@ -119,7 +119,7 @@
 	}
 
 	/**
-	 * Parse request to find correct WordPress query.
+	 * Parses the request to find the correct WordPress query.
 	 *
 	 * Sets up the query variables based on the request. There are also many
 	 * filters and actions that can be used to further manipulate the result.
@@ -405,9 +405,14 @@
 		if ( is_user_logged_in() ) {
 			$headers = array_merge( $headers, wp_get_nocache_headers() );
 		} elseif ( ! empty( $_GET['unapproved'] ) && ! empty( $_GET['moderation-hash'] ) ) {
-			// Unmoderated comments are only visible for one minute via the moderation hash.
-			$headers['Expires']       = gmdate( 'D, d M Y H:i:s', time() + MINUTE_IN_SECONDS );
-			$headers['Cache-Control'] = 'max-age=60, must-revalidate';
+			// Unmoderated comments are only visible for 10 minutes via the moderation hash.
+			$expires = 10 * MINUTE_IN_SECONDS;
+
+			$headers['Expires']       = gmdate( 'D, d M Y H:i:s', time() + $expires );
+			$headers['Cache-Control'] = sprintf(
+				'max-age=%d, must-revalidate',
+				$expires
+			);
 		}
 		if ( ! empty( $this->query_vars['error'] ) ) {
 			$status = (int) $this->query_vars['error'];
@@ -485,7 +490,7 @@
 		 * @since 2.8.0
 		 *
 		 * @param string[] $headers Associative array of headers to be sent.
-		 * @param WP       $this    Current WordPress environment instance.
+		 * @param WP       $wp      Current WordPress environment instance.
 		 */
 		$headers = apply_filters( 'wp_headers', $headers, $this );
 
@@ -597,8 +602,8 @@
 			$GLOBALS['single'] = 1;
 		}
 
-		if ( $wp_query->is_author() && isset( $wp_query->post ) ) {
-			$GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author );
+		if ( $wp_query->is_author() ) {
+			$GLOBALS['authordata'] = get_userdata( get_queried_object_id() );
 		}
 	}