Revert "fix(module_map): only include apps installed on the site - not everything on the bench" (#24605)
This commit is contained in:
parent
3990da0620
commit
d53a0ae45e
3 changed files with 12 additions and 38 deletions
|
|
@ -202,19 +202,8 @@ if TYPE_CHECKING: # pragma: no cover
|
|||
# end: static analysis hack
|
||||
|
||||
|
||||
def init(
|
||||
site: str, sites_path: str = ".", new_site: bool = False, force=False, site_ready: bool = True
|
||||
) -> None:
|
||||
"""
|
||||
Initialize frappe for the current site. Reset thread locals `frappe.local`
|
||||
|
||||
:param site: Site name.
|
||||
:param sites_path: Path to sites directory.
|
||||
:param new_site: Sets a flag to indicate a new site.
|
||||
:param force: Force initialization if already previously run.
|
||||
:param site_ready: Any init during site installation should set this to False.
|
||||
|
||||
"""
|
||||
def init(site: str, sites_path: str = ".", new_site: bool = False, force=False) -> None:
|
||||
"""Initialize frappe for the current site. Reset thread locals `frappe.local`"""
|
||||
if getattr(local, "initialised", None) and not force:
|
||||
return
|
||||
|
||||
|
|
@ -272,14 +261,12 @@ def init(
|
|||
local.qb = get_query_builder(local.conf.db_type)
|
||||
local.qb.get_query = get_query
|
||||
setup_redis_cache_connection()
|
||||
setup_module_map()
|
||||
|
||||
if not _qb_patched.get(local.conf.db_type):
|
||||
patch_query_execute()
|
||||
patch_query_aggregation()
|
||||
|
||||
if site:
|
||||
setup_module_map(site_ready)
|
||||
|
||||
local.initialised = True
|
||||
|
||||
# Set the user as database name if not set in config
|
||||
|
|
@ -1649,32 +1636,18 @@ def append_hook(target, key, value):
|
|||
target[key].extend(value)
|
||||
|
||||
|
||||
def setup_module_map(site_ready: bool = True):
|
||||
"""
|
||||
Rebuild map of all modules (internal).
|
||||
|
||||
:param site_ready: If the site isn't fully ready yet - install is still going on, we can't
|
||||
fetch apps from site DB. Fallback to fetching all apps on bench for module map temporarily.
|
||||
"""
|
||||
def setup_module_map():
|
||||
"""Rebuild map of all modules (internal)."""
|
||||
if conf.db_name:
|
||||
local.app_modules = cache.get_value("app_modules")
|
||||
local.module_app = cache.get_value("module_app")
|
||||
|
||||
if not (local.app_modules and local.module_app):
|
||||
local.module_app, local.app_modules = {}, {}
|
||||
|
||||
if site_ready:
|
||||
apps = get_installed_apps(_ensure_on_bench=True)
|
||||
else:
|
||||
apps = get_all_apps()
|
||||
|
||||
for app in apps:
|
||||
for app in get_all_apps(with_internal_apps=True):
|
||||
local.app_modules.setdefault(app, [])
|
||||
for module in get_module_list(app):
|
||||
module = scrub(module)
|
||||
if module in local.module_app:
|
||||
print(f"WARNING: module `{module}` found in apps `{local.module_app[module]}` and `{app}`")
|
||||
|
||||
local.module_app[module] = app
|
||||
local.app_modules[app].append(module)
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ def new_site(
|
|||
"Create a new site"
|
||||
from frappe.installer import _new_site
|
||||
|
||||
frappe.init(site=site, new_site=True, site_ready=False)
|
||||
frappe.init(site=site, new_site=True)
|
||||
|
||||
_new_site(
|
||||
db_name,
|
||||
|
|
@ -417,7 +417,7 @@ def _reinstall(
|
|||
if not yes:
|
||||
click.confirm("This will wipe your database. Are you sure you want to reinstall?", abort=True)
|
||||
try:
|
||||
frappe.init(site=site, site_ready=False)
|
||||
frappe.init(site=site)
|
||||
frappe.connect()
|
||||
frappe.clear_cache()
|
||||
installed = frappe.get_installed_apps()
|
||||
|
|
@ -429,7 +429,7 @@ def _reinstall(
|
|||
frappe.db.close()
|
||||
frappe.destroy()
|
||||
|
||||
frappe.init(site=site, site_ready=False)
|
||||
frappe.init(site=site)
|
||||
|
||||
_new_site(
|
||||
frappe.conf.db_name,
|
||||
|
|
@ -726,6 +726,7 @@ def disable_user(context, email):
|
|||
@pass_context
|
||||
def migrate(context, skip_failing=False, skip_search_index=False):
|
||||
"Run patches, sync schema and rebuild files/translations"
|
||||
from traceback_with_variables import activate_by_import
|
||||
|
||||
from frappe.migrate import SiteMigration
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ def _new_site(
|
|||
print("--no-mariadb-socket requires db_type to be set to mariadb.")
|
||||
sys.exit(1)
|
||||
|
||||
frappe.init(site=site, site_ready=False)
|
||||
frappe.init(site=site)
|
||||
|
||||
if not db_name:
|
||||
import hashlib
|
||||
|
|
@ -557,7 +557,7 @@ def make_conf(
|
|||
)
|
||||
sites_path = frappe.local.sites_path
|
||||
frappe.destroy()
|
||||
frappe.init(site, sites_path=sites_path, site_ready=False)
|
||||
frappe.init(site, sites_path=sites_path)
|
||||
|
||||
|
||||
def make_site_config(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue