Support » Plugin: OSM - OpenStreetMap » Fatal error in traceErrorMsg() on PHP 7.1.

  • Hi folks, one of my users encountered an error on a site that uses WPML (for multi-lingual pages) and OSM plugin. While creating a new translation of a page at /wp-admin/post.php?post=2&action=edit&lang=en they encountered a fatal PHP error: Fatal error: Uncaught Error: Using $this when not in object context in .../wordpress/wp-content/plugins/osm/osm.php on line 249 which was triggered by this OSM error: [OSM-Plugin-Error]:Array hast got wrong file extension (gpx, kml)!. While there may be other conflicts with these two plugins, fixing the fatal PHP error in the OSM plugin allows the editor to load successfully on PHP 7.1.29 even though the OSM error flashes a bit.

    Here is a patch to fix the fatal error in the OSM plugin:

    diff --git a/wp-content/plugins/osm/osm.php b/wp-content/plugins/osm/osm.php
    index 60a0dd6..11b71c4 100644
    --- a/wp-content/plugins/osm/osm.php
    +++ b/wp-content/plugins/osm/osm.php
    @@ -246,7 +246,7 @@ class Osm
     
       public static function traceErrorMsg($e = '')
       {
    -   if ($this == null){
    +   if (!isset($this) || $this == null){
          return $e;
        }
        $EMsg = $this->ErrorMsg->get_error_message($e);
    
    • This topic was modified 5 months, 1 week ago by Adam Franco. Reason: fix code formatting
Viewing 4 replies - 1 through 4 (of 4 total)
  • Upon further investigation, this error was triggered by editing an already saved post with an OSM shortcode that includes a broken KML link. I’m not sure how this got saved previously, but having the file_list parameter end in just / instead of an actual filename seemed to initiate the sequence of errors.

    [osm_map_v3 map_center="4.176581, -80.231335" zoom="3" width="90%" height="800" control="scaleline" file_list="http://site.example.edu/files/2019/06/"]

    Plugin Author MiKa

    (@photoweblog)

    Hello @adamfranco,

    thanks for this!!!

    Will consider it at the next version.

    Br, MiKa

    Hello I have the same problem…
    What exactly do I do? (I’m not a developer, I do not know what to do with copy-paste if you tell me exactly) 🙂
    Thanks in advance,

    Dominique (hello from France)

    ======
    Une erreur de type E_ERROR a été causée dans la ligne 249 du fichier /home/artibydom/sites/acadie.artybi.com/wp-content/plugins/osm/osm.php. Message d’erreur : Uncaught Error: Using $this when not in object context in /home/artibydom/sites/acadie.artybi.com/wp-content/plugins/osm/osm.php:249
    Stack trace:
    #0 /home/artibydom/sites/acadie.artybi.com/wp-content/plugins/osm/osm.php(268): Osm::traceErrorMsg(‘[OL3_createMark…’)
    #1 /home/artibydom/sites/acadie.artybi.com/wp-content/plugins/osm/osm.php(513): Osm::traceText(1, ‘[OL3_createMark…’)
    #2 /home/artibydom/sites/acadie.artybi.com/wp-content/plugins/osm/osm_map_v3/osm-sc-osm_map_v3.php(474): Osm::OL3_createMarkerList(‘osm_l’, ‘CommunautxC3xA9s’, ‘Osm_None’, ‘post’, ‘Osm_All’, ‘category’)
    #3 /home/artibydom/sites/acadie.artybi.com/wp-content/plugins/osm/osm.php(869): include(‘/home/artibydom…’)
    #4 /home/artibydom/sites/acadie.artybi.com/wp-includes/shortcodes.php(325): Osm->sc_OL3JS(Array, ”, ‘osm_map_v3’)
    #5 [internal function]: do_shortcode_tag(Array)
    #6 /home/artibydom/sites/acadie.artybi.com/wp-includes/shortcodes.php(199): preg_replace_callback(‘/\[(\[?)(osm_ma…’, ‘do_shortcode_ta…’, ‘n

    Plugin Author MiKa

    (@photoweblog)

    Hello @adamfranco

    again thanks – hope it is fixed with the last version.

    BTW: If you like the plugin, feel free to support us with your rate:

    https://wordpress.org/support/plugin/osm/reviews/

    Br, Mika

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.