omeka / plugin-Geolocation

Allows administrative users to save geolocation data for an individual item. The plugin generates a Google map containing items with geolocation data and a web page for displaying the map.
http://omeka.org/codex/Plugins/Geolocation
12 stars 20 forks source link

Search using proximity broken when using Omeka 2.3.1 #35

Closed mjlassila closed 9 years ago

mjlassila commented 9 years ago

Search using address proximity (in /items/browse) gives the following error in Omeka 2.3.1 when using the current version (master branch) of the plugin. In the admin map browse view (admin/geolocation/map/browse?) search works normally.

With Omeka 2.2.2 and the same version of plugin there's no error so it seems that the error is somehow related to recent changes in Omeka core.

exception 'Zend_Db_Statement_Mysqli_Exception' with message 'Mysqli prepare error: Unknown column '    COS(RADIANS(60.631811)) *' in 'field list'' in /home/omeka/omeka-2.3/application/libraries/Zend/Db/Statement/Mysqli.php:77
Stack trace:
#0 /home/omeka/omeka-2.3/application/libraries/Zend/Db/Statement.php(115): Zend_Db_Statement_Mysqli->_prepare('SELECT `items`....')
#1 /home/omeka/omeka-2.3/application/libraries/Zend/Db/Adapter/Mysqli.php(388): Zend_Db_Statement->__construct(Object(Zend_Db_Adapter_Mysqli), 'SELECT `items`....')
#2 /home/omeka/omeka-2.3/application/libraries/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Adapter_Mysqli->prepare('SELECT `items`....')
#3 [internal function]: Zend_Db_Adapter_Abstract->query(Object(Omeka_Db_Select), Array)
#4 /home/omeka/omeka-2.3/application/libraries/Omeka/Db.php(79): call_user_func_array(Array, Array)
#5 /home/omeka/omeka-2.3/application/libraries/Omeka/Db/Table.php(648): Omeka_Db->__call('query', Array)
#6 /home/omeka/omeka-2.3/application/libraries/Omeka/Db/Table.php(648): Omeka_Db->query(Object(Omeka_Db_Select), Array)
#7 /home/omeka/omeka-2.3/application/libraries/Omeka/Db/Table.php(281): Omeka_Db_Table->fetchObjects(Object(Omeka_Db_Select))
#8 [internal function]: Omeka_Db_Table->findBy(Array, 10, 1)
#9 /home/omeka/omeka-2.3/application/controllers/helpers/Db.php(59): call_user_func_array(Array, Array)
#10 /home/omeka/omeka-2.3/application/libraries/Omeka/Controller/AbstractActionController.php(128): Omeka_Controller_Action_Helper_Db->__call('findBy', Array)
#11 /home/omeka/omeka-2.3/application/libraries/Omeka/Controller/AbstractActionController.php(128): Omeka_Controller_Action_Helper_Db->findBy(Array, 10, 1)
#12 /home/omeka/omeka-2.3/application/controllers/ItemsController.php(183): Omeka_Controller_AbstractActionController->browseAction()
#13 /home/omeka/omeka-2.3/application/libraries/Zend/Controller/Action.php(516): ItemsController->browseAction()
#14 /home/omeka/omeka-2.3/application/libraries/Zend/Controller/Dispatcher/Standard.php(308): Zend_Controller_Action->dispatch('browseAction')
#15 /home/omeka/omeka-2.3/application/libraries/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#16 /home/omeka/omeka-2.3/application/libraries/Zend/Application/Bootstrap/Bootstrap.php(105): Zend_Controller_Front->dispatch()
#17 /home/omeka/omeka-2.3/application/libraries/Zend/Application.php(382): Zend_Application_Bootstrap_Bootstrap->run()
#18 /home/omeka/omeka-2.3/application/libraries/Omeka/Application.php(79): Zend_Application->run()
#19 /home/omeka/omeka-2.3/index.php(23): Omeka_Application->run()
#20 {main}
mjlassila commented 9 years ago

I went through recent Zend Framework changelogs and it seems that in Zend 1.12.8 there were relevant changes in Zend DB layer. (https://github.com/zendframework/zf1/pull/418). I got this fixed by using Zend_Db_Expr when constructing SQL query for location search (https://github.com/mjlassila/plugin-Geolocation/blob/master/GeolocationPlugin.php#L291).

zerocrates commented 9 years ago

Yeah, the changes to expression handling have bit some other plugins before, but nobody had reported it on this one yet.

What's curious to me here is that you report the search works fine from the map page. Does that include the proximity search, or just other searches?

mjlassila commented 9 years ago

Tested this once more and actually the proximity search in admin/geolocation/map/browse doesn't work correctly. Searching doesn't give the database error, but at the same time the map doesn't display hits even though the page title indicates that there are matching items.

It seems really strange that the search works at all because admin map search uses the same code as the public search view :confused:

zerocrates commented 9 years ago

With your changed code are the results correct in the "regular" search, the map search, on admin and public?

If its the expression/parens problem, which it would make sense to be, then that change should fix the issue everywhere.

mjlassila commented 9 years ago

Changed code fixes the problem everywhere. The reason I'm confused was that the unpatched code worked at all but nevertheless, now it works.

zerocrates commented 9 years ago

Can you make a pull request containing your change?

mjlassila commented 9 years ago

It seems impossible to make a pull request from a repo which is not a direct fork but here's a diff: https://github.com/mjlassila/plugin-Geolocation/commit/d37bb63f6c01e5eea25d2ebcab9f7c67992acd34.diff

zerocrates commented 9 years ago

Okay, I pulled in your change from your repository