WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#16572 closed defect (bug) (invalid)

Admin URL's break when site is installed as a subdirectory

Reported by: jcorradino Owned by:
Milestone: Priority: normal
Severity: major Version: 3.0.5
Component: Administration Keywords: reporter-feedback
Focuses: Cc:

Description

For instance, the pagination on the posts page links to /wp-admin/ rather than /sub-directory/wp-admin/

The problem lays in the following code on edit.php (lines 312-319)

$page_links = paginate_links( array(
	'base' => add_query_arg( 'paged', '%#%' ),
	'format' => '',
	'prev_text' => __('«'),
	'next_text' => __('»'),
	'total' => $num_pages,
	'current' => $pagenum
));

I changed it to the following, and it seems to work.

$page_links = paginate_links( array(
	'base' => get_option('home').add_query_arg( 'paged', '%#%' ),
	'format' => '',
	'prev_text' => __('«'),
	'next_text' => __('»'),
	'total' => $num_pages,
	'current' => $pagenum
));

If there is an easier way to go about fixing this, then please let me know. Pagination is not the only place where I am seeing this bug, if you also look at /wp-admin/includes/media.php, line 82 contains the following

$link = "<a href='" . esc_url($href) . "'$class>$text</a>";

which also dumps you in /wp-admin/ instead of /sub-directory/wp-admin/

I propose the same change as above. In total, there are 4 templates that I have determined to be affected by this bug under wp-admin (may be missing some): comment.php, edit.php, media.php, and /includes/media.php.

Change History (5)

comment:1 nacin3 years ago

  • Keywords reporter-feedback added

I think this is a server configuration issue. add_query_arg() when called like that appends variables to $_SERVER['REQUEST_URI']. Sounds like that variable is lying to us.

Many of my test installs are installed as subdomains without issue.

comment:2 follow-up: jcorradino3 years ago

That actually seemed to have been the issue. $_SERVERREQUEST_URI? returned /wp-admin/post.php, not /news/wp-admin/post.php.

I set $_SERVERREQUEST_URI? = '/news'.$_SERVERREQUEST_URI? in functions.php for the theme and that seemed to have fixed the issue.

comment:3 nacin3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Better fix it in wp-config.php, as a lot of stuff happens before functions.php is loaded.

comment:4 in reply to: ↑ 2 hakre3 years ago

Replying to jcorradino:

Can you please add this to the beginning of your index.php file and report back the output?

var_dump($_SERVER['REQUEST_URI']); die();
Last edited 3 years ago by hakre (previous) (diff)

comment:5 nacin3 years ago

hakre, he's already answered that in a comment. The ticket is closed.

Note: See TracTickets for help on using tickets.