• Hi, there!

    The plugin is working fine in all features except by clearing logs.

    All locked IP’s can be unlocked easily if I want but when I try to clear the log it turns settings page blank, without any content.

    When I refresh the page all contents come back but ‘Lockout log’ remains intact, without clearing.

    I’ve tried deactivate e reactivate the plugin but nothing changes.

    Any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author WPChef

    (@wpchefgadget)

    Hi Marcos,

    Do you see any errors in the browser or error_log (it should be enabled first to see the errors)?

    [ Signature deleted ]

    • This reply was modified 6 years, 3 months ago by Jan Dembowski.
    Thread Starter Marcos Blatt

    (@marcos-blatt)

    Hi WpChef,

    How can I enable errors in the browser or error_log?

    I’ve used Chrome, Firefox and Opera and I haven’t seen anything wrong, only that issue in the plugin.

    Note 1: I’ve tried to deactivate all other plugins except Limit Login Attempts Reloaded but the issue has remained the same.

    Note 2: WordPress is up-to-date (4.9.2).

    Thanks.

    Plugin Author WPChef

    (@wpchefgadget)

    Hi Marcos,

    In the wp-config.php file replace this line of code

    define('WP_DEBUG', false);

    with this:

    define('WP_DEBUG', true);
    define('WP_DEBUG_LOG', true);
    define('WP_DEBUG_DISPLAY', true);

    After that click the save button on the plugin’s settings page again and see if you get any PHP errors on the screen or in the error_log file in the root folder of your site.

    [ Signature deleted ]

    • This reply was modified 6 years, 3 months ago by Jan Dembowski.
    Thread Starter Marcos Blatt

    (@marcos-blatt)

    Hi @wpchefgadget

    I’ve done everything you asked for.

    With only your plugin activated I’ve clicked the ‘Save options’ button and nothing has happened.

    When I’ve tried clear the logs the page has turned blank but with this message below:

    Catchable fatal error: Argument 1 passed to WPaaS\Hotfixes::clean_limit_login_attempts() must be of the type array, string given in /home/content/p3pnexwpnas08_data01/79/41571279/html/wp-content/mu-plugins/gd-system-plugin/includes/class-hotfixes.php on line 187

    My blog is hosted @ Media Temple and that file class-hotfixes.php is blocked for changes.

    The content of that file is the following:

    <?php
    
    namespace WPaaS;
    
    if ( ! defined( 'ABSPATH' ) ) {
    
    	exit;
    
    }
    
    final class Hotfixes {
    
    	/**
    	 * Class constructor.
    	 */
    	public function __construct() {
    
    		/**
    		 * Define the WP101 API key from the WPaaS config.
    		 */
    		if ( ! defined( 'GD_WP101_API_KEY' ) ) {
    
    			define( 'GD_WP101_API_KEY', Plugin::config( 'wp101_key' ) );
    
    		}
    
    		/**
    		 * WP Easy Mode.
    		 *
    		 * Deactivate all plugins on quit, except WP101.
    		 */
    		add_filter( 'wpem_deactivate_plugins_on_quit', function( $plugins ) {
    
    			if ( ! function_exists( 'get_plugins' ) ) {
    
    				require_once ABSPATH . 'wp-admin/includes/plugin.php';
    
    			}
    
    			$plugins = get_plugins();
    
    			unset( $plugins['wp101-video-tutorial/wp101-video-tutorial.php'] );
    			unset( $plugins['search-engine-visibility/sev.php'] );
    
    			return array_keys( $plugins );
    
    		} );
    
    		/**
    		 * WP Popular Posts.
    		 *
    		 * This makes it perform much better especially on high traffic sites.
    		 */
    		add_filter( 'wpp_data_sampling', '__return_true' );
    
    		/**
    		 * Limit Login Attempts.
    		 */
    		add_filter( 'pre_update_option_limit_login_lockouts',      [ $this, 'clean_limit_login_attempts' ], PHP_INT_MAX );
    		add_filter( 'pre_update_option_limit_login_retries_valid', [ $this, 'clean_limit_login_attempts' ], PHP_INT_MAX );
    		add_filter( 'pre_update_option_limit_login_retries',       [ $this, 'clean_limit_login_attempts' ], PHP_INT_MAX );
    		add_filter( 'pre_update_option_limit_login_logged',        [ $this, 'clean_limit_login_attempts' ], PHP_INT_MAX );
    
    		/**
    		 * Jetpack.
    		 */
    		if ( Plugin::is_staging_site() ) {
    
    			// Prevent identity crisis from triggering on staging sites.
    			add_filter( 'jetpack_has_identity_crisis', '__return_false', PHP_INT_MAX );
    
    		}
    
    		// Hide the Jetpack updates screen nag.
    		add_filter( 'option_jetpack_options', [ $this, 'remove_jetpack_nag' ], PHP_INT_MAX );
    
    		/**
    		 * Disable sslverify for remote requests on non-production environments.
    		 */
    		add_filter( 'http_request_args', function( array $args ) {
    
    			if ( ! Plugin::is_env( 'prod' ) ) {
    
    				$args['sslverify'] = false;
    
    			}
    
    			return $args;
    
    		}, PHP_INT_MAX );
    
    		/**
    		 * Override the GEM API base URL on non-production environments.
    		 */
    		if ( ! Plugin::is_env( 'prod' ) ) {
    
    			add_filter( 'gem_api_base_url', function( $url ) {
    
    				return sprintf( 'https://gem.%s-godaddy.com/', Plugin::get_env() );
    
    			}, PHP_INT_MAX );
    
    		}
    
    		/**
    		 * WP-Cron.
    		 */
    		if ( defined( 'WP_CLI' ) && WP_CLI ) {
    
    			$this->blacklist_cron_event_hooks();
    
    		}
    
    		$this->add_cron_restrictions();
    
    		/**
    		 * Remove the author credit from GoDaddy themes for other brands.
    		 */
    		if ( ! Plugin::is_gd() ) {
    
    			add_filter( 'primer_author_credit',               '__return_false' );
    			add_filter( 'primer_show_site_identity_settings', '__return_false' );
    			add_filter( 'wpem_show_theme_byline',             '__return_false' );
    
    		}
    
    		/**
    		 * Change the terms of service URL depending on the brand.
    		 */
    		$tos_urls = [
    			'gd'       => 'https://www.godaddy.com/agreements/showdoc.aspx?pageid=Hosting_SA',
    			'mt'       => 'https://mediatemple.net/legal/terms-of-service/',
    			'reseller' => sprintf(
    				'https://www.secureserver.net/agreements/showdoc.aspx?pageid=Hosting_SA&prog_id=%d',
    				Plugin::reseller_id()
    			),
    		];
    
    		if ( $tos_url = Plugin::use_brand_value( $tos_urls ) ) {
    
    			$return_tos_url = function() use ( $tos_url ) { return $tos_url; };
    
    			add_filter( 'wpem_tos_url',         $return_tos_url );
    			add_filter( 'stock_photos_tos_url', $return_tos_url );
    
    		}
    
    	}
    
    	/**
    	 * Hide the Jetpack updates screen nag.
    	 *
    	 * @filter option_jetpack_options
    	 *
    	 * @param  array $options
    	 *
    	 * @return array
    	 */
    	public function remove_jetpack_nag( $options ) {
    
    		if ( $options && empty( $options['hide_jitm']['manage'] ) || 'hide' !== $options['hide_jitm']['manage'] ) {
    
    			$options['hide_jitm']['manage'] = 'hide';
    
    		}
    
    		return $options;
    
    	}
    
    	/**
    	 * Clean up options for Limit Login Attempts.
    	 *
    	 * On very active sites these can become massive
    	 * arrays that turn into massive strings and break
    	 * MySQL because of packet size limitations.
    	 *
    	 * @filter pre_update_option_limit_login_lockouts
    	 * @filter pre_update_option_limit_login_retries_valid
    	 * @filter pre_update_option_limit_login_retries
    	 * @filter pre_update_option_limit_login_logged
    	 *
    	 * @param  array $value
    	 *
    	 * @return array
    	 */
    	public function clean_limit_login_attempts( array $value ) {
    
    		if ( count( $value ) < 250 ) {
    
    			return $value;
    
    		}
    
    		$sorting_func = function( $a, $b ) {
    
    			if ( is_array( $b ) ) {
    
    				if ( count( $a ) == count( $b ) ) {
    
    					return 0;
    
    				}
    
    				return ( count( $a ) < count( $b ) ) ? - 1 : 1;
    
    			}
    
    			if ( $a == $b ) {
    
    				return 0;
    
    			}
    
    			return ( $a < $b ) ? -1 : 1;
    
    		};
    
    		uasort( $value, $sorting_func );
    
    		return array_slice( $value, -200 );
    
    	}
    
    	/**
    	 * Blacklist cron event hooks.
    	 *
    	 * Note: Should only run when using WP-CLI.
    	 */
    	private function blacklist_cron_event_hooks() {
    
    		global $wpdb, $wpaas_cron_event_temp_blacklist;
    
    		$blacklist = [
    			'wp_version_check',
    		];
    
    		// Get temporary blacklist transients
    		$transients = (array) $wpdb->get_results(
    			"SELECT
    			option_name,
    			option_value
    			FROM {$wpdb->options}
    			WHERE option_name
    			LIKE '_transient_wpaas_skip_cron_%';"
    		);
    
    		// Scrub array of key prefixes and expired transients
    		foreach ( $transients as $key => $transient ) {
    
    			$transients[ $key ]->option_name = preg_filter( '/^_transient_/', '', $transient->option_name );
    
    			if ( false === get_transient( $transient->option_name ) ) {
    
    				unset( $transients[ $key ] );
    
    			}
    
    		}
    
    		// Store in global, used by 'cron event wpaas reset' subcommand
    		$wpaas_cron_event_temp_blacklist = array_combine(
    			wp_list_pluck( $transients, 'option_name' ),
    			wp_list_pluck( $transients, 'option_value' )
    		);
    
    		// Merge temporary blacklist into core blacklist
    		$blacklist = array_merge( $blacklist, array_values( $wpaas_cron_event_temp_blacklist ) );
    
    		// Remove blacklisted events from the crons array
    		add_filter( 'option_cron', function( $crons ) use ( $blacklist ) {
    
    			if ( ! $crons ) {
    
    				return $crons;
    
    			}
    
    			foreach ( (array) $crons as $timestamp => $events ) {
    
    				foreach ( (array) $events as $hook => $event ) {
    
    					if ( in_array( $hook, $blacklist ) ) {
    
    						unset( $crons[ $timestamp ][ $hook ] );
    
    					}
    
    				}
    
    				if ( ! $events ) {
    
    					unset( $crons[ $timestamp ] );
    
    				}
    
    			}
    
    			return (array) $crons;
    
    		}, PHP_INT_MAX );
    
    	}
    
    	/**
    	 * Implement WPaaS restrictions on cron events
    	 *
    	 * since @NEXT
    	 */
    	private function add_cron_restrictions() {
    
    		/**
    		 * If the wp_version_check cron was ever scheduled before
    		 * we unschedule it since we are on a managed platform.
    		 */
    		if ( false !== wp_next_scheduled( 'wp_version_check' ) ) {
    
    			wp_clear_scheduled_hook( 'wp_version_check' );
    
    		}
    
    		add_filter( 'schedule_event', function ( $event ) {
    
    			$blacklisted_hooks = [
    				'wp_version_check',
    				'wp_maybe_auto_update',
    			];
    
    			if ( ! isset( $event->hook ) || in_array( $event->hook, $blacklisted_hooks ) ) {
    
    				return false;
    
    			}
    
    			return $event;
    
    		} );
    
    	}
    
    }

    In the line 187 we have the following:

    	public function clean_limit_login_attempts( array $value ) {
    
    		if ( count( $value ) < 250 ) {
    
    			return $value;
    
    		}

    Any ideas???

    Thread Starter Marcos Blatt

    (@marcos-blatt)

    Hi @wpchefgadget,

    Today I updated the plugin to the latest version (2.7.0) but the problem remains.

    If you can’t help me with the solution I’d like to know how can I clear those logs manually in database.

    Which specific table in DB should I “clean” to clear only those logs?

    Thanks in advance.

    • This reply was modified 6 years, 6 months ago by Marcos Blatt.
    • This reply was modified 6 years, 6 months ago by Marcos Blatt.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘‘Clear log’ feature NOT working’ is closed to new replies.