Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9039007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:37:56+00:00 2026-06-16T09:37:56+00:00

In drupal, an uncatchable php error is thrown by this code: /* * @param

  • 0

In drupal, an uncatchable php error is thrown by this code:

/*
* @param $variables
*   An associative array containing:
*   - element: An associative array containing the properties of the element.
*     Properties used: #title, #title_display, #description, #id, #required,
*     #children, #type, #name.
*
* @ingroup themeable
*/
function theme_form_element($variables) {
  //print_r($variables); die("daa`");
  $element = &$variables['element'];
  // This is also used in the installer, pre-database setup.
  $t = get_t();

  // This function is invoked as theme wrapper, but the rendered form element
  // may not necessarily have been processed by form_builder().

  $element += array(
    '#title_display' => 'before',
  );
...

The last line of drupal’s function throws the error.

$variables['element'] is an array when it enters the function. When the $element reference is assigned to it, it changes (within $variables) from type Array to type &Array. The variable $element reports itself as type Array.

The following lines no not throw the same error when used instead of the += operator:

$element = $element + array();
$new = array_merge($element, array());  

@iputonmyrobeandwizardhat asked for an sscce, which I attempted to provide below. However, the code does not cause the same error in isolation that it throws while in use in drupal’s rendering process. Can anyone recommend a method to isolate the error?

<?php
function theme_form_element($variables) { 
  $element = &$variables['element'];         
  var_dump($variables);                //['element'] becomes type &array

  //not fatal
  $element2 = $element + array( '#title' => 'before'); 

  //not fatal
  $element3 = array_merge($element, array( '#title' => 'before'));   

  $element += array( '#title_display' => 'before');  
    var_dump($element);
}

$variables_array = array
(
'element' => array
    (
        '#type' => 'textfield',
        '#title' => 'First Name:',
        '#default_value' => '',
        '#size' => 60,
        '#maxlength' => 64,
        '#description' => 'First name',
        '#required' => 1,
        '#input' => 1,
        '#autocomplete_path' => '',
        '#process' => Array ('ajax_process_form'),

        '#theme' => 'textfield',
        '#theme_wrappers' => Array('form_element'),

        '#defaults_loaded' => 1,
        '#tree' => '',
        '#parents' => Array('first_name'),

        '#array_parents' => Array('first_name'),

        '#weight' => 0,
        '#processed' => 1,
        '#attributes' => Array(),

        '#title_display' => 'before',
        '#id' => 'edit-first-name',
        '#name' => 'first_name',
        '#value' => '',
        '#ajax_processed' => '',
        '#sorted' => 1,
        '#children' => '<input type="text" id="edit-first-name" name="first_name" value="" size="60" maxlength="64" class="form-text required" />'
    )

);    
?>

The input:

// base64_encode(serialize($variables));
YToxOntzOjc6ImVsZW1lbnQiO2E6MjY6e3M6NToiI3R5cGUiO3M6OToidGV4dGZpZWxkIjtzOjY6IiN0aXRsZSI7czoxMToiRmlyc3QgTmFtZToiO3M6MTQ6IiNkZWZhdWx0X3ZhbHVlIjtzOjA6IiI7czo1OiIjc2l6ZSI7aTo2MDtzOjEwOiIjbWF4bGVuZ3RoIjtpOjY0O3M6MTI6IiNkZXNjcmlwdGlvbiI7czoxMDoiRmlyc3QgbmFtZSI7czo5OiIjcmVxdWlyZWQiO2I6MTtzOjY6IiNpbnB1dCI7YjoxO3M6MTg6IiNhdXRvY29tcGxldGVfcGF0aCI7YjowO3M6ODoiI3Byb2Nlc3MiO2E6MTp7aTowO3M6MTc6ImFqYXhfcHJvY2Vzc19mb3JtIjt9czo2OiIjdGhlbWUiO3M6OToidGV4dGZpZWxkIjtzOjE1OiIjdGhlbWVfd3JhcHBlcnMiO2E6MTp7aTowO3M6MTI6ImZvcm1fZWxlbWVudCI7fXM6MTY6IiNkZWZhdWx0c19sb2FkZWQiO2I6MTtzOjU6IiN0cmVlIjtiOjA7czo4OiIjcGFyZW50cyI7YToxOntpOjA7czoxMDoiZmlyc3RfbmFtZSI7fXM6MTQ6IiNhcnJheV9wYXJlbnRzIjthOjE6e2k6MDtzOjEwOiJmaXJzdF9uYW1lIjt9czo3OiIjd2VpZ2h0IjtpOjA7czoxMDoiI3Byb2Nlc3NlZCI7YjoxO3M6MTE6IiNhdHRyaWJ1dGVzIjthOjA6e31zOjE0OiIjdGl0bGVfZGlzcGxheSI7czo2OiJiZWZvcmUiO3M6MzoiI2lkIjtzOjE1OiJlZGl0LWZpcnN0LW5hbWUiO3M6NToiI25hbWUiO3M6MTA6ImZpcnN0X25hbWUiO3M6NjoiI3ZhbHVlIjtzOjA6IiI7czoxNToiI2FqYXhfcHJvY2Vzc2VkIjtiOjA7czo3OiIjc29ydGVkIjtiOjE7czo5OiIjY2hpbGRyZW4iO3M6MTIxOiI8aW5wdXQgdHlwZT0idGV4dCIgaWQ9ImVkaXQtZmlyc3QtbmFtZSIgbmFtZT0iZmlyc3RfbmFtZSIgdmFsdWU9IiIgc2l6ZT0iNjAiIG1heGxlbmd0aD0iNjQiIGNsYXNzPSJmb3JtLXRleHQgcmVxdWlyZWQiIC8+Ijt9fQ==
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:37:57+00:00Added an answer on June 16, 2026 at 9:37 am

    += works fine with arrays and references.

    $arr = array(1);
    $e = &$arr;
    $e += array(1,2);
    
    print_r($e);//Array ( [0] => 1 [1] => 2 )
    

    http://codepad.org/0M5ChPgt

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On Drupal 6, I used to have a custom PHP block which accessed arg(0),
In Drupal 7 simple updates work like this: $num_updated = db_update('joke') ->fields(array( 'punchline' =>
Drupal is giving me an error message which says : An illegal choice has
Drupal cannot create the files folder. I tried to upload a php script with
Drupal 6.x I have this module that manages four different content types. For that
In Drupal 6 you could use code similar to the following one: function example_user($op,
Drupal version 6.12 I have a page whose input format is PHP. I simply
Can Drupal be used with PostGIS, allowing for spatial queries?
Drupal asking for ftp access while installing module. I found that PHP ftp extension
Drupal 7 has the field group module which contains a horizontal_tab.js file. Inside this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.