Title: PHP 8 Compatibility
Last modified: August 23, 2022

---

# PHP 8 Compatibility

 *  Resolved [nickiova](https://wordpress.org/support/users/nickiova/)
 * (@nickiova)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/php-8-compatibility-64/)
 * Hi there,
    Is the plugin PHP 8 compatible? We tried enabling PHP 8 on a site 
   using this plugin but caused a critical error when signing in so reverted back
   to PHP 7.4 which cleared up the issues.
 * See error message: [https://gyazo.com/d61202732939426f6dfc658dcd6f37e8](https://gyazo.com/d61202732939426f6dfc658dcd6f37e8)
 * Thanks!
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fphp-8-compatibility-64%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Contributor [Adam Salah](https://wordpress.org/support/users/adam1318/)
 * (@adam1318)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/php-8-compatibility-64/#post-15943384)
 * Hello, [@nickiova](https://wordpress.org/support/users/nickiova/)
 * Thank you for using our plugin and we appreciate this.
 * Actually, PHP 8 is not stable so far and it has a lot of compatibility issues.
   
   So, we suggest using PHP 7.4 until they push a clean PHP version.
 * Thank you and have a nice day.
 * Regards
 *  Thread Starter [nickiova](https://wordpress.org/support/users/nickiova/)
 * (@nickiova)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/php-8-compatibility-64/#post-15943776)
 * Thanks, [@adam1318](https://wordpress.org/support/users/adam1318/)!
 * That is good to know! Appreciate the response!
 *  [Matthieu](https://wordpress.org/support/users/theschappy/)
 * (@theschappy)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-compatibility-64/#post-16085006)
 * Hi there,
 * quick fix attached: just check whether fopen is not returning false in case.
 *     ```
       --- seo-redirection.org.php     2022-10-10 14:37:51.936208538 +0200
       +++ seo-redirection.php 2022-10-10 14:41:10.907284467 +0200
       @@ -238,11 +238,13 @@
                       if(is_readable($file))
                       {
                               $f = @fopen( $file, 'r+' );
       -                       $filestr = @fread($f , filesize($file));
       -                       if (strpos($filestr , $marker_name) === false)
       -                        {
       -                                insert_with_markers( $file,  $marker_name,  $content );
       -                        }
       +                       if ($f !== false) {
       +                               $filestr = @fread($f , filesize($file));
       +                               if (strpos($filestr , $marker_name) === false)
       +                                {
       +                                        insert_with_markers( $file,  $marker_name,  $content );
       +                                }
       +                       }
                       }else{
                               echo $file.' is not readable!';
                       }
       ```
   
 * Cheers!
 *  Plugin Author [osama.esh](https://wordpress.org/support/users/osamaesh/)
 * (@osamaesh)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/php-8-compatibility-64/#post-16089073)
 * Thank you for your help and feedback,
    version updated
 *  [Aaron Barraza](https://wordpress.org/support/users/aebs90/)
 * (@aebs90)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/php-8-compatibility-64/#post-16271428)
 * Hello!
 * The error is still in the plugin. The fix from [@theschappy](https://wordpress.org/support/users/theschappy/)
   is correct, but it was wrongly implemented.
 * If you see carefully, at the beggining of the lines he has some **–** (meaning
   this line should be removed) and **+** (meaning that line should be added).
 * So, the intention was to replace this:
 *     ```
       $filestr = @fread($f , filesize($file));
       if (strpos($filestr , $marker_name) === false)
       {
       		insert_with_markers( $file,  $marker_name,  $content );
       }
       ```
   
 * with this:
 *     ```
       if ($f !== false) {
       		$filestr = @fread($f , filesize($file));
       		if (strpos($filestr , $marker_name) === false)
       		{
       				insert_with_markers( $file,  $marker_name,  $content );
       		}
       }
       ```
   
 * Or in simple words, wrap the original code inside the `if ($f !== false) {` `}`
   conditional.
 * [@osamaesh](https://wordpress.org/support/users/osamaesh/) Is it possible to 
   make this change public? Because what was implemented was to duplicate the code
   lol:
 *     ```
       $f = @fopen( $file, 'r+' );
                              $filestr = @fread($f , filesize($file));
                              if (strpos($filestr , $marker_name) === false)
                               {
                                       insert_with_markers( $file,  $marker_name,  $content );
                               }
                              if ($f !== false) {
                                      $filestr = @fread($f , filesize($file));
                                      if (strpos($filestr , $marker_name) === false)
                                       {
                                               insert_with_markers( $file,  $marker_name,  $content );
                                       }
                              }
       ```
   
 * And the problem with duplicating the code, is that before the validation, the**
   fread()** is called, and on the scenarios where $f is false, that causes the 
   php fatal error.
 * Thank you all!
    -  This reply was modified 3 years, 6 months ago by [Aaron Barraza](https://wordpress.org/support/users/aebs90/).
      Reason: Added additional information
 *  Plugin Author [osama.esh](https://wordpress.org/support/users/osamaesh/)
 * (@osamaesh)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/php-8-compatibility-64/#post-16271891)
 * hello,
    thank you [@aebs90](https://wordpress.org/support/users/aebs90/) for 
   your hard work, fo sure yes, we will publish an update soon

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘PHP 8 Compatibility’ is closed to new replies.

 * ![](https://ps.w.org/seo-redirection/assets/icon-128x128.jpg?rev=983735)
 * [SEO Redirection Plugin - 301 Redirect Manager](https://wordpress.org/plugins/seo-redirection/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/seo-redirection/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/seo-redirection/)
 * [Active Topics](https://wordpress.org/support/plugin/seo-redirection/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/seo-redirection/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/seo-redirection/reviews/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * 8 replies
 * 5 participants
 * Last reply from: [osama.esh](https://wordpress.org/support/users/osamaesh/)
 * Last activity: [3 years, 6 months ago](https://wordpress.org/support/topic/php-8-compatibility-64/#post-16271891)
 * Status: resolved