Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

mage-setup problem (UPDATED) (SOLVED)
 
lau_gue
Jr. Member
 
Total Posts:  4
Joined:  2013-01-04
 

I’m trying to upgrade from 1.5.1 to 1.7.0 - running on PHP5.2.17 FastCGI

When I run:
./mage list-upgrades
it returns:
Please initialize Magento Connect installer by running:  ./mage mage-setup

When I run:
./mage mage-setup
it returns:
Running initial setup…

But then when I again run:
./mage list-upgrades
it returns:
Please initialize Magento Connect installer by running:  ./mage mage-setup

No matter how many times I run ./mage mage-setup I still have the same problem.

So I tried to debug the mage file and discovered that the problem is caused because the following command isn’t working
./mage config-set magento_root “$MAGE_ROOT_DIR”

All the other commands expect the magento_root config setting to have something in it like “/home/abc/public_html/mysite”
and if it doesn’t then it tells you to run mage-setup which is supposed to set it.

So I tried running:
./mage config-set magento_root /home/abc/public_html/mysite
directly in the command line and it returns nothing
Then I run:
./mage config-get magento_root
to see if it successfully set it and it returns nothing.

I then noticed that the final line of the mage script is this:

exec $PHP -C -q -d output_buffering=1 -d variables_order=EGPCS \
-d open_basedir="” -d safe_mode=0 -d register_argc_argv="On" \
-d auto_prepend_file="” -d auto_append_file="” \
$MAGE_ROOT_DIR/$MAGE_PHP_SCRIPT “$@”

and as $MAGE_ROOT_DIR = /home/abc/public_html/mysite/downloader
and as $MAGE_PHP_SCRIPT = mage.php

So there must be a problem with /downloader/mage.php

Can anybody help?

 
Magento Community Magento Community
Magento Community
Magento Community
 
lau_gue
Jr. Member
 
Total Posts:  4
Joined:  2013-01-04
 

I’ve found the solution to the problem.

I put some debug statements towards the bottom of /downloader/mage.php and discovered that the constants STDIN, STDOUT and STDERR are not defined nothing gets run if they’re not defined.

Turns out that STDIN, STDOUT and STDERR are automatically defined if you run php CLI for command line php programs but my site is hosted at bluehost.com and they run FASTCGI as the command line processor and it doesn’t define STDIN, STDOUT and STDERR.

Therefore the solution is to change the /mage script so that it calls the CLI processor. I discovered that at bluehost.com you can run the CLI processor by doing “exec php-cli” instead of “exec php”.

Therefore i edit /mage and changed line 4 to:

MAGE_PHP_BIN="php-cli"

And that fixed the problem!!

If anyone responsible for the /mage script reads this then I suggest it would be good to add a comment beside that line explaining this problem.

It would also be good if the code at the end of /downloader/mage.php was changed from this:

if (defined('STDIN') && defined('STDOUT') && (defined('STDERR'))) {
    __cli_Mage_Connect
::instance()->init($argv)->run();
}

to this;

if (defined('STDIN') && defined('STDOUT') && (defined('STDERR'))) {
    __cli_Mage_Connect
::instance()->init($argv)->run();
}else{
   
echo 'It looks like you are processing this script using the CGI php processor and you MUST call it using the CLI processor. Try setting MAGE_PHP_BIN="php-cli" in the file /mage or find out from your web host how to call the php CLI processor.';
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
Digital Pianism
Member
 
Avatar
Total Posts:  48
Joined:  2010-06-08
 

Another solution: in downloader/mage.php

Paste the following:

if (!defined('STDIN'))
{
    define
('STDIN'fopen('php://stdin''r'));
}
if (!defined('STDOUT'))
{
    define
('STDOUT'fopen('php://stdout''w'));
}
if (!defined('STDERR'))
{
    define
('STDERR'fopen('php://stderr''w'));
}

Before :

if (defined('STDIN') && defined('STDOUT') && (defined('STDERR'))) {
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top