Skip to content

Commit

Permalink
Merge pull request #8 from developvi/dev
Browse files Browse the repository at this point in the history
version 5.9.2
  • Loading branch information
eslam-dev authored Dec 1, 2024
2 parents afbdda5 + d4705bf commit 81cbcc4
Show file tree
Hide file tree
Showing 36 changed files with 597 additions and 206 deletions.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,50 @@ Note: Even though the entire git development history isn't available on github,
[Friendly Release Notes](https://wpclouddeploy.com/category/release-notes/)

## Change Log ##

5.9.2
----

* Tweak: Renamed function custom_map_meta_cap_for_eslam to custom_map_meta_cap_for_server_access for better clarity and alignment with naming conventions.

* Tweak: Updated the label for ubuntu2404lts from "Ubuntu 24.04 LTS (Important Restrictions - See Docs!)" to "Ubuntu 24.04 LTS" for cleaner presentation.

* New: Added support for PHP 8.4 in various components, including version checks, configuration files, and logging. Updated scripts for installation and management of PHP 8.4.

* New: Added support for PHP 8.4 in server preparation script, including updates to php.ini configurations and Redis installation.

* Enh: Refactored get_wp_versions to optimize version retrieval by dynamically appending the version parameter to the API request (?version=$min_version), ensuring only relevant versions are fetched directly from the source, thereby eliminating the need for local filtering with array_filter and version_compare

* Fix: Update passwordless link generation to use domain variable instead of username

* Enh: Added 'default' => array() to 'logging_and_tracing_types_debug_log' and 'logging_and_tracing_types' fields to properly initialize default selections, ensuring that no log types are pre-selected by default. This avoids potential database performance issues caused by logging all types unnecessarily.

* Fix: Ensure exclude message text is an array or object before processing to prevent potential errors in logging logic
* Fix: Comment out the command to stop PHP-FPM service during domain change to prevent unintended service disruption
* New: Added PayPal donation and Discord community links to plugin action links
5.9.1
----
* Enh: Optimized post retrieval in `includes/templates/sent_email_details_popup.php` by replacing get_posts with get_post for improved performance and reduced memory usage.
* Enh: Improved get_server_name function to prioritize fetching the server name from the wpcd_server_name meta field, with a fallback to the post title for consistency and better data handling.

* Enh: Optimized get_server_id_by_instance_id function by replacing get_posts with WP_Query for better performance and scalability. Limited results to a single post and retrieved only post IDs to reduce overhead. Improved logic to handle multiple results gracefully.

* Enh: Optimized get_app_count function by replacing get_posts with WP_Query, limiting results to IDs only, and using found_posts to reduce memory usage and improve performance.

* Enh: Improved wpcd_sent_emails_list_pagination by switching from get_posts to WP_Query for efficient querying and better performance. Optimized logic for retrieving total counts and paginated results, reducing memory usage and improving scalability.

* Enh: Improved notification retrieval by replacing get_posts with get_post for better performance and standardized metadata access with get_post_meta for consistency and efficiency.

* Enh: Optimized wpcd_is_server_available_for_commands by replacing get_posts with WP_Query, limiting results to a single post, and reducing memory usage with fields => 'ids'. Improved overall performance and scalability.

* Enh: Simplified wpcd_get_permissions by directly accessing post titles from the WP_Post object and handling IDs efficiently when fields => 'ids' is used. Improved code readability and performance.

* Enh: Refactored wpcd_get_permission_groups to use WP_Query with optional fields => 'ids', improving performance and memory efficiency. Simplified metadata and title retrieval by accessing the WP_Post object directly.

* Enh: Replaced get_posts with WP_Query in WPCD_POSTS_TEAM class for improved performance and memory efficiency. Limited results to a single post and updated logic for count retrieval.



5.9.0
-----
* Fix : the caching issue related to checking the plugin version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,7 @@ public function server_fields() {
'8.1' => '8.1',
'8.2' => '8.2',
'8.3' => '8.3',
'8.4' => '8.4',
),
'std' => ( array( '5.6', '7.1', '7.2', '7.3', '8.0' ) ),
'select_all_none' => true,
Expand Down Expand Up @@ -1521,6 +1522,7 @@ public function site_fields() {
'7.4' => '7.4',
'8.2' => '8.2',
'8.3' => '8.3',
'8.4' => '8.4',
),
'tab' => 'wordpress-app-sites',
),
Expand Down
115 changes: 78 additions & 37 deletions includes/core/apps/wordpress-app/class-wordpress-app.php
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,14 @@ public static function get_wp_versions()
$versions = get_transient('developvi_wp_versions');

