mmcguire Member Jan 8, 2018 #1 I have an external script that sets a notice active directly in the database. SQL: update xf_notice set active = 1 where notice_id = 3; Now I need to know how I can call rebuildNoticeCache() so the notice shows up on the site. Any help is appreciated.
I have an external script that sets a notice active directly in the database. SQL: update xf_notice set active = 1 where notice_id = 3; Now I need to know how I can call rebuildNoticeCache() so the notice shows up on the site. Any help is appreciated.
Jeremy P XenForo developer Staff member Jan 8, 2018 #2 PHP: \XF::repository('XF:Notice')->rebuildNoticeCache(); Or better yet have the script use the entity system instead of setting it directly in the database: PHP: $notice = \XF::em()->find('XF:Notice', 3); $notice->active = true; $notice->save(); Either way you'll have to bootstrap XF first if you haven't already: PHP: <?php // bootstrap framework $dir = __DIR__; require($dir . '/src/XF.php'); \XF::start($dir);
PHP: \XF::repository('XF:Notice')->rebuildNoticeCache(); Or better yet have the script use the entity system instead of setting it directly in the database: PHP: $notice = \XF::em()->find('XF:Notice', 3); $notice->active = true; $notice->save(); Either way you'll have to bootstrap XF first if you haven't already: PHP: <?php // bootstrap framework $dir = __DIR__; require($dir . '/src/XF.php'); \XF::start($dir);