This is really confusing, but calling webkit_web_context_set_favicon_database_directory() with NULL enables the favicon database using WebKit's default directory. This function has been removed from WebKit, and the favicon database is enabled by default now, so there's no need to replace this code with anything else.
P.S. This creates a mess, but all this code will disappear once you remove the WEBKIT_CHECK_VERSION guards. I've added them just to keep Builder's CI happy for now, since we can't add 2.39.7 to the runtime until applications are ready for it.