if (false === $versions) {
$min_version = trim(wpcd_get_option('wpcd_allowed_min_wp_version'));
if (empty($min_version)) {
$min_version = '6.1.4';
}
$min_version = apply_filters('wpcd_allowed_min_wp_version', $min_version);

// Make a request to fetch the latest WP versions
$response = wp_remote_get('https://api.wordpress.org/core/version-check/1.7/');
$response = wp_remote_get("https://api.wordpress.org/core/version-check/1.7/?version=$min_version");

// Return if the request was unsuccessful
if (200 !== wp_remote_retrieve_response_code($response)) {
Expand All @@ -773,16 +779,7 @@ public static function get_wp_versions()
$body = json_decode(wp_remote_retrieve_body($response), true);
$versions = array_column($body['offers'], 'version');
$versions[] = 'latest';
$min_version = trim(wpcd_get_option('wpcd_allowed_min_wp_version'));
if (empty($min_version)) {
$min_version = '6.1.4';
}
$min_version = apply_filters('wpcd_allowed_min_wp_version', $min_version);

// Filter versions greater than or equal to $min_version
$versions = array_filter($versions, function ($version) use ($min_version) {
return version_compare($version, $min_version, '>=');
});


// Sort versions in reverse order
rsort($versions);
Expand Down Expand Up @@ -1297,14 +1294,40 @@ public function is_php_83_installed( $server_id ) {

return false;
}

/**
* Returns a boolean true/false if PHP 83 is supposed to be installed.
*
* @param int $server_id ID of server being interrogated.
*
* @return boolean
*/
public function is_php_84_installed( $server_id ) {

$initial_plugin_version = $this->get_server_meta_by_app_id( $server_id, 'wpcd_server_plugin_initial_version', true ); // This function is smart enough to know if the ID being passed is a server or app id and adjust accordingly.

if ( version_compare( $initial_plugin_version, '5.9.1' ) > -1 ) {
// Versions of the plugin after 5.9.1 automatically install PHP 8.4.
return true;
} else {
// See if it was manually installed via an upgrade process - which would leave a meta field value behind on the server CPT record.
$is_php84_installed = (bool) $this->get_server_meta_by_app_id( $server_id, 'wpcd_server_php84_installed', true ); // This function is smart enough to know if the ID being passed is a server or app id and adjust accordingly.
if ( true === $is_php84_installed ) {
return true;
} else {
return false;
}
}

return false;
}
/**
* Returns a boolean true/false if a particular PHP version is active.
* Version 4.16 and later of WPCD deactivated earlier versions of PHP
* by default. Only if the user explicitly activated it was it enabled.
*
* @param int $server_id ID of server being interrogated.
* @param string $php_version PHP version - eg: php56, php71, php72, php73, php74, php81, php82, php83 etc.
* @param string $php_version PHP version - eg: php56, php71, php72, php73, php74, php81, php82, php83, php84 etc.
*
* @return boolean
*/
Expand Down Expand Up @@ -1347,6 +1370,11 @@ public function is_php_version_active( $server_id, $php_version ) {
$return = false;
}
break;
case 'php84':
if ( ! $this->is_php_84_installed( $server_id ) ) {
$return = false;
}
break;
}
}

Expand Down Expand Up @@ -2080,6 +2108,12 @@ public function get_php_versions( $id ) {
} else {
$php83 = array();
}
// Create single element array if php 8.4 is installed.
if ( $this->is_php_84_installed( $id ) ) {
$php84 = array( '8.4' => '8.4' );
} else {
$php84 = array();
}

// Array of other PHP versions.
switch ( $webserver_type ) {
Expand Down Expand Up @@ -2139,7 +2173,8 @@ public function get_php_versions( $id ) {
$php80,
$php81,
$php82,
$php83
$php83,
$php84,
);

// Filter out inactive versions. Only applies to NGINX. OLS always have all versions listed in the above switch statement active.
Expand All @@ -2156,7 +2191,8 @@ public function get_php_versions( $id ) {
'php80' => '8.0',
'php81' => '8.1',
'php82' => '8.2',
'php82' => '8.3',
'php83' => '8.3',
'php84' => '8.4',
);
foreach ( $php_versions as $php_version_key => $php_version ) {
if ( ! $this->is_php_version_active( $server_id, $php_version_key ) ) {
Expand Down Expand Up @@ -5139,6 +5175,7 @@ public function wpapp_wpcd_app_table_filtering() {
'8.1' => '8.1',
'8.2' => '8.2',
'8.3' => '8.3',
'8.4' => '8.4',
);
$php_version = $this->generate_meta_dropdown( 'wpapp_php_version', __( 'PHP Version', 'wpcd' ), $php_version_options );
echo wpcd_kses_select( $php_version );
Expand Down Expand Up @@ -5694,31 +5731,35 @@ public function wpcd_is_server_available_for_commands( $is_available, $server_id
return false;
}

// Ok, so far the server is still available for commands. Lets check the app records.
$args = array(
'post_type' => 'wpcd_app',
'post_status' => 'private',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'parent_post_id',
'value' => $server_id,
),
array(
'key' => 'wpcd_app_wordpress-app_action_status',
'value' => 'in-progress',
// Check app records for in-progress actions.
$args = array(
'post_type' => 'wpcd_app',
'post_status' => 'private',
'posts_per_page' => 1, // Limit to 1 result for efficiency
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'parent_post_id',
'value' => $server_id,
),
array(
'key' => 'wpcd_app_wordpress-app_action_status',
'value' => 'in-progress',
),
),
),
);

$app_posts = get_posts( $args );

if ( $app_posts ) {
return false;
'fields' => 'ids', // Fetch only IDs to reduce memory usage
);

$query = new WP_Query( $args );

// If there are any matching posts, the server is not available.
if ( $query->have_posts() ) {
return false;
}

return $is_available;
}

