Announcement

#16 2014-10-03 11:56:10

Konve
Translation Team
2012-07-24
58

Re: [resolved] wrong parameter count for nl2br()

Hi plg

PHP: 5.2.17 [2014-10-03 09:03:27]

Does not work it is a new version of the plugn!

Email send.

Offline

 

#17 2014-10-03 12:36:12

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [resolved] wrong parameter count for nl2br()

Plg,
nl2br accepts a second param only from 5.3

Mistic made a change (which I approved because i thought without side effect) by dropping the accepted number of args for event handlers. However builtiin php functions might trigger warnings.
Two solutions:
1. Replace this particular issue with our own nl2br wrapper
2. Put back optionally the number of args and call accordingly (also provide backward compatibility)

I think 1. Is the fastest to implement...

Offline

 

#18 2014-10-03 13:17:17

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: [resolved] wrong parameter count for nl2br()

OK, so in Piwigo 2.6, we had by default $accepted_args=1 on add_event_handler, which was fine for nl2br. Now in Piwigo 2.7, we accept all arguments.

I see that:

Code:

trigger_change('render_element_description',
          $picture['current']['comment'],
          'picture_page_element_description'
          )

The 2nd argument is not related to the 2nd argument $is_xhtml :

Code:

string nl2br ( string $string [, bool $is_xhtml = true ] )

So I agree with you, we'd better use our own pwg_nl2br for this specific case. Something like this?

Code:

function pwg_nl2br($string)
{
  // echo '['.__FUNCTION__.'] nb args = '.func_num_args().'<br>'; // => gives 2

  return nl2br($string);
}

Offline

 

#19 2014-10-03 15:04:39

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [resolved] wrong parameter count for nl2br()

Exactly and use it as event handler in picture.php and common.inc.php

Offline

 

#20 2014-10-03 19:41:06

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: [resolved] wrong parameter count for nl2br()

Konve, nrms or manuvui can you test this change with your PHP 5.2 ?

Code:

[pierrick@pierrick-desktop] ~/public_html/piwigo/dev/trunk
$ svn diff picture.php 
Index: picture.php
===================================================================
--- picture.php (revision 29781)
+++ picture.php (working copy)
@@ -137,7 +137,11 @@
 // add default event handler for rendering element content
 add_event_handler('render_element_content', 'default_picture_content');
 // add default event handler for rendering element description
-add_event_handler('render_element_description', 'nl2br');
+add_event_handler('render_element_description', 'pwg_nl2br');
+function pwg_nl2br($string)
+{
+  return nl2br($string);
+}
 
 trigger_notify('loc_begin_picture');

Offline

 

#21 2014-10-04 17:11:14

Konve
Translation Team
2012-07-24
58

Re: [resolved] wrong parameter count for nl2br()

Hello, plg!

Sorry, but I do not understand.
What exactly should I do?
First, I need to update to 2.7 , and then make changes to the code? In what file?

Offline

 

#22 2014-10-04 17:26:01

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: [resolved] wrong parameter count for nl2br()

On Piwigo 2.7.0, in file picture.php, replace:

Code:

add_event_handler('render_element_description', 'nl2br');

by

Code:

add_event_handler('render_element_description', 'pwg_nl2br');
function pwg_nl2br($string)
{
  return nl2br($string);
}

Offline

 

#23 2014-10-05 11:02:39

nrms
Guest

Re: [resolved] wrong parameter count for nl2br()

Hi plg,

I managed to resolve the issue by updating the PHP used to 5.4 with my web host (they allow use of 5.2, 5.3 or 5.4). After switching to 5.4 the issue went away.

It did introduce a new issue where thumbnails and other non-original sizes of photos weren't being generated. Managed to fix that using the info found on here at
http://piwigo.org/forum/viewtopic.php?id=22796

Thanks :)

 

#24 2014-10-05 21:13:45

scottsoutter
Guest

Re: [resolved] wrong parameter count for nl2br()

Hi all,

I had the same issue and after asking my friend google ended up here.  The change of

add_event_handler('render_element_description', 'pwg_nl2br');
function pwg_nl2br($string)
{
  return nl2br($string);
}

to the picture.php file fixed the error. 

Thank you!

 

#25 2014-10-06 04:11:11

LD
Guest

Re: [resolved] wrong parameter count for nl2br()

Site is using PHP ver. 5.2.17

 

#26 2014-10-06 04:16:25

LD
Guest

Re: [resolved] wrong parameter count for nl2br()

plg - Your code example fixed it in picture.php.  Thank You!

 

#27 2014-10-06 10:49:07

manuvui
Member
2014-01-19
14

Re: [resolved] wrong parameter count for nl2br()

Thanks Plg

All working correctly after code changes in picture.php

Offline

 

#28 2014-10-06 11:31:45

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13791

Re: [resolved] wrong parameter count for nl2br()

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact