• Resolved ucsendre

    (@ucsendre)


    Dear @vmarko

    I have a lot of the below warning lines in my debug log:
    PHP Warning: strpos(): Empty needle in /var/www/vhosts/domain.tld/httpdocs/wp-content/plugins/w3-total-cache/UserExperience_LazyLoad_Mutator.php on line 240

    This means you should check if the needle in strpos function is empty before searching for it as searching for an empty string does not make sense.

    Please change the below function in UserExperience_LazyLoad_Mutator.php:

    	private function is_content_excluded( $content ) {
    		foreach ( $this->excludes as $w ) {
    			if ( strpos( $content, $w ) !== FALSE ) {
    				return true;
    			}
    		}
    
    		return false;
    	}

    like this:

    	private function is_content_excluded( $content ) {
    		foreach ( $this->excludes as $w ) {
    			if ( !empty($w) ) {
    				if ( strpos( $content, $w ) !== FALSE ) {
    					return true;
    				}
    			}
    		}
    
    		return false;
    	}

    This will save a lot of debug.log warnings for us.
    Thank you!

    Best regards,
    Endre

Viewing 1 replies (of 1 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @ucsendre

    Thank you for reaching out and suggesting the changes.
    I’ve created a pull request for this and once approved it will be fixed in future releases. Hopefully, the next update, that will be released soon.
    Thanks!

Viewing 1 replies (of 1 total)
  • The topic ‘searching for an empty needle in strpos() is useless’ is closed to new replies.