Drupal cron error: failed to open stream - php

I've set up my Drupal 7 cron job like so:
/usr/local/bin/php /home/myaccount/public_html/cron.php
However, cron sends me an email with the following error message:
Warning: include_once(/home/myaccount/includes/bootstrap.inc): failed to open stream: No such file or directory in /home/myaccount/public_html/cron.php on line 13
Warning: include_once(): Failed opening '/home/myaccount/includes/bootstrap.inc' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/myaccount/public_html/cron.php on line 13
Fatal error: Call to undefined function drupal_bootstrap() in /home/tente myaccount studios/public_html/cron.php on line 14
It appears that cron is somehow stripping out public_html from the path. I uploaded a temporary PHP file and printed out getcwd() and it reports the path correctly, including public_html. So somewhere between line 11 when DRUPAL_ROOT is defined as getcwd() and line 13 when the include is called, something strips out public_html from the path.

You should use curl to call your webserver so that the correct php.ini and openbasedir directives are set. See https://www.drupal.org/cron

Related

How to have relative path (../) in a pipe script?

I have [root]/includes/helpdesk/pipe.php with this code:
#!/opt/cpanel/ea-php55/root/usr/bin/php
<?php
require_once("pipeprocess.php");
In the same location in pipeprocess.php in first line I include another file still in the same location: helpdesk.php
then in [root]/includes/helpdesk/helpdesk.php in the first line I have:
require_once ("../../config.php");
config.php is in [root], this is why I have twice ../../, helpdesk.php works fine with direct access, but if run pipe.php via pipe command setup in cPanel I get a bounce error that config. php is not found:
PHP Warning: require_once(../../config.php): failed to open stream:
No such file or directory in
/home/[user]/public_html/[root]/includes/helpdesk/helpdesk.php on line
21
Warning: require_once(../../config.php): failed to open stream: No
such file or directory in
/home/[user]/public_html/[root]/includes/helpdesk/helpdesk.php on line
21 PHP Fatal error: require_once(): Failed opening required
'../../config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php')
in /home/[user]/public_html/[root]/includes/helpdesk/helpdesk.php on
line 21
Fatal error: require_once(): Failed opening required
'../../config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php')
in /home/[user]/public_html/[root]/includes/helpdesk/helpdesk.php on
line 21
Why I am getting this pipe error as direct access to helpdesk.php works fine? does pipe not accept ../ or ../../ as parth of the path? or is there an EasyApache4 issue? I did several tests and noticed this is because of ../ as part of including path. Does pipe/EasyApache4 have problem with this?
What if you used __DIR__, based on where your currently running script file's folder?
As of PHP 5.3.0, you could use something like this:
require_once (__DIR__ . "/../../config.php");

warning errors in php