return $is_available;
}


/**
* Checks a special transient to see if aptget is running on the server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ public function register_post_type_fields( $metaboxes ) {
'7.4' => '7.4',
'8.2' => '8.2',
'8.3' => '8.3',
'8.4' => '8.4',
),
'save_field' => true,
'columns' => 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ then
then
echo $(date): "Warning: Installing PHP without the Imagick module because it is not yet available on $GV_UBUNTU_VERSION_STRING"
fi
phpversion=(7.4 8.0 8.1 8.2 8.3)
phpversion=(7.4 8.0 8.1 8.2 8.3 8.4)
for ver in "${phpversion[@]}"
do
echo $(date): ".....PHP $ver"
Expand Down Expand Up @@ -396,7 +396,7 @@ else
then
# Update php.ini file to increase filesize uploads allowed in WordPress
echo $(date): "Adding required entries in php.ini to allow for larger file uploads in WordPress..."
phpversion=(7.4 8.0 8.1 8.2 8.3)
phpversion=(7.4 8.0 8.1 8.2 8.3 8.4)
for ver in "${phpversion[@]}"
do
sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 25M/g" /etc/php/$ver/fpm/php.ini
Expand All @@ -415,9 +415,9 @@ else
sed -i "s/;opcache.validate_permission=0/opcache.validate_permission=1/g" /etc/php/$ver/fpm/php.ini
sed -i "s/;opcache.file_update_protection=2/opcache.file_update_protection=60/g" /etc/php/$ver/fpm/php.ini

# PHP 8.1, 8.2 & 8.3 needs a set of default functions added to its global php.ini file because its set to blank for some reason.
# PHP 8.1, 8.2 & 8.3 & 8.4 needs a set of default functions added to its global php.ini file because its set to blank for some reason.
# We're going to use the same list as 7.4.
if [ $ver = "8.1" ] || [ $ver = "8.2" ] || [ $ver = "8.3" ]; then
if [ $ver = "8.1" ] || [ $ver = "8.2" ] || [ $ver = "8.3" ] || [ $ver = "8.4" ]; then
echo "$(date): Setting global list of restricted php functions for PHP $ver"
sed -i "s/^disable_functions.*/disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,/g" /etc/php/$ver/fpm/php.ini
fi
Expand Down Expand Up @@ -856,9 +856,9 @@ fastcgi_hide_header X-Powered-By;
sed -i "s/;opcache.validate_permission=0/opcache.validate_permission=1/g" /usr/local/lsws/lsphp${phpver}/etc/php/${lsphpver}/litespeed/php.ini
sed -i "s/;opcache.file_update_protection=2/opcache.file_update_protection=60/g" /usr/local/lsws/lsphp${phpver}/etc/php/${lsphpver}/litespeed/php.ini

# PHP 8.1, 8.2 & 8.3 needs a set of default functions added to its global php.ini file because its set to blank for some reason.
# PHP 8.1, 8.2 & 8.3 & 8.4 needs a set of default functions added to its global php.ini file because its set to blank for some reason.
# We're going to use the same list as 7.4.
if [ $lsphpver = "8.1" ] || [ $lsphpver = "8.2" ] || [ $lsphpver = "8.3" ]; then
if [ $lsphpver = "8.1" ] || [ $lsphpver = "8.2" ] || [ $lsphpver = "8.3" ] || [ $lsphpver = "8.4" ]; then
echo "$(date): Setting global list of restricted php functions for PHP $lsphpver"
sed -i "s/^disable_functions.*/disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,/g" /usr/local/lsws/lsphp${phpver}/etc/php/${lsphpver}/litespeed/php.ini
fi
Expand Down Expand Up @@ -941,7 +941,7 @@ else
# Do Redis things related to NGINX
if [ "$webserver_type" = "nginx" ]
then
apt-get install -y php7.4-redis php8.0-redis php8.1-redis php8.2-redis php8.3-redis > /dev/null 2>&1
apt-get install -y php7.4-redis php8.0-redis php8.1-redis php8.2-redis php8.3-redis php8.4-redis > /dev/null 2>&1
fi

