function view::clone_view

cis7 view::clone_view()
cle7 view::clone_view()
elmsmedia7 view::clone_view()
icor7 view::clone_view()
meedjum_blog7 view::clone_view()
mooc7 view::clone_view()

Safely clone a view.

Because views are complicated objects within objects, and PHP loves to do references to everything, if a View is not properly and safely cloned it will still have references to the original view, and can actually cause the original view to point to objects in the cloned view. This gets ugly fast.

This will completely wipe a view clean so it can be considered fresh.

Return value

view The cloned view.


sites/all/modules/ulmus/views/includes/, line 1955
Provides the view object type and associated methods.


An object to contain all of the data to generate a view, plus the member functions to build the view query, execute the query and render the output.


function clone_view() {
  $clone = version_compare(phpversion(), '5.0') < 0 ? $this : clone($this);

  $keys = array(
  foreach ($keys as $key) {
    if (isset($clone->$key)) {
  $clone->built = $clone->executed = FALSE;
  $clone->build_info = array();
  $clone->attachment_before = '';
  $clone->attachment_after = '';
  $clone->result = array();

  // shallow cloning means that all the display objects
  // *were not cloned*. We must clone them ourselves.
  $displays = array();
  foreach ($clone->display as $id => $display) {
    $displays[$id] = clone $display;
    if (isset($displays[$id]->handler)) {
  $clone->display = $displays;

  return $clone;



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.