I am starting to work on a site that has been up for some time. It is producing the following error messages before I even got started:
Warning: main(includes/main_functions.php) [function.main]: failed to open stream: No such file or directory in \\boswinfs01\home\users\web\b748\ez.paphospro\includes\top.php on line 22
Warning: main() [function.include]: Failed opening 'includes/main_functions.php' for inclusion (include_path='.;c:\php\4\pear') in \\boswinfs01\home\users\web\b748\ez.paphospro\includes\top.php on line 22
Warning: main(includes/functions/functions_email.php) [function.main]: failed to open stream: No such file or directory in \\boswinfs01\home\users\web\b748\ez.paphospro\includes\top.php on line 23
Warning: main() [function.include]: Failed opening 'includes/functions/functions_email.php' for inclusion (include_path='.;c:\php\4\pear') in \\boswinfs01\home\users\web\b748\ez.paphospro\includes\top.php on line 23
Fatal error: Call to undefined function: get_includes_file() in \\boswinfs01\home\users\web\b748\ez.paphospro\includes\top.php on line 24
Could it be that the path in the includes\top.php file is incorrect? Or do I need to look for something else?
the top.php file includes the following code:
define('BASE_PATH' , '/--/--/--/--/--/--/'); (I took out the path in this example).
and on the lines 22, 23, 24 it has the following code:
`include("includes/main_functions.php");
include("includes/functions/functions_email.php");
include(get_includes_file("includes/config.php"));`
all the above files are on the server in those directories.
I really need some direction as to why the errors are there and what I can do to fix them.
Thanks for any and all help or suggestions.
The warning is caused by non existing script file or wrong file permissions.
I would recommend you to do some refactoring, replacing the include function with require_once. This way you'll get a fatal E_COMPILE_ERROR level error which is better than a misleading application.
Then you must define your application base path define('DOCROOT', realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR); and use it to reference all other application dependencies (e.g. require_once(DOCROOT.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR.'main_functions.php');

application path in codeigniter in php

My system's path is C:\xampp\htdocs\codeigniter and my application folder is inside the system folder. I am facing the following error..
Warning: require_once(C:/xampp/htdocs/codeigniter/core/CodeIgniter.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\codeigniter\index.php on line 202
Fatal error: require_once() [function.require]: Failed opening required 'C:/xampp/htdocs/codeigniter/core/CodeIgniter.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\codeigniter\index.php on line 202
Your system path should be:
C:\xampp\htdocs\codeigniter\system
And your app path should be:
C:\xampp\htdocs\codeigniter\application
Did you change these?
Your index.php file cannot find the path you specified which means the path is probably incorrect unless you are having permission issues.

Moving Laravel outside of docroot gives me problems with php's chdir() and path('sys')

I've been using Laravel 3 on a live website for a while, and decided to move the app to outside of docroot, delete the public_html folder, and symlink the public folder to the public_html one. I followed solution 1 here.
Having done that, my site has stopped loading, giving a 500 error. When I checked the error log in public/error_log, this message appears:
[05-Feb-2013 08:07:25] PHP Warning: chdir() [<a href='function.chdir'>function.chdir</a>]: No such file or directory (errno 2) in /home4/indieweb/indiewebseries/paths.php on line 62
[05-Feb-2013 08:07:25] PHP Fatal error: require() [<a href='function.require'>function.require</a>]: Failed opening required '/home4/indieweb/indiewebseries/public/laravel/laravel.php' (include_path='.:/usr/lib64/php:/usr/lib/php:/usr/share/pear') in /home4/indieweb/indiewebseries/public/index.php on line 34
Just for reference:
// paths.php on line 62:
chdir(__DIR__);
// index.php line 34:
require path('sys').'laravel.php';
Any ideas?
EDIT: I tried #TheShiftExchange suggestion, moved everything outside of docroot, and renamed public to public_html. I now get these php errors:
[07-Feb-2013 05:38:25] PHP Warning: chdir() [<a href='function.chdir'>function.chdir</a>]: No such file or directory (errno 2) in /home4/indieweb/paths.php on line 62
[07-Feb-2013 05:38:25] PHP Fatal error: require() [<a href='function.require'>function.require</a>]: Failed opening required '/home4/indieweb/public_html/laravel/laravel.php' (include_path='.:/usr/lib64/php:/usr/lib/php:/usr/share/pear') in /home4/indieweb/public_html/index.php on line 34
I found the solution. It turns out all my problems were irrelevant. For some reason, the PHP settings in my hosting account were reset, and all I had to do was switch the PHP version back to 5.4 to fix everything.

require_once() cant find the include path

Hi i am trying to indlude a file by using require_once(). i am using xampp apache php server.
the file test.php is in htdocs drupal folder is also in the same directory where the include files is.
the code in line 5 is
require_once ‘drupal7/includes/bootstrap.inc’;
i am getting error
Warning: Division by zero in C:\xampp\htdocs\import.php on line 5
Warning: require_once(inc’) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\import.php on line 5
Fatal error: require_once() [function.require]: Failed opening required 'inc’' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\import.php on line 5
someone please guide me how to include a local file.
Looks like you have "fancy" single quotes in line 5. (Did you copy this from somewhere?) Change them to regular single quotes, like these:
require_once 'drupal7/includes/bootstrap.inc';

Categories