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=""]

    Plugin Author MiKa


    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/ Message d’erreur : Uncaught Error: Using $this when not in object context in /home/artibydom/sites/
    Stack trace:
    #0 /home/artibydom/sites/ Osm::traceErrorMsg(‘[OL3_createMark…’)
    #1 /home/artibydom/sites/ Osm::traceText(1, ‘[OL3_createMark…’)
    #2 /home/artibydom/sites/ Osm::OL3_createMarkerList(‘osm_l’, ‘CommunautxC3xA9s’, ‘Osm_None’, ‘post’, ‘Osm_All’, ‘category’)
    #3 /home/artibydom/sites/ include(‘/home/artibydom…’)
    #4 /home/artibydom/sites/ Osm->sc_OL3JS(Array, ”, ‘osm_map_v3’)
    #5 [internal function]: do_shortcode_tag(Array)
    #6 /home/artibydom/sites/ preg_replace_callback(‘/\[(\[?)(osm_ma…’, ‘do_shortcode_ta…’, ‘n

    Plugin Author MiKa


    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:

    Br, Mika

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