Last modified: 2013-01-18 18:05:24 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T38056, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 36056 - SMW query printer ignores $egMapsGoogleMapsZoom
SMW query printer ignores $egMapsGoogleMapsZoom
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
SemanticMaps (Other open bugs)
unspecified
All All
: Unprioritized normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-18 04:21 UTC by Ike Hecht
Modified: 2013-01-18 18:05 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Ike Hecht 2012-04-18 04:21:00 UTC
When using Semantic Maps to return an #ask query result, it should use the default zoom when there is only one location returned by the query. It does not.

I tracked this to SM_MapPrinter.php line 158:
if ( $params['zoom'] === false && $locationAmount <= 1 ) {
	$params['zoom'] = $this->service->getDefaultZoom();
}

At first glance the problem seems to be that $locationAmount reports *double* the number of locations that are actually being returned by the query, which prevents the default zoom from being assigned.
Comment 1 Jeroen De Dauw 2012-04-18 09:39:27 UTC
What version of Semantic Maps? If you could further debug this and fix the double location stuff, then this might get resolved a lot faster then if you have to wait on me :)
Comment 2 Ike Hecht 2012-04-18 12:04:57 UTC
The bug is in the trunk version, but I found it in all versions since 1.0. 

I did fix it - with: ( $locationAmount / 2 )  <= 1 
:).

I don't think I'll get the chance to further track it until late next week.
Comment 3 Ike Hecht 2012-05-08 23:52:41 UTC
So I finally tracked it to SM_QueryHandler.php line 455 (trunk):

$locations[] = $location;

The problem is that $locations already has a value. So when $location is added to it, we get 2 locations.

Here's a fixed version of the function that seems to work but I'm not confident enough to check it in:

protected function buildLocationsList( array $locations, $title, $text, $icon, array $properties ) {
	if ( $this->template ) {
		global $wgParser;
		$parser = version_compare( $GLOBALS['wgVersion'], '1.18', '<' ) ? $wgParser : clone $wgParser;
	}
	else {
		$text .= implode( '<br />', $properties );
	}

	$locationsResult = array();
	foreach ( $locations as $location ) {
		if ( $this->template ) {
			$segments = array_merge(
				array( $this->template, 'title=' . $title, 'latitude=' . $location->getLatitude(), 'longitude=' . $location->getLongitude() ),
				$properties
			);

			$text .= $parser->parse( '{{' . implode( '|', $segments ) . '}}', $parser->getTitle(), new ParserOptions() )->getText();
		}

		$location->setTitle( $title );
		$location->setText( $text );
		$location->setIcon( $icon );

		$locationsResult [] = $location;
	}

	return $locationsResult;
}
Comment 4 Jeroen De Dauw 2012-05-09 18:28:13 UTC
Great! Can you submit this to gerrit? 

https://www.mediawiki.org/wiki/Git/Workflow
Comment 5 Ike Hecht 2012-05-15 17:28:19 UTC
In merge queue: https://gerrit.wikimedia.org/r/7730

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links