Lack of interest Unnecessary Call of getAllPrefixesGroupedByRouteType in XenForo_Model_RoutePrefix

  • Thread starter Thread starter ragtek
  • Start date Start date
This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.
R

ragtek

Guest
You're calling $this->getAllPrefixesGroupedByRouteType in method importPrefixesAddOnXml, which will run 2 queries.
(they aren't big for avarage joe and probably they're cached by sql server because you run them ~10 lines later again, BUT

That's IMHO not necessary, because you don't do anything with the result, so you could remove this part...

PHP:
/**
    * Imports the add-on route prefixes XML.
    *
    * @param SimpleXMLElement $xml XML element pointing to the root of the prefix data
    * @param string $addOnId Add-on to import for
    */
    public function importPrefixesAddOnXml(SimpleXMLElement $xml, $addOnId)
    {
        $db = $this->_getDb();

        $currentPrefixes = $this->getAllPrefixesGroupedByRouteType(); // unnecessary part!!!*****************************************

        XenForo_Db::beginTransaction($db);
        $this->deletePrefixesForAddOn($addOnId);

        $routeTypes = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->route_type);
        foreach ($routeTypes AS $typeXml)
        {
......
 
Upvote 1
This suggestion has been closed. Votes are no longer accepted.
Top Bottom