# Do Redis things related to OLS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ sed -i "s/$old_domain/$new_domain/g" /etc/wp-backup.conf 2> /dev/null
if [ "$g_webserver_type" = "nginx" ]
then
php_version=$(ls /etc/php/*/fpm/pool.d/$old_domain.conf | cut -d '/' -f 4)
systemctl stop php$php_version-fpm
# systemctl stop php$php_version-fpm
rename_nginx_site_confs
elif [ "$g_webserver_type" = "ols" ] || [ "$g_webserver_type" = "ols-enterprise" ]
then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ then
#fi

# if /var/www/$domain exists, let the user know before overwriting
if [[ -d /var/www/$domain || -e /etc/nginx/sites-enabled/$domain || -e /etc/nginx/sites-available/$domain || -e /etc/php/5.6/fpm/pool.d/$domain.conf || -e /etc/php/7.1/fpm/pool.d/$domain.conf || -e /etc/php/7.2/fpm/pool.d/$domain.conf || -e /etc/php/7.3/fpm/pool.d/$domain.conf || -e /etc/php/7.4/fpm/pool.d/$domain.conf || -e /etc/php/8.0/fpm/pool.d/$domain.conf || -e /etc/php/8.1/fpm/pool.d/$domain.conf || -e /etc/php/8.2/fpm/pool.d/$domain.conf || -e /etc/php/8.3/fpm/pool.d/$domain.conf || -d ${VHDIR}/$domain ]]
if [[ -d /var/www/$domain || -e /etc/nginx/sites-enabled/$domain || -e /etc/nginx/sites-available/$domain || -e /etc/php/5.6/fpm/pool.d/$domain.conf || -e /etc/php/7.1/fpm/pool.d/$domain.conf || -e /etc/php/7.2/fpm/pool.d/$domain.conf || -e /etc/php/7.3/fpm/pool.d/$domain.conf || -e /etc/php/7.4/fpm/pool.d/$domain.conf || -e /etc/php/8.0/fpm/pool.d/$domain.conf || -e /etc/php/8.1/fpm/pool.d/$domain.conf || -e /etc/php/8.2/fpm/pool.d/$domain.conf || -e /etc/php/8.3/fpm/pool.d/$domain.conf || -e /etc/php/8.4/fpm/pool.d/$domain.conf || -d ${VHDIR}/$domain ]]
then
# we do the following to allow bypassing this check if the user sets $overwrite to "yes"
if [[ "$overwrite" != "yes" ]]
Expand Down
4 changes: 2 additions & 2 deletions includes/core/apps/wordpress-app/scripts/v1/raw/10-misc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ then
while [[ -z $module ]]
do
default_lsphpver=$(grep -sEo 'lsphp[0-9]{2}' $WEBCF|head -n1| sed 's|lsphp||'); # 74
default_php_version=$(echo $default_lsphpver | sed 's/^\(.\{1\}\)/\1./') # 7.0,7.1,7.2,7.3,7.4,8.0,8.1,8.2,8.3 etc
default_php_version=$(echo $default_lsphpver | sed 's/^\(.\{1\}\)/\1./') # 7.0,7.1,7.2,7.3,7.4,8.0,8.1,8.2,8.3,8.4 etc
ls /usr/local/lsws/lsphp${default_lsphpver}/etc/php/${default_php_version}/mods-disabled | sed 's/.ini//' | nl
echo
read -p "Select module: " site_number
Expand Down Expand Up @@ -830,7 +830,7 @@ then
if [ "$g_webserver_type" = "ols" ] || [ "$g_webserver_type" = "ols-enterprise" ]
then
default_lsphpver=$(grep -sEo 'lsphp[0-9]{2}' $WEBCF|head -n1| sed 's|lsphp||'); # 74
default_php_version=$(echo $default_lsphpver | sed 's/^\(.\{1\}\)/\1./') # 7.0,7.1,7.2,7.3,7.4,8.0,8.1,8.2,8.3 etc
default_php_version=$(echo $default_lsphpver | sed 's/^\(.\{1\}\)/\1./') # 7.0,7.1,7.2,7.3,7.4,8.0,8.1,8.2,8.3,8.4 etc
mkdir -p /usr/local/lsws/lsphp${default_lsphpver}/etc/php/${default_php_version}/mods-disabled
while [[ -z $module ]]
do
Expand Down
Loading

0 comments on commit 81cbcc4

Please sign in to comment.