phpBB API Documentation
Class

phpbb\version_helper

class version_helper

Class to handle version checking and comparison

Methods

__construct(service $cache, config $config, file_downloader $file_downloader)

Constructor

version_helper set_file_location(string $host, string $path, string $file = 'versions.json', bool $use_ssl = false)

Set location to the file

version_helper set_current_version(string $version)

Set current version

version_helper force_stability(null|string $stability)

Over-ride the stability to force check to include unstable versions

mixed compare(string $version1, string $version2, string $operator = null)

Wrapper for version_compare() that allows using uppercase A and B for alpha and beta releases.

bool is_stable(string $version)

Check whether or not a version is "stable"

string get_latest_on_current_branch(bool $force_update = false, bool $force_cache = false)

Gets the latest version for the current branch the user is on

array get_update_on_branch(bool $force_update = false, bool $force_cache = false)

Gets the latest update for the current branch the user is on Will suggest versions from newer branches when EoL has been reached and/or version from newer branch is needed for having all known security issues fixed.

array get_ext_update_on_branch(bool $force_update = false, bool $force_cache = false)

Gets the latest extension update for the current phpBB branch the user is on Will suggest versions from newer branches when EoL has been reached and/or version from newer branch is needed for having all known security issues fixed.

array get_suggested_updates(bool $force_update = false, bool $force_cache = false)

Obtains the latest version information

array get_versions_matching_stability(bool $force_update = false, bool $force_cache = false)

Obtains the latest version information matching the stability of the current install

array get_versions(bool $force_update = false, bool $force_cache = false)

Obtains the latest version information

array validate_versions(array $versions_info)

Validate versions info input

Details

at line 87
public __construct(service $cache, config $config, file_downloader $file_downloader)

Constructor

Parameters

service $cache
config $config
file_downloader $file_downloader

at line 110
public version_helper set_file_location(string $host, string $path, string $file = 'versions.json', bool $use_ssl = false)

Set location to the file

Parameters

string $host Host (e.g. version.phpbb.com)
string $path Path to file (e.g. /phpbb)
string $file File name (Default: versions.json)
bool $use_ssl Use SSL or not (Default: false)

Return Value

version_helper

at line 126
public version_helper set_current_version(string $version)

Set current version

Parameters

string $version The current version

Return Value

version_helper

at line 140
public version_helper force_stability(null|string $stability)

Over-ride the stability to force check to include unstable versions

Parameters

null|string $stability Null to not force stability, 'unstable' or 'stable' to force the corresponding stability

Return Value

version_helper

at line 160
public mixed compare(string $version1, string $version2, string $operator = null)

Wrapper for version_compare() that allows using uppercase A and B for alpha and beta releases.

See http://www.php.net/manual/en/function.version-compare.php

Parameters

string $version1 First version number
string $version2 Second version number
string $operator Comparison operator (optional)

Return Value

mixed Boolean (true, false) if comparison operator is specified. Integer (-1, 0, 1) otherwise.

at line 173
public bool is_stable(string $version)

Check whether or not a version is "stable"

Stable means only numbers OR a pl release

Parameters

string $version

Return Value

bool Bool true or false

at line 194
public string get_latest_on_current_branch(bool $force_update = false, bool $force_cache = false)

Gets the latest version for the current branch the user is on

Parameters

bool $force_update Ignores cached data. Defaults to false.
bool $force_cache Force the use of the cache. Override $force_update.

Return Value

string

Exceptions

version_check_exception

at line 228
public array get_update_on_branch(bool $force_update = false, bool $force_cache = false)

Gets the latest update for the current branch the user is on Will suggest versions from newer branches when EoL has been reached and/or version from newer branch is needed for having all known security issues fixed.

Parameters

bool $force_update Ignores cached data. Defaults to false.
bool $force_cache Force the use of the cache. Override $force_update.

Return Value

array Version info or empty array if there are no updates

Exceptions

RuntimeException

at line 271
public array get_ext_update_on_branch(bool $force_update = false, bool $force_cache = false)

Gets the latest extension update for the current phpBB branch the user is on Will suggest versions from newer branches when EoL has been reached and/or version from newer branch is needed for having all known security issues fixed.

Parameters

bool $force_update Ignores cached data. Defaults to false.
bool $force_cache Force the use of the cache. Override $force_update.

Return Value

array Version info or empty array if there are no updates

Exceptions

RuntimeException

at line 331
public array get_suggested_updates(bool $force_update = false, bool $force_cache = false)

Obtains the latest version information

Parameters

bool $force_update Ignores cached data. Defaults to false.
bool $force_cache Force the use of the cache. Override $force_update.

Return Value

array

Exceptions

version_check_exception

at line 352
public array get_versions_matching_stability(bool $force_update = false, bool $force_cache = false)

Obtains the latest version information matching the stability of the current install

Parameters

bool $force_update Ignores cached data. Defaults to false.
bool $force_cache Force the use of the cache. Override $force_update.

Return Value

array Version info

Exceptions

version_check_exception

at line 372
public array get_versions(bool $force_update = false, bool $force_cache = false)

Obtains the latest version information

Parameters

bool $force_update Ignores cached data. Defaults to false.
bool $force_cache Force the use of the cache. Override $force_update.

Return Value

array Version info, includes stable and unstable data

Exceptions

version_check_exception

at line 429
public array validate_versions(array $versions_info)

Validate versions info input

Parameters

array $versions_info Decoded json data array. Will be modified and cleaned by this method

Return Value

array Versions info array

Exceptions

version_check_exception