Discussion:
[mapguide-users] fusion error - searchStr.test is not a function
sebafr
2018-04-04 17:03:17 UTC
Permalink
Today, all off ours mapguide servers (5 different places, 2 different
versions) happened this error:

fusionSF.js:132996 Uncaught TypeError: searchStr.test is not a function

Looking at fusionSF,js i found this code:

...
Array.prototype.find = function(searchStr) {
var returnArray = null;
for (i=0; i<this.length; i++) {
if (typeof(searchStr) == 'function') {
if (searchStr.test(this[i])) {
if (!returnArray) { returnArray = [] }
returnArray.push(i);
}
} else {
if (this[i]===searchStr) {
if (!returnArray) { returnArray = [] }
returnArray.push(i);
}
}
}
return returnArray;
};


Somebody knows whats happens ?

I comment the lines below and everything works again, apparently well, but I
wanted to know why?

...
Array.prototype.find = function(searchStr) {
var returnArray = null;
for (i=0; i<this.length; i++) {
if (typeof(searchStr) == 'function') {
//if (searchStr.test(this[i])) {
// if (!returnArray) { returnArray = [] }
// returnArray.push(i);
//}
} else {
if (this[i]===searchStr) {
if (!returnArray) { returnArray = [] }
returnArray.push(i);
}
}
}
return returnArray;
};

thanks in advance
sebafr



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
GordonL
2018-04-04 17:47:36 UTC
Permalink
I am pretty sure the problem is with the Google Maps API.

Remove all the Google layers and I think this solves the error.

I am looking into how to choose the older Google Map API Version so that we
can continue using Google Maps in mapguide.




--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
GordonL
2018-04-04 20:53:56 UTC
Permalink
Here's how I fixed my Google layers:

In Maestro, open your Flexible Web Layout (ApplicationDefinition)
Click Edit as XML
Scroll to the bottom
Replace the line:
<GoogleScript>http://maps.google.com/maps/api/js?sensor=false</GoogleScript>

with the following:

<GoogleScript>http://maps.google.com/maps/api/js?v=3.3&amp;sensor=true&amp;client=</GoogleScript>




--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
BMason
2018-04-04 22:01:35 UTC
Permalink
I get an error in the XML document (1272.25) when I replace that line
Gordan.



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
NMaj
2018-04-10 12:35:18 UTC
Permalink
I had the same problem with MapGuideMaestro 6.0m5 XML editor, so
MapGuideMaestro 6.0m8 fixed the problem.



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
sebafr
2018-04-05 13:43:20 UTC
Permalink
Many thanks for your response GordonL!

It worked, and now everything makes sense: google was the problem !!!

I change as you said, and the version (v parameter) was the solution.

The google api recommends putting only the main version and letting them
choose the last released minor version for us, there I put only: v=3 and
everything worked perfect.

Thanks again for your time.
Sebafr



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
Jackie Ng
2018-04-05 14:10:29 UTC
Permalink
Though your problem appears to be resolved, I'm personally curious as to what
searchStr is if it is passes the typeof(searchStr) == 'function' test.

If it's trying to call .test() on it, then one would think searchStr being
passed in is a regex (RegExp) as that's the only thing I know of that you
can call .test() against, but a regex would not pass the typeof(searchStr)
== 'function' test, so what is being passed in here?

- Jackie



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
sebafr
2018-04-05 18:02:42 UTC
Permalink
That's a good discussion, Jackie!
I think 'test' is a method of the searchstr object that derives from
Array.prototype.find.
Testing, after Gordon's tips, on handling the versions in google api, I
noticed that the latest version is assumed whenever no version is reported
in the google api call. The last version in development is 3.32.8 and this
searchstr.temp function does not exist in this context and for some reason,
in the load of the google map, this routine that runs the searchStr.temp is
executed and therefore gives the commented error. When we use any other
version before that, in the map load, it simply does not pass through these
lines in fusionSF.js, that is, it does not give an error, but it does not
mean that it exists, but that simply in the previous versions of google api
this routine is not called. Now why is running this now, only the google
team could respond.
Best Regards
Sebafr



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
Jackie Ng
2018-04-09 09:43:36 UTC
Permalink
I'll make a patch release of Fusion shortly to include this fix.

Though my fix will be to test for both searchStr and searchStr.test before
calling it, instead of removing that whole if block, on the extreme
off-chance that something should still be hitting down this code path.

- Jackie



--
Sent from: http://osgeo-org.1560.x6.nabble.com/MapGuide-Users-f4182607.html
Loading...