Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue: APC CLI #4731

Merged
merged 1 commit into from Mar 26, 2019

Conversation

Projects
None yet
7 participants
@JediKev
Copy link
Member

commented Feb 13, 2019

This addresses issue #4720 where creating tickets via CLI fails to set a status and crashes with an "APC must be enabled" error. This adds a check to see if the APC module is loaded before continuing.

@pablopol24

This comment has been minimized.

Copy link

commented Feb 13, 2019

it did not work in my case with:
if (extension_loaded('apc') && function_exists('apcu_store')) {
It works with:
if (PHP_SAPI !== 'cli' && function_exists('apcu_store')) {

@JediKev

This comment has been minimized.

Copy link
Member Author

commented Feb 13, 2019

@pablopol24

Hmmm...

What OS are you running? CentOS, Ubuntu, etc.

What build of PHP?

Also, how did you apply this fix? Did you copy/paste, apply via git, etc.

Cheers.

@JediKev

This comment has been minimized.

Copy link
Member Author

commented Feb 13, 2019

@pablopol24

The error is APC must be enabled to use APCuIterator which means the APC module is not enabled/loaded. In PHP the way you check that is extension_loaded('apc').

Not sure why this is not working for you but working fine for me. Maybe you mistyped something? Try applying the diff or copy pasting from the pull request.

Cheers.

@@ -960,7 +960,7 @@ static function storeCounts($key, $counts, $ttl) {
}
static function clearCounts() {
if (function_exists('apcu_store')) {
if (extension_loaded('apc') && function_exists('apcu_store')) {

This comment has been minimized.

Copy link
@greezybacon

greezybacon Feb 13, 2019

Member

I'm not so sure. On PHP >= 5.6 the extension is called acpu. So I think your fix is just disabling the block altogether? Because function_exists('acpu_store') should be enough to detect the presence of ACPu?

This comment has been minimized.

Copy link
@JediKev

JediKev Feb 13, 2019

Author Member

function_exists('apcu_store') is not adequate enough to detect this as it fails for me every time when piping via CLI. I receive the error APC must be enabled to use APCuIterator which means APC is not enabled.

@greezybacon

This comment has been minimized.

Copy link
Member

commented Feb 13, 2019

Should the fix maybe go into class.ticket.php around line 3173:

    function save($refetch=false) {
        if ($this->dirty) {
            $this->updated = SqlFunction::NOW();
            if (isset($this->dirty['status_id']) && PHP_SAPI !== 'cli')
                // Refetch the queue counts
                SavedQueue::clearCounts();
        }
        return parent::save($this->dirty || $refetch);
    }    
@JediKev

This comment has been minimized.

Copy link
Member Author

commented Feb 13, 2019

@greezybacon

There has to be a better way other than detecting CLI right?

Cheers.

@adlerweb

This comment has been minimized.

Copy link

commented Feb 13, 2019

The error is APC must be enabled to use APCuIterator which means the APC module is not enabled/loaded. In PHP the way you check that is extension_loaded('apc').

I can't test atm, but as far as I remember tell the APCu extension is loaded, just not active due to apc.enable_cli beeing false in the default config. symfony has a similar problem and only proposal atm is also to check the used SAPI first.

@pablopol24

This comment has been minimized.

Copy link

commented Feb 14, 2019

@ pablopol24

Hmmm ...

¿Qué sistema operativo estás ejecutando? CentOS, Ubuntu, etc.

¿Qué compilación de PHP?

Además, ¿cómo aplicaste esta corrección? Copiaste / pegaste, aplicaste vía git, etc.

Aclamaciones.

Ubuntu 18.04
PHP 7.2
Osticket 1.11

copy and paste in both cases

@greezybacon

This comment has been minimized.

Copy link
Member

commented Feb 14, 2019

According to StackOverflow, ini_get('apc.enabled')?

@adlerweb

This comment has been minimized.

Copy link

commented Feb 14, 2019

According to StackOverflow, ini_get('apc.enabled')?

That is only true for other SAPIs, CLI like the cron used for mails ignores apc.enabled and uses apc.enable_cli instead.

issue: APC CLI
This addresses issue 4720 where creating tickets via CLI fails to set a
status and crashes with an "APC must be enabled" error. This adds a check to
see if the APC module is loaded before continuing.

@JediKev JediKev force-pushed the JediKev:issue/apc-cli branch from ac40fc8 to b210e4f Feb 15, 2019

lubo added a commit to devinsolutions/docker-osticket that referenced this pull request Feb 18, 2019

@bradgillap

This comment has been minimized.

Copy link

commented Feb 22, 2019

The fix op posted in this thread worked for me in production with two departments and several users.

Server Information

osTicket Version | v1.11 (0f229ae) —  Up to date
Web Server Software | Apache/2.4.25 (Debian)
MySQL Version | 10.1.37
PHP Version | 7.2.15-1+020190209065123.16+stretch1.gbp3ad8c0

gdlib | Used for image manipulation and PDF printing
imap | Used for email fetching
xml | XML API
xml-dom | Used for HTML email processing
json | Improves performance creating and processing JSON
mbstring | Highly recommended for non western european language content
phar | Highly recommended for plugins and language packs
intl | Highly recommended for non western european language content
fileinfo | Used to detect file types for uploads
APCu | Improves overall performance
Zend Opcache | Improves overall performance

cgi.fix_pathinfo | "1" is recommended if AJAX is not working
date.timezone | America/Toronto

Schema | osticket (localhost)
Schema Signature |
Space Used | 13.66 MiB
Space for Attachments | 10.47 MiB
Timezone | EST (Interpreted as America/New_York)

Thanks!

@protich protich merged commit 43794f9 into osTicket:develop-next Mar 26, 2019

@clonemeagain

This comment has been minimized.

Copy link
Contributor

commented Mar 26, 2019

Typically APC is only enabled for cgi/fpm/Apache, not cli, enabling tools like composer and systems like laravel/symfony to work properly in cli mode, because of annotations and apc stripping them.
Each of those PHP use cases will have their own ini and module configs. This would explain why simply detecting the sapi type works

@visimitra visimitra referenced this pull request Apr 17, 2019

Open

API Unexpected Data receive email in PHP7.2 #4852

0 of 4 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.