after activation of module I receive this message in all pages and filter not works

Warning: Call-time pass-by-reference has been deprecated in /var/www/html/drupal/sites/all/modules/collapse_text/collapse_text.module on line 605

Thanks in advance

Comments

Miria’s picture

Having the same issue. In my case, filter seems to work fine, but the error appears at the top of every page.

JohnDoranNY’s picture

Having the same issue.. I just installed it.. I get the same error messages and the [collapse] and [/collapse] is not filtered.

jasondgardner’s picture

same with me.

glottus’s picture

I'm getting the same. I attempted to edit line 605 in collapse_text.module to use $found instead of &$found, but that just caused a 500 error when browsing to the text formats configuration page, so I reverted it to the current code.

Unlike others in a different issue, this module seems to still work in IE and other browsers, BUT, and this is a dealbreaker, the above error gets inserted into the node content of any page I try to edit.

I'm using ckeditor on this site, and if I click on Edit for any given page, this error gets pulled in and appended to be beginning of the content's source. Until this gets fixed, I won't be able to use this module.

pukku’s picture

Hi! I'm sorry for the long time in responding.

I can't replicate this problem.

What version of PHP 5.3 are you using? Are there any customizations in your php.ini file that enable extra warnings?

Thanks,
Ricky

glottus’s picture

Personally, I'm using PHP 5.2.17 and don't have anything extra enabled in php.ini regarding extra warnings.

I did try repeating the change above, but with all occurrences of '&$' before a variable to call it as a reference. That worked to remove the error and allow me to edit a node without problems, but the behavior of collapse_text started having problems. After editing a node and saving it, I could see working collapsible sections immediately (Firefox, Chromium), but only in that browser and until the page is refreshed. After a refresh or in any other browser, I could see the title of the fieldset with the triangle/arrow decoration, but it was not a functional link to control the visibility of that section.

Inspecting the source code shows that the appropriate text is there, but since the title doesn't function as a link, it is not visible in the browser if set to "collapsed".

A diff of the page source in both states shows them to be identical, and this module doesn't require any extra javascript or CSS beyond what Drupal 7 already uses.

Disabling ckeditor has no effect on this behavior, and the only other filter being used is Pathologic, which is applied after collapse_text.

Not sure if I should open another issue since the error in the original post is no longer a problem for me, but the overall fix isn't complete.

glottus’s picture

Update: I'm still using the version of collapse_text.module that I created by replacing all instances of '&$' with '$'. That fixed my pass-by-reference issues, but then the filter stopped working correctly, as I described above, so it wasn't a full solution. I'm closer now, but suspect there's still work that could be done within the module to do it better.

I discovered that form.js and collapse.js (both found in the drupal/misc directory at the root of your site) were being loaded for the first time a page was displayed after editing it or flushing all caches. However, if I refreshed the page, those two .js files were no longer loaded. I tried several solutions, including modifications to the module itself as suggested here, but nothing worked as well as adding the following line to the top of my node.tpl.php:

drupal_add_library('system', 'drupal.collapse');

I know that this is less than elegant since these .js files will now load for every node, not just the ones in which the filter is used, but this now works perfectly for my needs and I'm loving this feature.

As a side note, I want my content providers to be able to use this in ckeditor (very easy) and I want each collapsible fieldset to appear collapsed on page load, but by having the content people enter

[collapse collapsed title=""Some title"]some really long example text[/collapse]

they risk having users with Javascript turned off not being able to access the collapsed content, so I want to teach the content writers to use just

[collapse title=""Some title"]some really long example text[/collapse]

and help them with some extra jQuery to collapse those fieldsets if the user DOES have Javascript. So while I was editing my node.tpl.php, I added

drupal_add_js('jQuery(document).ready(function(){jQuery(".collapse-processed").addClass("collapsed");});', 'inline');

just below the line above.

pukku’s picture

Well, the code in question is the part of the module that determines when to include the libraries, so what you describe makes sense...

Ricky

pukku’s picture

I've just committed a change to the 7.x-2.x development branch that may fix this problem. It changes to a different way of signaling that we should add the libraries to the page. It may take time to update the packaged version for download, but you can also get it via git. The correct version will have the string "CollapseTextInPageException" in the collapse_text.module file.

nico059’s picture

Hi folks,
As seen here: http://stackoverflow.com/questions/1055812/how-to-avoid-call-time-pass-b...
In php 5.3, it's not the caller which determine if it's a byref parameter.

In my case, I justed change all the &$Variable to $Variable in all function call parameter (perhaps 3-4 replace &$found -> $found), and everything seems ok. No extensive test done yet ...

jens peter’s picture

I get this error too but also it seems to change other settings as the text in admin-area is suddenly bigger. I did hope that this would be fixed in the release of the module instead of as a patch.
Do anyone know if this is beind updated anytime soon.
Thanks

mesr01’s picture

+1

I discovered this issue while debugging a WSOD (not related to Collapse text). It may be possible to reproduce by inserting the following snippet in Drupal's index.php:

<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
Vote_Sizing_Steve’s picture

Regarding #10:
In my case, I justed change all the &$Variable to $Variable in all function call parameter (perhaps 3-4 replace &$found -> $found), and everything seems ok. No extensive test done yet ...
Can you submit a patch, or explain again which lines need changing?

illmatix’s picture

#13, #10
Yes I found that removing the referenced variable from the functions worked in the previous versions. Although I just upgraded the module and can't seem to get the error from appearing now.

I asked another developer here why this worked and he explained to me the same thing that #10 mentioned. It's usually up to the function author whether or not they should be editing the original $variable. Also Call-time pass-by-referenc is deprecated in PHP 5.3.x.

A patch would be greatly appreciated and I'll do what ever testing I can.

illmatix’s picture

Basically what I've done is create my own recursive array walk which seems to work on my installation. I've combined my recursive array walk with the callback function. I'm still new at module contributions so if I've missed anything in the process please mention it so I can keep on contributing.

I did do the patch verse the 7.x-2.x version which in I did see the revised function. I understand that my method won't be as fast to the array_walk_recursive() but I feel that it is a much simpler approach that doesn't require any pass-by-reference. Any suggestions or comments would be helpful.

illmatix’s picture

Oops seems like my patch breaks admin edit / add pages. So I've added a check for admin pages so that it doesn't run on them. I can see that this isn't a complete fix as there might be situations where having them on admin pages might be needed.

So here is a revised patch.

v.zhakov’s picture

subscibe

ultimateboy’s picture

I'm curious if this is the same issue reported here: http://drupal.org/node/1166504 which has been fixed in the latest -dev. Please update to the latest dev to make sure. Because this is filed against the -dev version, I'm going to keep this issue open assuming you have tested the latest -dev. Just cross-referencing the previous issue as it's definitely along the same lines.

pukku’s picture

Status: Active » Closed (duplicate)

Hi! This is the same issue as mentioned in #1166504. As I've noted there, I will shortly (as soon as I finish going through the queue) be releasing a new version that should get rid of all this ugliness.