[wp-trac] [WordPress Trac] #47033: Admin Paging broken when using a Proxy or Alternate Site URL

WordPress Trac noreply at wordpress.org
Thu Apr 25 02:49:33 UTC 2019


#47033: Admin Paging broken when using a Proxy or Alternate Site URL
----------------------------+-----------------------------
 Reporter:  ooglek          |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Administration  |    Version:  5.1.1
 Severity:  normal          |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 I'm running WP as a separate subdomain website and using nginx to proxy
 requests to that site to it is presented as part of our main site.

 The WordPress Address (URL) and Site Address (URL) are both set to
 "https://www.domain.com/blog" and for the core of the site and most of the
 admin functionality, this works. WordPress is running directly at
 "http://wp.domain.com/blog" and nginx proxies requests to that host, as it
 lives on a separate non-load-balanced host than the main www site.

 However, when viewing Posts, if you click to Page 2, you are logged out.
 This occurred in both 5.0.4 and 5.1.1.

 I've solved this issue by fixing the $current_url value in two files and
 three places.

 1. wp-admin/includes/class-wp-list-table.php
 2. wp-admin/includes/misc.php

 My solution was to use get_site_url() and then set_url_scheme to that
 value plus the REQUEST_URI.

 However, since all three places run the same three calls -- get_site_url,
 set_url_scheme, then remove_query_arg, it may make sense to throw that in
 a helper class to simplify and unify.

 I'll submit a patch shortly.

 Here's the diff, but not my final patch, against 5.1.1:


 {{{
 --- /tmp/class-wp-list-table.php        2019-04-25 02:28:04.760014000
 +0000
 +++ ./blog/wp-admin/includes/class-wp-list-table.php    2019-04-25
 02:31:36.522866000 +0000
 @@ -795,7 +795,8 @@
                 $current              = $this->get_pagenum();
                 $removable_query_args = wp_removable_query_args();

 -               $current_url = set_url_scheme( 'http://' .
 $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
 +               $site_url = get_site_url(null, '', 'admin');
 +               $current_url = set_url_scheme(substr($site_url, 0,
 strpos($site_url, '/', 8)) . $_SERVER['REQUEST_URI'] );

                 $current_url = remove_query_arg( $removable_query_args,
 $current_url );

 @@ -1079,7 +1080,8 @@
         public function print_column_headers( $with_id = true ) {
                 list( $columns, $hidden, $sortable, $primary ) =
 $this->get_column_info();

 -               $current_url = set_url_scheme( 'http://' .
 $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
 +               $site_url = get_site_url(null, '', 'admin');
 +               $current_url = set_url_scheme(substr($site_url, 0,
 strpos($site_url, '/', 8)) . $_SERVER['REQUEST_URI'] );
                 $current_url = remove_query_arg( 'paged', $current_url );

                 if ( isset( $_GET['orderby'] ) ) {

 --- /tmp/misc.php       2019-04-25 02:32:56.006536000 +0000
 +++ /usr/local/www/vhosts/wp.tossabledigits.com/blog/wp-
 admin/includes/misc.php 2019-04-25 02:33:44.931033000 +0000
 @@ -1163,7 +1163,8 @@
         }

         // Ensure we're using an absolute URL.
 -       $current_url  = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST']
 . $_SERVER['REQUEST_URI'] );
 +       $site_url = get_site_url(null, '', 'admin');
 +       $current_url  = set_url_scheme(substr($site_url, 0,
 strpos($site_url, '/', 8)) . $_SERVER['REQUEST_URI'] );
         $filtered_url = remove_query_arg( $removable_query_args,
 $current_url );
         ?>
         <link id="wp-admin-canonical" rel="canonical" href="<?php echo
 esc_url( $filtered_url ); ?>" />
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47033>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list