Title: Patch for PHP 8 error
Last modified: August 14, 2023

---

# Patch for PHP 8 error

 *  [groggu](https://wordpress.org/support/users/groggu/)
 * (@groggu)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/patch-for-php-8-error/)
 * This plugin no longer functions correctly in PHP 8 due to changes in the _min_
   and _max_ functions. If you are able (or are willing) to update the code, you
   can edit the wp-gpx-maps-util.php file and wrap the problem area in code that
   checks that the $_ele, $_dist, and $_time arrays exist before applying the functions.
 * **The original code** (starting at line 379) is
 *     ```wp-block-code
               $points->maxEle      = max( $_ele );
               $points->minEle      = min( $_ele );
               $points->totalLength = max( $_dist );
               $points->maxTime     = max( $_time );
               $points->minTime     = min( $_time );
       ```
   
 * This is the **updated code**
 *     ```wp-block-code
               if (is_array($_ele) && count($_ele) > 0) {
                   $points->maxEle      = max( $_ele );
                   $points->minEle      = min( $_ele );                
               }
               if (is_array($_dist) && count($_dist) > 0) {
                   $points->totalLength = max( $_dist );
               }
               if (is_array($_time) && count($_time) > 0) {
                   $points->maxTime     = max( $_time );
                   $points->minTime     = min( $_time );
               }
       ```
   
 * Hopefully the original dev will create a new PHP 8 compatible version soon.

The topic ‘Patch for PHP 8 error’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-gpx-maps_bcbfb3.svg)
 * [WP GPX Maps](https://wordpress.org/plugins/wp-gpx-maps/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-gpx-maps/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-gpx-maps/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-gpx-maps/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-gpx-maps/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-gpx-maps/reviews/)

 * 2 replies
 * 4 participants
 * Last reply from: [groggu](https://wordpress.org/support/users/groggu/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/patch-for-php-8-error/)
 * Status: not a support question