Question

Strict warning: Only variables should be passed by reference in include() (line 26 of page.tpl.php).

Hello Support Team,

I have got this error after upgrade my php version from 5.3.10 to 5.5.7. My application is running in drupal 7.23 in ubuntu 12.04.

Error : Strict warning: Only variables should be passed by reference in include() (line 26 of /var/www/avcdistributor.com/sites/all/themes/tejas/templates/page.tpl.php).

Line 24-28 Says :

if($user->uid != 0){ $block = block_load(‘block’, ‘7’); $output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block)))); print $output; }

Can you please help me what is the issue, it will perfectly worked on php 5.3.10, but after upgrade php version it will not working.

Thanks, Tejas


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

the problem you are having is that you are passing the return of the function call “_block_get_renderable_array” to drupal_render. drupal_render expects that parameter to be passed by reference. You can only pass a variable by reference NOT the return value of a function call.

Here is an example fix. <pre> $block = block_load(‘block’, ‘7’); $render_block = _block_get_renderable_array(_block_render_blocks(array($block))) $output = drupal_render($render_block); print $output; </pre>

it was perfectly worked on php 5.3.10, but after upgrade php version it will not working. <br> <br>The reason you are seeing this message after upgrading, is that strict warnings (E_STRICT) became part of E_ALL in 5.4.0. The default value for error_reporting in 5.5.7 excludes E_STRICT, however if you didn’t alter your php.ini file, you will still have the 5.3 default which doesn’t exclude E_STRICT: <br> <br> 5.3: # Default Value: E_ALL & ~E_NOTICE <br> <br> 5.5: # Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED <br> <br>The correct action to resolve this is to add & ~E_STRICT to your existing error_reporting value in php.ini. <br> <br>http://php.net/manual/en/function.error-reporting.php#refsect1-function.error-reporting-changelog

For more information on resolving this issue with your code, please refer to: http://www.php.net/manual/en/language.references.pass.php <br> <br>[Not recommended] <br>However, to prevent this warnings from displaying, add “~E_STRICT” to your php.ini on the error_reporting line. Such as: <br>error_reporting = E_ALL ~E_STRICT