Skip to content

Commit

Permalink
Updated: Refactor content2 list and list_count fetch to ensure langua…
Browse files Browse the repository at this point in the history
…ge mask is omitted for database performance
  • Loading branch information
brookinsconsulting committed Jan 29, 2017
1 parent 0176fd3 commit ff7abdc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
Expand Up @@ -1341,6 +1341,9 @@ static function createAttributeFilterSQLStrings( &$attributeFilter, &$sortingInf
{
if ( $justFilterCount > 0 )
$filterSQL['where'] .= " ( " . $attibuteFilterJoinSQL . " ) AND ";
// EZE - KERNEL HACK TO REMOVE PERFORMANCE PROBLEMS WITH LANGUAGES. THIS CHANGE REMOVES SECTION ATTRIBUTE FILTER TRAILING AND STRING IN QUERY.
// $filterSQL['where'] .= " ( " . $attibuteFilterJoinSQL . " ) ";

}
} // end of 'if ( is_array( $filterArray ) )'
}
Expand Down Expand Up @@ -1831,7 +1834,8 @@ static function createShowInvisibleSQLString( $useSettings, $fetchHidden = true
$showInvisible = eZContentObjectTreeNodeNoLanguage::showInvisibleNodes();

if ( !$showInvisible )
$showInvisibleNodesCond = 'AND ezcontentobject_tree.is_invisible = 0';
$showInvisibleNodesCond = ' ezcontentobject_tree.is_invisible = 0';
//$showInvisibleNodesCond = 'AND ezcontentobject_tree.is_invisible = 0';

return $showInvisibleNodesCond;
}
Expand Down Expand Up @@ -1865,7 +1869,7 @@ static function getLimitationList( &$limitation )
{
return $limitation;
}

$currentUser = eZUser::currentUser();
$currentUserID = $currentUser->attribute( 'contentobject_id' );
$limitationList = array();
Expand Down Expand Up @@ -1963,6 +1967,7 @@ static function subTreeByNodeID( $params = false, $nodeID = 0 )
}

$attributeFilter = eZContentObjectTreeNodeNoLanguage::createAttributeFilterSQLStrings( $params['AttributeFilter'], $sortingInfo, $language );

if ( $attributeFilter === false )
{
return null;
Expand Down Expand Up @@ -2001,7 +2006,12 @@ static function subTreeByNodeID( $params = false, $nodeID = 0 )
}

$languageFilter = eZContentLanguage::languagesSQLFilter( 'ezcontentobject' );
$objectNameLanguageFilter = eZContentLanguage::sqlFilter( 'ezcontentobject_name', 'ezcontentobject' );

// EZE -KERNEL HACK - Disabled per content2 module fetch function is lang removed for db performance
// $languageFilter = eZContentLanguage::languagesSQLFilter( 'ezcontentobject' );
$languageFilter = '';
// $objectNameLanguageFilter = eZContentLanguage::sqlFilter( 'ezcontentobject_name', 'ezcontentobject' );
$objectNameLanguageFilter = '';

if ( $language )
{
Expand Down Expand Up @@ -2045,7 +2055,8 @@ static function subTreeByNodeID( $params = false, $nodeID = 0 )
"$objectNameLanguageFilter " .
"$showInvisibleNodesCond " .
"$sqlPermissionChecking[where] " .
"$objectNameFilterSQL AND " .
// "$objectNameFilterSQL AND " .
"$objectNameFilterSQL " .
"$languageFilter " .
$groupBySQL;

Expand All @@ -2055,7 +2066,7 @@ static function subTreeByNodeID( $params = false, $nodeID = 0 )
$db = eZDB::instance();

$server = count( $sqlPermissionChecking['temp_tables'] ) > 0 ? eZDBInterface::SERVER_SLAVE : false;

//print_r( $query ); die();
$nodeListArray = $db->arrayQuery( $query, array( 'offset' => $offset,
'limit' => $limit ),
$server );
Expand Down Expand Up @@ -2438,8 +2449,12 @@ static function subTreeCountByNodeID( $params = array(), $nodeID )
$mainNodeOnlyCond = 'ezcontentobject_tree.node_id = ezcontentobject_tree.main_node_id AND';
}

$languageFilter = ' AND '.eZContentLanguage::languagesSQLFilter( 'ezcontentobject' );
$objectNameLanguageFilter = eZContentLanguage::sqlFilter( 'ezcontentobject_name', 'ezcontentobject' );
// EZE - KERNEL PATCH - Disabled to prevent language usage query slowdown
//$languageFilter = ' AND '.eZContentLanguage::languagesSQLFilter( 'ezcontentobject' );
$languageFilter = '';

// $objectNameLanguageFilter = eZContentLanguage::sqlFilter( 'ezcontentobject_name', 'ezcontentobject' );
$objectNameLanguageFilter = '';

if ( $language )
{
Expand All @@ -2450,6 +2465,15 @@ static function subTreeCountByNodeID( $params = array(), $nodeID )
$attributeFilterParam = isset( $params['AttributeFilter'] ) ? $params['AttributeFilter'] : false;
$sortingInfo = array( 'sortCount' => 0, 'attributeJoinCount' => 0 );
$attributeFilter = eZContentObjectTreeNodeNoLanguage::createAttributeFilterSQLStrings( $attributeFilterParam, $sortingInfo, $language );

// EZE - KERNEL PATCH - Disabled to prevent language usage query slowdown
$replaceStringAnd = ' AND';
$replaceStringAndPos = strrpos( $attributeFilter['where'], $replaceStringAnd );
if( $replaceStringAndPos !== false )
{
$$attributeFilter['where'] = substr_replace( $attributeFilter['where'], '', $replaceStringAndPos, strlen( $replaceStringAnd ) );
}

if ( $attributeFilter === false )
{
return null;
Expand Down
Expand Up @@ -263,7 +263,7 @@
$home_page_fetch_sort_array_attribute_forum_only = array( array( 'attribute', false(), $home_page_forum_topic_publication_date ), array( 'published', false() ) )
$home_page_fetch_sort_array_published = array( 'published', false() )
$home_page_fetch_sort_array = $home_page_fetch_sort_array_published
$children = fetch( 'content', 'list', hash( 'parent_node_id', $home_page_root_node_id,
$children = fetch( 'content2', 'list', hash( 'parent_node_id', $home_page_root_node_id,
'attribute_filter', array( 'and', array( 'section', '!=', $home_page_section_github ), array( 'section', '!=', $home_page_section_planet ), array( 'section', '!=', $home_page_section_issues ), array( 'section', '!=', $home_page_section_forums ) ),
'extended_attribute_filter', hash( 'id', 'BcDateTimeExtendedFilter', 'params', hash( 'published', makedate( 1, 1, currentdate()|datetime( 'custom', '%Y' ) ) ) ),
'offset', $view_parameters.offset,
Expand Down
Expand Up @@ -197,7 +197,7 @@

$FunctionList['list'] = array( 'name' => 'list',
'operation_types' => array( 'read' ),
'call_method' => array( 'class' => 'eZContentFunctionCollection',
'call_method' => array( 'class' => 'eZContentFunctionCollectionNoLanguage',
'method' => 'fetchObjectTree' ),
'parameter_type' => 'standard',
'parameters' => array( array( 'name' => 'parent_node_id',
Expand Down

0 comments on commit ff7abdc

Please sign in to comment.