2022-01-27 * @author Eric Schwarzer 2022-02-22 */ require_once(__DIR__.'/ui.php'); $addon = \AddonQuery::create() ->filterByType('theme') ->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)') ->addAscendingOrderByColumn('case when NumConflicts > 0 then 1 else 2 end') ->orderByName(Propel\Runtime\ActiveQuery\Criteria::ASC) ); $tablesRemaining = $addon->getAddonTables(\AddonTableQuery::create()->filterByState('dirty')); //E: Somehow this is wrong, causes sql to hang like a mofo.. needs an additional where I think or possibly a modification of the index or something. //I had to restart mysql locally to deal with the hang. /* $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)') ->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)') ->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([ 'hidesearch' => true, '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 = "WordPress help and support for {$addon->getName()} {$addon->getType()} repair conflicts, fix errors & site issues"; $template->display('wordpress-addon-support.tpl');