WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#12594 closed defect (bug) (fixed)

Use paths in include calls

Reported by: nacin Owned by: sorich87
Milestone: 3.0 Priority: normal
Severity: normal Version:
Component: Performance Keywords:
Focuses: Cc:

Description

We often do require('admin.php') where require('./admin.php') would be quicker, as it would avoid the include_path directive.

We should audit core for instances where we include a file (it'd generally be a bootstrap) without specifying a relative or absolute path.

Attachments (1)

path_patch.diff (45.2 KB) - added by sorich87 4 years ago.

Download all attachments as: .zip

Change History (10)

sorich874 years ago

comment:1 sorich874 years ago

  • Keywords has-patch added; needs-patch removed
  • Owner set to sorich87
  • Status changed from new to accepted

I added a relative path where no path is specified

comment:2 nacin4 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [14139]) Use relative paths when including files, avoiding include_path. fixes #12594, props sorich87.

comment:3 Viper007Bond4 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Testing patches is a good idea. This completely breaks trunk.

Warning: require_once(./class-oembed.php) [function.require-once]: failed to open stream: No such file or directory in [...]\wp-includes\media.php  on line 1358

Fatal error: require_once() [function.require]: Failed opening required './class-oembed.php' (include_path='.;C:\php5\pear') in [...]\wp-includes\media.php on line 1358

comment:4 Viper007Bond4 years ago

That's from my localhost. Also breaks on my live block and scribu's localhost.

comment:5 scribu4 years ago

  • Keywords needs-patch added; has-patch removed
  • Priority changed from normal to highest omg bbq
  • Severity changed from normal to blocker

comment:6 dd324 years ago

(In [14151]) Fix invalid paths in requires. See r14139. See #12594

comment:7 dd324 years ago

Relative paths are taken from the calling script, not the current file.

So in those cases, it was trying to load ABSPATH/class-json.php

comment:8 sorich874 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

Thanks dd32

comment:9 nacin4 years ago

  • Keywords needs-patch removed
  • Priority changed from highest omg bbq to normal
  • Severity changed from blocker to normal

My bad, sorry guys, I didn't have any embeds on my testbed. Completely missed that.

Note: See TracTickets for help on using tickets.