Commit 75e4a3ace19 for woocommerce

commit 75e4a3ace195c30fd2dffd4f4a5bfc4b3dfffc16
Author: Viktor Szépe <viktor@szepe.net>
Date:   Fri Mar 13 18:54:33 2026 +0100

    Fix undefined variable in robots_txt method (#63589)

    Co-authored-by: Néstor Soriano <konamiman@konamiman.com>

diff --git a/plugins/woocommerce/changelog/pr-63589 b/plugins/woocommerce/changelog/pr-63589
new file mode 100644
index 00000000000..e4252bfe0b7
--- /dev/null
+++ b/plugins/woocommerce/changelog/pr-63589
@@ -0,0 +1,4 @@
+Significance: minor
+Type: fix
+
+Fix undefined site_url variable in robots_txt
diff --git a/plugins/woocommerce/includes/class-woocommerce.php b/plugins/woocommerce/includes/class-woocommerce.php
index 8d34da0b9de..a6df85da6e7 100644
--- a/plugins/woocommerce/includes/class-woocommerce.php
+++ b/plugins/woocommerce/includes/class-woocommerce.php
@@ -1180,7 +1180,8 @@ final class WooCommerce {
 	 * @internal For exclusive usage of WooCommerce core, backwards compatibility not guaranteed.
 	 */
 	public function robots_txt( $output ) {
-		$path = ( ! empty( $site_url['path'] ) ) ? $site_url['path'] : '';
+		$site_url = wp_parse_url( site_url() );
+		$path     = ( ! empty( $site_url['path'] ) ) ? $site_url['path'] : '';

 		$lines       = preg_split( '/\r\n|\r|\n/', $output );
 		$agent_index = array_search( 'User-agent: *', $lines, true );
diff --git a/plugins/woocommerce/phpstan-baseline.neon b/plugins/woocommerce/phpstan-baseline.neon
index a589d6b82f9..6076e6b4cc8 100644
--- a/plugins/woocommerce/phpstan-baseline.neon
+++ b/plugins/woocommerce/phpstan-baseline.neon
@@ -16614,18 +16614,6 @@ parameters:
 			count: 1
 			path: includes/class-woocommerce.php

-		-
-			message: '#^Undefined variable\: \$site_url$#'
-			identifier: variable.undefined
-			count: 1
-			path: includes/class-woocommerce.php
-
-		-
-			message: '#^Variable \$site_url in empty\(\) is never defined\.$#'
-			identifier: empty.variable
-			count: 1
-			path: includes/class-woocommerce.php
-
 		-
 			message: '#^Call to method display_items\(\) on an unknown class WP_CLI\\Formatter\.$#'
 			identifier: class.notFound