Support

Akeeba Backup for Joomla!

#19026 die() vs. die(2)

Posted in ‘Akeeba Backup for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Akeeba Backup version
n/a

Latest post by nicholas on Wednesday, 05 February 2014 01:44 CST

user78038
EXTREMELY IMPORTANT: Please attach a ZIP file containing your Akeeba Backup log file in order for us to help you with any backup or restoration issue. If the file is over 2Mb, please upload it on your server and post a link to it.

Description of my issue:

I have created a Linux Centos CLI cron script at Siteground to send me a message when there is an error with my backups. I test for a zero error code vs. non-zero.

The documentation for Akeeba Backup says:
The akeeba-backup.php script will return a different exit code, depending on the backup status. When the backup is successful and without warnings, the exit code will be 0. When the backup completed but with warnings, the exit code will be 1. Finally, if the backup fails, the exit code will be 2. This allows you to check the backup status, for example inside a shell script, for automation purposes.

However, when the PHP version is less than 5.3.1 akeeba-backup.php sends a zero return code causing my CLI script to report a false outcome.

I recommend a change to line 76 of the akeeba-backup.php file from die(); to die(2); This would be consistent with the documentation and also allow for proper shell script error handling when the PHP version is not acceptable to the akeeba-backup.php script?

Thanks,
Dennis Kmetz

nicholas
Akeeba Staff
Manager
Actually, die(2) would print 2 in the standard output. We use halt() to modify the error level instead. halt() and halt(0) set the error level to 0, halt(1) sets it to 1, halt(2) sets it to 2 and so on.

That said, you are using an outdated version of our software which may have a bug regarding that feature and is definitely NOT compatible with Joomla! 3.2.1 as it predates it by several months. Please upgrade to Akeeba Backup 3.9.2 which, at the time of this writing, is the latest release that is compatible with Joomla! 3.2.1

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

user78038
Thanks for the quick response

Sorry... I got the version wrong... I am actually using the latest version:
Akeeba Backup Professional 3.9.2 (2013-12-27)

So.. I recommend a change to line 76 of the akeeba-backup.php file from die(); to die(2); This would be consistent with the documentation and also allow for proper shell script error handling when the PHP version is not acceptable to the akeeba-backup.php script

of course, halt(2) would also be OK with me.



nicholas
Akeeba Staff
Manager
As I said, die(2) would be inconsistent with the documentation and outright wrong as it would print out the character 2. It would not set the error level to 2, which is what is documented. Moreover our documentation states:
The akeeba-backup.php script will return a different exit code, depending on the backup status. When the backup is successful and without warnings, the exit code will be 0. When the backup completed but with warnings, the exit code will be 1. Finally, if the backup fails, the exit code will be 2. This allows you to check the backup status, for example inside a shell script, for automation purposes.

Line 76 is only executed BEFORE the backup even starts. Actually, it occurs before the Joomla! CLI application dependencies are loaded, let alone our CRON script have he chance to run. It's part of the pre-run check which only checks the PHP version. Changing the exit status (errorlevel) to 2 at this point would be INCONSISTENT with our documentation which declares that the exist status is only modified as the result of backup warnings and errors.

Finally, please note that before you schedule an unattended CRON job you must make sure that the minimum system requirements are met and it actually runs. When the line you mention executes you are receiving a message similar to the following:
================================================================================
WARNING! Incompatible PHP version 5.2.15
================================================================================

This CRON script must be run using PHP version 5.3.1 or later. Your server is
currently using a much older version which would cause this script to crash. As
a result we have aborted execution of the script. Please contact your host and
ask them for the correct path to the PHP CLI binary for PHP 5.3.1 or later, then
edit your CRON job and replace your current path to PHP with the one your host
gave you.

For your information, the current PHP version information is as follows.

PATH:    /usr/bin/php-ancient
VERSION: 5.2.15

Further clarifications:

1. There is absolutely no possible way that you are receiving this warning in
   error. We are using the PHP_VERSION constant to detect the PHP version you
   are currently using. This is what PHP itself reports as its own version. It
   simply cannot lie.

2. Even though your *site* may be running in a higher PHP version that the one
   reported above, your CRON scripts will most likely not be running under it.
   This has to do with the fact that your site DOES NOT run under the command
   line and there are different executable files (binaries) for the web and
   command line versions of PHP.

3. Please note that you MUST NOT ask us for support about this error. We cannot
   possibly know the correct path to the PHP CLI binary as we have not set up
   your server. Your host must know and give that information.

4. The latest published versions of PHP can be found at http://www.php.net/
   Any older version is considered insecure and must NOT be used on a live
   server. If your server uses a much older version of PHP than that please
   notify them that their servers are insecure and in need of an update.

This script will now terminate. Goodbye.

When you see THAT message you don't need an exit code. It's not something that broke "suddenly". It's something that never worked, not the first time you tried using the ancient PHP version, not any later time. You need to fix your command line, not your configuration.

TL;DR:
This is not a bug. This ticket is closed.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!