WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 8 months ago

#16845 closed defect (bug) (invalid)

Notice: Undefined index: post_id in wp-admin/media-upload.php

Reported by: spaam Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Warnings/Notices Keywords:
Focuses: Cc:

Description

Installed 3.1 on my server. when i edit a post and trying to insert a image from another site using: /wp-admin/media-upload.php?tab=type_url . im missing post_id in that url. then i dont get the "insert into post" button.
error msg:
Notice: Undefined index: post_id in /var/www/blog/htdocs/wp-admin/includes/media.php on line 1639
Notice: Undefined index: post_id in /var/www/blog/htdocs/wp-admin/includes/media.php on line 2223

Attachments (2)

worpress-missing-post_id.patch (704 bytes) - added by spaam 3 years ago.
wordpress-missing-post_id-and-type.patch (728 bytes) - added by spaam 3 years ago.

Download all attachments as: .zip

Change History (19)

comment:1 WildPhoenix3 years ago

  • Cc WildPhoenix added

Is this a clean install? I have tested a clean install and cannot re-produce the error. Disable all plugins and try it again?

comment:2 spaam3 years ago

yes its a clean install. no plugins or themes are installed. just tar zxf latest.tar.gz .. mv wordpress htdocs. then run the install script. then i tried edit the first post and i got that error after i enabled debug mode to see why i didnt see that insert button.

comment:3 WildPhoenix3 years ago

Strange, the only part I am a little confused about is the location of wordpress install. Could you clarify? /var/www/blog/htdocs/wp-admin/includes/media.php looks like a malformed address.

Instead of using terminal commands, install it manually and try to replicate the problem?

comment:4 follow-up: spaam3 years ago

its a just a white page when i access it.

comment:5 spaam3 years ago

that patch fixed the problem. .dunno if its the right way but it works.

comment:6 in reply to: ↑ 4 spaam3 years ago

Replying to spaam:

its a just a white page when i access it.

i mean.. it look like a php script and its just white from the browser.

comment:7 spaam3 years ago

  • Keywords has-patch added

comment:8 WildPhoenix3 years ago

The post_id should be coming from the media buttons, do any of the links have the post_id parameter?

comment:9 spaam3 years ago

the first page works since it got page_id in the url.. but when i click on the other links . the post_id get strip away somehow..

comment:10 WildPhoenix3 years ago

Could you give me some technical details about your setup such as browser, OS, web server set up etc.

comment:11 spaam3 years ago

firefox 3.6.15 and chrome 10. using debian testing with php 5.3.3 (with xcache 1.3.1 , i get same result without it) and lighttpd 2 (latest git head).

comment:12 spaam3 years ago

somehow $_GETtype? missing too from the url and attached a patch that fix the post_id problem and that type problem.

comment:13 dd323 years ago

Can you dump out the contents of $_SERVER and check that REQUEST_URI and QUERY_STRING are set to on the affected page? (ie. the one which has $_GET['post_id'] but has links which do not have it..)

comment:14 spaam3 years ago

With post_id and type:
[REQUEST_URI] => /wp-admin/media-upload.php
[QUERY_STRING] => post_id=1&type=image&TB_iframe=1&width=640&height=643

without post_id and type:
[REQUEST_URI] => /wp-admin/media-upload.php
[QUERY_STRING] => tab=type_url

comment:15 dd323 years ago

  • Keywords has-patch removed

using debian testing with php 5.3.3 (with xcache 1.3.1 , i get same result without it) and lighttpd 2 (latest git head).

Well there's ya problem! Lighttpd does things differently when it comes to passing requests with regard to Rewriting, REQUEST_URI and a few other things.. 404's come to mind there too.

[REQUEST_URI] => /wp-admin/media-upload.php

That should have the query vars in it (ie. the contents of QUERY_STRING), Which Lighttpd doesnt appear to be passing.

This may be worthy of an inclusion to wp_fix_server_vars() if it's a case that's present in a release version of lighttpd and doesn't negatively affect anything else..

The attached patches are useless, they fix this particular issue, but they don't safeguard against every other case of add_query_arg() in WordPress (which is a lot).

Try adding this to your wp-config.php to correct the vars for now:

if ( !empty($_SERVER['QUERY_STRING']) )
   $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];

Also, You'll probably find that when using rewrites, GET params are not parsed correctly, It may've been fixed, but it might still be present, ie. site.com/my/permalink/?year=2011 $_GET['year'] may be unset, requiring some extra handling of $_SERVER['QUERY_STRING'] to populate $_GET + $_REQUEST.

comment:16 avryl8 months ago

  • Component changed from General to Warnings/Notices

comment:17 helen8 months ago

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

Media library got an overhaul - closing.

Note: See TracTickets for help on using tickets.