Closed phptek closed 5 years ago
A simplified query that returns the expected single row:
SELECT * FROM "SomePage" WHERE (ST_Intersects(ST_GeomFromText('POLYGON((174.78122057099 -41.2900367890677,174.781886102042 -41.2902302628832,174.782658976811 -41.2896982085099,174.78289513299 -41.2898271917867,174.782701914298 -41.2902947540276,174.782852195503 -41.2904721043458,174.782487226862 -41.2910202750086,174.781113227272 -41.2906655768704,174.78122057099 -41.2900367890677))', 4326),"SomePage"."Location"))
One that doesn't work (containing multple SIlverStripe JOIN's)
SELECT DISTINCT "SiteTree_Live"."ClassName", "SiteTree_Live"."LastEdited", "SiteTree_Live"."Created", "SiteTree_Live"."CanViewType", "SiteTree_Live"."CanEditType", "SiteTree_Live"."Version", "SiteTree_Live"."URLSegment", "SiteTree_Live"."Title", "SiteTree_Live"."MenuTitle", "SiteTree_Live"."Content", "SiteTree_Live"."MetaDescription", "SiteTree_Live"."ExtraMeta", "SiteTree_Live"."ShowInMenus", "SiteTree_Live"."ShowInSearch", "SiteTree_Live"."Sort", "SiteTree_Live"."HasBrokenFile", "SiteTree_Live"."HasBrokenLink", "SiteTree_Live"."ReportClass", "SiteTree_Live"."ParentID", "Page_Live"."LandingPageSummary", "Page_Live"."LandingPageSummaryImageID", "SomePage_Live"."Type", "SomePage_Live"."Label", "SomePage_Live"."Address", "SomePage_Live"."Name", "SomePage_Live"."Abstract", ST_AsEWKT("SomePage_Live"."Location") "Location", "SiteTree_Live"."ID", CASE WHEN "SiteTree_Live"."ClassName" IS NOT NULL THEN "SiteTree_Live"."ClassName" ELSE E'SilverStripe\\CMS\\Model\\SiteTree' END AS "RecordClassName" FROM "SiteTree_Live" LEFT JOIN "Page_Live" ON "Page_Live"."ID" = "SiteTree_Live"."ID" LEFT JOIN "SomePage_Live" ON "SomePage_Live"."ID" = "SiteTree_Live"."ID" WHERE (ST_Intersects(ST_GeomFromText('POLYGON((174.78122057099 -41.2900367890677,174.781886102042 -41.2902302628832,174.782658976811 -41.2896982085099,174.78289513299 -41.2898271917867,174.782701914298 -41.2902947540276,174.782852195503 -41.2904721043458,174.782487226862 -41.2910202750086,174.781113227272 -41.2906655768704,174.78122057099 -41.2900367890677))', 4326),"SomePage_Live"."Location")) ORDER BY "SiteTree_Live"."Sort" ASC
I have traced this back to a failed JOIN
. For some reason ,using MapField
in updateCMSFields()
in a DataExtension
on Page
, failes to populate the "Location" field on the page's xx_Live table.
Sorry, I can't reproduce this issue. It is working fine for me:
Page.php with Geometry field saved and published successfully using the CMS.
To reproduce (using v1.1.3)
Page
with aLocation
field asGeometry
TestModel
as aDataObject
subclass, that also has aLocation
field asGeometry
and set that location value, as any polygon located within the Page's geometry, e.g. around the shape of Te Papa's building footprintPage
records, that intersect or are within the geometry of the oneTestModel
you just created, somethuing like this:Note: As discussed, there should prob be a unit-test to cover the
WithinGeo
filter :-)[UPDATE]
I was partly being an idiot, in that I was relying too hard on expected behviour. In a standard SilverStripe
FormField
subclass, changing the value, re-renders the "Publish" button, as SilverStripe detects that something has changed. It is this that isn't happening for theMapField
. SilverStripe simply wasn't recognising that a change had ocurred. Once I made a change to a different field, the "Publish" button highlighted itself, and publishing wrote the right Geometry string to the xx_Live table.