+ """)
+
+ for php_name, conf_name, var_type in PHP_CONST_DEFS:
+ varout = _quote_php_variable(var_type, config, conf_name)
+
+ basedata += f"@define('CONST_{php_name}', {varout});\n"
+
+ template = "\nrequire_once(CONST_LibDir.'/website/{}');\n"
+
+ search_name_table_exists = bool(conn and conn.table_exists('search_name'))
+
+ for script in WEBSITE_SCRIPTS:
+ if not search_name_table_exists and script == 'search.php':
+ out = template.format('reverse-only-search.php')
+ else:
+ out = template.format(script)
+
+ (basedir / script).write_text(basedata + out, 'utf-8')
+
+
+def invalidate_osm_object(osm_type: str, osm_id: int, conn: Connection,
+ recursive: bool = True) -> None:
+ """ Mark the given OSM object for reindexing. When 'recursive' is set
+ to True (the default), then all dependent objects are marked for
+ reindexing as well.
+
+ 'osm_type' must be on of 'N' (node), 'W' (way) or 'R' (relation).
+ If the given object does not exist, then nothing happens.
+ """
+ assert osm_type in ('N', 'R', 'W')
+
+ LOG.warning("Invalidating OSM %s %s%s.",
+ OSM_TYPE[osm_type], osm_id,
+ ' and its dependent places' if recursive else '')
+
+ with conn.cursor() as cur:
+ if recursive:
+ sql = """SELECT place_force_update(place_id)
+ FROM placex WHERE osm_type = %s and osm_id = %s"""
+ else:
+ sql = """UPDATE placex SET indexed_status = 2
+ WHERE osm_type = %s and osm_id = %s"""
+
+ cur.execute(sql, (osm_type, osm_id))