We have moved to Github. Please open tickets there.

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#1161 closed Defect (fixed)

elgg_view doesn't pick up default view if other viewtype does not exist

Reported by: cash Owned by:
Priority: critical Milestone:
Component: Core Version: 1.5
Severity: critical Keywords:
Cc: brettp Difficulty:

Description

Here is the code of interest from elgg_view:

		    foreach($viewlist as $priority => $view) {
		    	
		    	$view_location = elgg_get_view_location($view, $viewtype);
		    			    	
			    if (file_exists($view_location . "{$viewtype}/{$view}.php") && !include($view_location . "{$viewtype}/{$view}.php")) {
			        $success = false;
			        
			        if ($viewtype != "default") {
			            if (include($view_location . "default/{$view}.php")) {
			                $success = true;
			            }
			        }
			        if (!$success && isset($CONFIG->debug) && $CONFIG->debug == true) {
			            error_log(" [This view ({$view}) does not exist] ");
			        }
			    } else if (isset($CONFIG->debug) && $CONFIG->debug == true && !file_exists($view_location . "{$viewtype}/{$view}.php")) {
		    	
			    	error_log($view_location . "{$viewtype}/{$view}.php");
			    	error_log(" [This view ({$view}) does not exist] ");
			    }
		    
		    }

Unless I'm missing something, the only way the first if statement is evaluated as true is if the view file exists but the apache user doesn't have permission to include the file. I believe the intention was to avoid a bunch of warnings by just including the view file.

I think this is closer to what you want:

if (!file_exists() || !include()) {
    $success = false;

    if ($viewtype != "default") {
        if (file_exists() && include()) {
            $success = true;
        }
    }
...
}

Change History (3)

comment:1 Changed 4 years ago by brettp

  • Resolution set to fixed
  • Status changed from new to closed

(In [svn:3585]) Fixes #1161: Views now default to 'default' if not found.

comment:2 Changed 4 years ago by cash

I've been meaning to update this one. We have been running with this fixed and it did cause some issues with RSS feeds. There was at least one blank view that had to be created under /views/rss: /page_elements/title.php

There may be others so it is good that this is fixed now to give us time to find any other views like this.

comment:3 Changed 3 years ago by brettp

(In [svn:3817]) Refs #1161: Added empty pagination view for RSS feeds.

Note: See TracTickets for help on using tickets.