2022-01-27 * @author Eric Schwarzer 2022-02-22 ;) * */ require_once(__DIR__.'/ui.php'); $type = \Util::ValidateArrayKey($_GET, 'type', ['plugin', 'theme']); if (!$type) { // invalid/missing type \Util::Redirect('/', 307); } $addon = \AddonQuery::create() ->filterByType($type) ->findOneBySlug($slug); if (!$addon) { // not found in db \Util::Redirect('/', 307); //307 should allow us to track this kind of thing more easily in apache logs. plus search engine wont' jut give up on the url forever. } //title now set down below $shortcodes = $addon->getAddonShortcodes( \AddonShortcodeQuery::create() // can get conflicts directly in the query, instead of looking up for each shortcode in the template. ->addAsColumn('NumConflicts', '(select count(*) from addons a inner join addon_shortcodes a2 on (a2.addon_id=a.id) where a2.shortcode = addon_shortcodes.shortcode and a.id != addon_shortcodes.addon_id)') // sort any shortcodes with conflicts above the others. ->addAscendingOrderByColumn('case when NumConflicts > 0 then 1 else 2 end') ->orderByShortcode(Propel\Runtime\ActiveQuery\Criteria::ASC) ); $functions = $addon->getAddonFunctions( \AddonFunctionQuery::create() ->addAsColumn('NumConflicts', '(select count(*) from addons a inner join addon_functions a2 on (a2.addon_id=a.id) where a2.function_name = addon_functions.function_name and a.id != addon_functions.addon_id)') ->addAscendingOrderByColumn('case when NumConflicts > 0 then 1 else 2 end') ->orderByFunctionName(Propel\Runtime\ActiveQuery\Criteria::ASC) ); $tablesCreated = $addon->getAddonTables( \AddonTableQuery::create() ->filterByState('active') ->addAsColumn('NumConflicts', '(select count(*) from addons a inner join addon_tables a2 on (a2.addon_id=a.id) where a2.name = addon_tables.name and a.id != addon_tables.addon_id and a2.state = "active")') ->addAscendingOrderByColumn('case when NumConflicts > 0 then 1 else 2 end') ->orderByName(Propel\Runtime\ActiveQuery\Criteria::ASC) ); $tablesRemaining = $addon->getAddonTables(\AddonTableQuery::create()->filterByState('dirty')); $filesCreated = $addon->getAddonFiles( \AddonFileQuery::create() ->filterByState('active') ->addAsColumn('NumConflicts', '(select count(*) from addons a inner join addon_files a2 on (a2.addon_id=a.id) where a2.filename = addon_files.filename and a.id != addon_files.addon_id and a2.state = "active")') ->addAscendingOrderByColumn('case when NumConflicts > 0 then 1 else 2 end') ->orderByFilename(Propel\Runtime\ActiveQuery\Criteria::ASC) ); $filesRemaining = $addon->getAddonFiles(\AddonFileQuery::create()->filterByState('dirty')); $optionsCreated = $addon->getAddonOptions( AddonOptionQuery::create() ->filterByState('active') ->addAsColumn('NumConflicts', '(select count(*) from addons a inner join addon_options a2 on (a2.addon_id=a.id) where a2.option = addon_options.option and a.id != addon_options.addon_id and a2.state = "active")') ->addAscendingOrderByColumn('case when NumConflicts > 0 then 1 else 2 end') ->orderByOption(Propel\Runtime\ActiveQuery\Criteria::ASC) ); $optionsRemaining = $addon->getAddonOptions(\AddonOptionQuery::create()->filterByState('dirty')); $template->assign([ 'addon' => $addon, 'shortcodes' => $shortcodes, 'tablesRemaining' => $tablesRemaining, 'tablesCreated' => $tablesCreated, 'optionsRemaining' => $optionsRemaining, 'optionsCreated' => $optionsCreated, 'filesRemaining' => $filesRemaining, 'filesCreated' => $filesCreated, 'functions' => $functions, 'shortcodeconflictCount' => 0, 'functionconflictCount' => 0, 'tableconflictCount' => 0 ]); $template->title = "fix {$addon->getName()} {$addon->getType()} conflicts, errors & issues"; $template->display('analyze/addon.tpl'); //lol _ this comment is a bigger change