queue::save PHP Method

save() public method

Save queue
public save ( )
    function save()
    {
        if (!sizeof($this->data)) {
            return;
        }
        $lock = new \phpbb\lock\flock($this->cache_file);
        $lock->acquire();
        if (file_exists($this->cache_file)) {
            include $this->cache_file;
            foreach ($this->queue_data as $object => $data_ary) {
                if (isset($this->data[$object]) && sizeof($this->data[$object])) {
                    $this->data[$object]['data'] = array_merge($data_ary['data'], $this->data[$object]['data']);
                } else {
                    $this->data[$object]['data'] = $data_ary['data'];
                }
            }
        }
        if ($fp = @fopen($this->cache_file, 'w')) {
            fwrite($fp, "<?php\nif (!defined('IN_PHPBB')) exit;\n\$this->queue_data = unserialize(" . var_export(serialize($this->data), true) . ");\n\n?>");
            fclose($fp);
            if (function_exists('opcache_invalidate')) {
                @opcache_invalidate($this->cache_file);
            }
            try {
                $this->filesystem->phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE);
            } catch (\phpbb\filesystem\exception\filesystem_exception $e) {
                // Do nothing
            }
            $this->data = array();
        }
        $lock->release();
    }