Incorrectly Detected BASE_PATH when ran in Cron.php

16 views
Skip to first unread message

Dmitry A.

unread,
Jan 6, 2011, 11:13:10 AM1/6/11
to in-port...@googlegroups.com
Hi guys,


There is a situation when we have BASE_PATH constant incorrectly determined in our Startup.php script while ran from Cron. Note that it works perfectly from the Web. The problem comes from PHP_SELF which contains a server FULL path when ran in cron. Since there about 2-3 places we depend on BASE_PATH, plus in some cases it's needed when performing some actions with Events triggered from cron I propose to have the ability to specify BASE_PATH in config.php which will overwrite the whole auto-detect part in Startup.php.


When ran from the Web Browser we have:

PHP_SELF : /dev/SVN/5.1.x-dev/index.php 
BASE_PATH: /dev/SVN/5.1.x-dev


When ran from the Cron.php we have:

PHP_SELF: /home/simone/web/dev/SVN/5.1.x-dev/tools/cron.php
PHP_BASE: /home/simone/web/dev/SVN/5.1.x-dev



Let me know what you think.

DA

Alexander Obuhovich

unread,
Jan 6, 2011, 1:04:35 PM1/6/11
to in-port...@googlegroups.com
PHP_SELF is path to the script based on DOCUMENT_ROOT, when launched from web.

PHP_SELF is path to PHP script, that was given to /usr/bin/php, e.g.
  • "/usr/bin/php tools/cron.php" will give "tools/cron.php" in PHP_SELF
  • "/usr/bin/php cron.php" will give "cron.php" in PHP_SELF

variable $_SERVER['SCRIPT_FILENAME'] will have same value (just for your info).

since we don't know how exactly cron.php will be executed to cut that part.

There is stupid solution: we should do this: "cd <DOCUMENT_ROOT>; /usr/bin/php tools/cron.php".



--
You received this message because you are subscribed to the Google Groups "In-Portal Bugs Team" group.
To post to this group, send email to in-port...@googlegroups.com.
To unsubscribe from this group, send email to in-portal-bug...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/in-portal-bugs?hl=en.



--
Best Regards,

http://www.in-portal.com
http://www.alex-time.com

Dmitry A.

unread,
Jan 6, 2011, 2:01:55 PM1/6/11
to in-port...@googlegroups.com
Thanks for your quick reply Alex.

I just thinking that we are going to rely on the server CD command which might not work always - depending on server configuration. What do you think about my proposition to have ability to specify BASE_PATH in the config.php similar to what we do with "system" and so on. I think it's quite good solution which will have to prevent auto-detect from failing and allows to properly overwrite it?


Cheers!

Alexander Obuhovich

unread,
Jan 6, 2011, 3:56:27 PM1/6/11
to in-port...@googlegroups.com
We already have "Site_Path" configuration variable, that could be used, when we got strange BASE_PATH. It's sad, that configuration variables are not available, where BASE_PATH constant is defined.

--
You received this message because you are subscribed to the Google Groups "In-Portal Bugs Team" group.
To post to this group, send email to in-port...@googlegroups.com.
To unsubscribe from this group, send email to in-portal-bug...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/in-portal-bugs?hl=en.

Dmitry Andrejev

unread,
Jan 6, 2011, 11:19:51 PM1/6/11
to in-port...@googlegroups.com
Hi Alex,


Yes, you are right about Site_Path.


I think we might want to get right of Site_Path completely? I have checked and it looks like it's used in 2-3 places, here is one in In-Auction module:

'ApplicationURL' => 'http://'.DOMAIN.$this->Application->ConfigValue('Site_Path').'in-auction/notify.php',


This just an idea that we can have one Constant which is auto-detected, but also can be forced or something like that. Or we can forget about this whole dilemma and just tell everyone to use $this->Application->ConfigValue('Site_Path') where it's needed.


Let me know your thoughts and reasons.


Thanks

DA
Best regards,

Dmitry A.

Alexander Obuhovich

unread,
Jan 7, 2011, 4:02:52 AM1/7/11
to in-port...@googlegroups.com
2nd option.

S.G.

unread,
Feb 21, 2011, 4:19:23 AM2/21/11
to in-port...@googlegroups.com
I suggest to move Site Path variable from ConfigurationValues table to config.php file. So, when we detect that script is not run under web-server (via command line), we may use this value as BASE_PATH constant. We already do similar thing for site domain.

Alexander Obuhovich

unread,
Feb 21, 2011, 4:37:55 AM2/21/11
to in-port...@googlegroups.com
Nice. We must adjust installator to allow changing "Site_Path" during installation.


On Mon, Feb 21, 2011 at 11:19 AM, S.G. <serg...@gmail.com> wrote:
I suggest to move Site Path variable from ConfigurationValues table to config.php file. So, when we detect that script is not run under web-server (via command line), we may use this value as BASE_PATH constant. We already do similar thing for site domain.

--
You received this message because you are subscribed to the Google Groups "In-Portal Bugs Team" group.
To post to this group, send email to in-port...@googlegroups.com.
To unsubscribe from this group, send email to in-portal-bug...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/in-portal-bugs?hl=en.

Dmitry A.

unread,
Feb 21, 2011, 10:46:58 AM2/21/11
to in-port...@googlegroups.com
Thanks for your input Sergey!

I support the idea since that's how I wanted to see it when we started this discussion :)


Anything else to add here or we are ready for a task?


DA


Alexander Obuhovich

unread,
Feb 21, 2011, 11:32:38 AM2/21/11
to in-port...@googlegroups.com
Ready for a task.

--
You received this message because you are subscribed to the Google Groups "In-Portal Bugs Team" group.
To post to this group, send email to in-port...@googlegroups.com.
To unsubscribe from this group, send email to in-portal-bug...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/in-portal-bugs?hl=en.

Dmitry A.

unread,
Feb 21, 2011, 2:18:21 PM2/21/11
to in-port...@googlegroups.com
New task created:

1005: Incorrectly Detected BASE_PATH in Cron



Note that it was added as a child of:

969: New "System Configuration" installation step



And will should be implemented after it's parent.


DA
Reply all
Reply to author
Forward
0 new messages