GAE PHP realpath returning false depending on how code is deployed

0 views
Skip to first unread message

Morgan O'Neal via StackOverflow

unread,
Jul 29, 2014, 2:46:48 PM7/29/14
to google-appengin...@googlegroups.com

I'm having a issue with Google App Engine and the PHP realpath function. When I deploy with git the realpath function does not work when accessing the wordpress css directory but does work when deploying with the command line sdk. Both codebases are the same except for the version being deployed. I also verified that the files are correctly in git and are visible when accessing them directly and from the project console code browser.

I'm using this as my test code

<?php
print '<pre>';
$file = __FILE__;
$realpath = realpath( $file );
print 'File: ' . $file . "\n";
print 'Realpath: ' . $realpath . "\n";
var_dump( $realpath );

$file = __DIR__ . '/wordpress/wp-includes/';
$realpath = realpath( $file );
print 'File: ' . $file . "\n";
print 'Realpath: ' . $realpath . "\n";
var_dump( $realpath );

$file = __DIR__ . '/wordpress/wp-includes/css/';
$realpath = realpath( $file );
print 'File: ' . $file . "\n";
print 'Realpath: ' . $realpath . "\n";
var_dump( $realpath );

$file = __DIR__ . '/wordpress/wp-includes/css/dashicons.min.css';
$realpath = realpath( $file );
print 'File: ' . $file . "\n";
print 'Realpath: ' . $realpath . "\n";
var_dump( $realpath );
print '</pre>';
?>

When I access the git deployed version I see:

File: /base/data/home/apps/s~peak-eon-630/wp.377596938324631222/test.php
Realpath: /base/data/home/apps/s~peak-eon-630/wp.377596938324631222/test.php
string(66) "/base/data/home/apps/s~peak-eon-630/wp.377596938324631222/test.php"
File: /base/data/home/apps/s~peak-eon-630/wp.377596938324631222/wordpress/wp-includes/
Realpath: /base/data/home/apps/s~peak-eon-630/wp.377596938324631222/wordpress/wp-includes
string(79) "/base/data/home/apps/s~peak-eon-630/wp.377596938324631222/wordpress/wp-includes"
File: /base/data/home/apps/s~peak-eon-630/wp.377596938324631222/wordpress/wp-includes/css/
Realpath: 
bool(false)
File: /base/data/home/apps/s~peak-eon-630/wp.377596938324631222/wordpress/wp-includes/css/dashicons.min.css
Realpath: 
bool(false)

And when I access the command line sdk deployed version I see:

File: /base/data/home/apps/s~peak-eon-630/test.377596986549195338/test.php
Realpath: /base/data/home/apps/s~peak-eon-630/test.377596986549195338/test.php
string(68) "/base/data/home/apps/s~peak-eon-630/test.377596986549195338/test.php"
File: /base/data/home/apps/s~peak-eon-630/test.377596986549195338/wordpress/wp-includes/
Realpath: /base/data/home/apps/s~peak-eon-630/test.377596986549195338/wordpress/wp-includes
string(81) "/base/data/home/apps/s~peak-eon-630/test.377596986549195338/wordpress/wp-includes"
File: /base/data/home/apps/s~peak-eon-630/test.377596986549195338/wordpress/wp-includes/css/
Realpath: /base/data/home/apps/s~peak-eon-630/test.377596986549195338/wordpress/wp-includes/css
string(85) "/base/data/home/apps/s~peak-eon-630/test.377596986549195338/wordpress/wp-includes/css"
File: /base/data/home/apps/s~peak-eon-630/test.377596986549195338/wordpress/wp-includes/css/dashicons.min.css
Realpath: /base/data/home/apps/s~peak-eon-630/test.377596986549195338/wordpress/wp-includes/css/dashicons.min.css
string(103) "/base/data/home/apps/s~peak-eon-630/test.377596986549195338/wordpress/wp-includes/css/dashicons.min.css"

My app.yaml looks like this:

application: peak-eon-630
version: wp
runtime: php
api_version: 1
threadsafe: true

handlers:
- url: /(.*\.(htm|html|css|js))$
  static_files: wordpress/\1
  upload: wordpress/.*\.(htm|html|css|js)$
  application_readable: true

- url: /wp-content/(.*\.(ico|jpg|png|gif|svg))$
  static_files: wordpress/wp-content/\1
  upload: wordpress/wp-content/.*\.(ico|jpg|png|gif|svg)$
  application_readable: true

- url: /(.*\.(ico|jpg|png|gif))$
  static_files: wordpress/\1
  upload: wordpress/.*\.(ico|jpg|png|gif)$
  application_readable: true

- url: /wp-admin/(.+)
  script: wordpress/wp-admin/\1
  secure: always

- url: /wp-admin/
  script: wordpress/wp-admin/index.php
  secure: always

- url: /wp-login.php
  script: wordpress/wp-login.php
  secure: always

- url: /wp-cron.php
  script: wordpress/wp-cron.php
  login: admin

- url: /xmlrpc.php
  script: wordpress/xmlrpc.php

- url: /wp-(.+).php
  script: wordpress/wp-\1.php

- url: /test.php
  script: test.php

- url: /(.+)?/?
  script: wordpress/index.php

skip_files:
- ^(.*/)?\.zip$
- ^(.*/)?\.bat$
- ^(.*/)?\.sh$
- ^(.*/)?\.md$
- ^(.*/)?node_modules/.*


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/25022732/gae-php-realpath-returning-false-depending-on-how-code-is-deployed
Reply all
Reply to author
Forward
0 new messages