Skip to content

Commit eb0be33

Browse files
committed
[bugfix][server] Respect relations in getfeatureinfo
Fixes #18518 QGIS Server 3 GetFeatureInfo doesn't resolve value relations anymore
1 parent 365fbed commit eb0be33

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

python/core/auto_generated/qgsproject.sip.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Most of the time you want to use QgsProject.instance() instead as many component
4646

4747
~QgsProject();
4848

49+
4950
void setTitle( const QString &title );
5051
%Docstring
5152
Sets the project's title.

src/core/qgsproject.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,11 @@ QgsProject::~QgsProject()
382382
}
383383
}
384384

385+
void QgsProject::setInstance( QgsProject *project )
386+
{
387+
sProject = project;
388+
}
389+
385390

386391
QgsProject *QgsProject::instance()
387392
{

src/core/qgsproject.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
109109

110110
~QgsProject() override;
111111

112+
#ifndef SIP_RUN
113+
114+
/**
115+
* Set the current project instance to \a project
116+
*
117+
* \note this is used mainly by the server, which caches the projects and (potentially) needs to switch the current instance on every request
118+
* \see instance()
119+
* \since QGIS 3.2
120+
*/
121+
static void setInstance( QgsProject *project );
122+
#endif
123+
112124
/**
113125
* Sets the project's title.
114126
* \param title new title

src/server/qgsconfigcache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const QgsProject *QgsConfigCache::project( const QString &path )
4848
mFileSystemWatcher.addPath( path );
4949
}
5050
}
51-
51+
QgsProject::setInstance( mProjectCache[ path ] );
5252
return mProjectCache[ path ];
5353
}
5454

tests/src/python/test_qgsserver_wms_getfeatureinfo.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,19 @@ def testGetFeatureInfoFilter(self):
286286
'FEATURE_COUNT=10&FILTER=testlayer%20%C3%A8%C3%A9' + urllib.parse.quote(':"NAME" = \'two\''),
287287
'wms_getfeatureinfo_filter_no_width')
288288

289+
def test_value_relation(self):
290+
"""Test wether value relations are resolved: regression 18518"""
291+
self.wms_request_compare('GetFeatureInfo',
292+
'&BBOX=537912.30469845747575164,4975501.92125043831765652,577227.89428471261635423,4996610.36656293831765652' +
293+
'&CRS=EPSG:32632' +
294+
'&WIDTH=1328&HEIGHT=713' +
295+
'&LAYERS=test_multi' +
296+
'&STYLES=&FORMAT=image/jpeg' +
297+
'&QUERY_LAYERS=test_multi&INFO_FORMAT=text/xml' +
298+
'&I=429&J=528&FEATURE_COUNT=10',
299+
'wms_getfeatureinfo_value_relation',
300+
project='test_project_value_relation.qgz')
301+
289302

290303
if __name__ == '__main__':
291304
unittest.main()

0 commit comments

Comments
 (0)