Page 1 of 1

Guestbook error: Warning: vsprintf(): Too few arguments in /home/httpd/vhosts/ca

Posted: Tue Jul 17, 2007 1:03 pm
by emt
I posted this as a bug in the Development, Guestbook forum last night, but thought I would put here so more people would see it. Just in case someone else is seeing this problem too!

Marshall


Installed new CMSMS 1.1 "Samoa", added modules Guestbook 1.1.9 and Captcha 0.3.

In the CMSMS admin, under Content, Guestbook, the following message is appearing for each message posted (only posted two test messages and two errors are showing).

Warning: vsprintf(): Too few arguments in /home/httpd/vhosts/cattycattyways.com/httpdocs/beta/lib/translation.functions.php on line 62

The message appears between the the "Manage Guestbook" tabs and the table showing the message.

I'm not sure if this is a Guestbook or CMSMS problem. I had previously installed Guestbook 1.1.9 on CMSMS 1.0.4 "Lanai" and did not experience this problem. (Same server, but different domain)

So based on those facts, I'm posting this as a bug report for Guestbook.

Thank you,
Marshall

Re: Guestbook error: Warning: vsprintf(): Too few arguments in /home/httpd/vhost

Posted: Tue Jul 24, 2007 10:12 pm
by Gregor
@Marshall, I experience this problem too after upgrading to cmsms 1.1 I also copied all files of Guestbook 1.1.9 to the server, because in the module manger it says "cannot download". The version stays to 1.1.2, I don't know how to continue this upgrade of the guestbook.

Gregor

Re: Guestbook error: Warning: vsprintf(): Too few arguments in /home/httpd/vhost

Posted: Thu Jul 26, 2007 1:36 pm
by b0n3m4n
Same here.

I'm using a fresh 1.1 Samoa install plus guestbook 1.1.9 installed via Module Manager without Captcha.
There is one error line for each guestbook entry shown in the admin section.

Re: Guestbook error: Warning: vsprintf(): Too few arguments in /home/httpd/vhost

Posted: Thu Jul 26, 2007 2:44 pm
by b0n3m4n
I believe I found the error.

It seems to be in /lib/translation.functions.php, line 34, which should be

Code: Select all

$params = NULL;
instead of

Code: Select all

$params = array();


Complete explanation

The problem lies in the function lang()

1) $params is initialized to array()

Code: Select all

	$name = '';
	$params = array();
	$realm = 'admin';
2) the number of parameters of the function lang() is checked. In the guestbook-case there is only 1 parameter

Code: Select all

	if (func_num_args() > 0)
	{
		$name = func_get_arg(0);
		if (func_num_args() == 2 && is_array(func_get_arg(1)))
		{
			$params = func_get_arg(1);
		}
		else if (func_num_args() > 1)
		{
			$params = array_slice(func_get_args(), 1);
		}
	}
	else
	{
		return '';
	}
since in this case func_num_args = 1 the variable $params remains unchanged, so this is still the case: $params = array()

3) this next step is supposed to handle the the different parameter cases differently. In our case we have only 1 parameter, so we need $result = $lang[$realm][$name]; to be executed.

Code: Select all


	$result = '';

	if (isset($lang[$realm][$name]))
	{
		if (isset($params))
		{
			$result = vsprintf($lang[$realm][$name], $params);
		}
		else
		{
			$result = $lang[$realm][$name];
		}
	}
	else
	{
		$result = "--Add Me - $name --";
	}
But, lo, isset($params) returns TRUE because $params has been initialized to array() in the beginning so the line we need to be executed can never be executed.

Thus I believe $params was meant to be initialized as NULL instead of array().

I tried changing it and it got rid of the error.
Can anyone confirm this who knows their way around this stuff better than I do?

Cheers,
Cerno

Re: Guestbook error: Warning: vsprintf(): Too few arguments in /home/httpd/vhost

Posted: Thu Jul 26, 2007 3:10 pm
by Gregor
@Cerno: just applied your sugestion, and got rid of the error :)

Thanks for your work!
Gregor

Re: Guestbook error: Warning: vsprintf(): Too few arguments in /home/httpd/vhosts/ca

Posted: Mon Aug 27, 2007 12:16 pm
by tobik
This issue is still in CMSMS 1.1.1 Upolu

Re: Guestbook error: Warning: vsprintf(): Too few arguments in /home/httpd/vhosts/ca

Posted: Thu Aug 30, 2007 12:24 pm
by tobik
The root cause is in class.guestbook.php. Change line 767 from

Code: Select all

$delconf        = lang('deleteconfirm');
to

Code: Select all

$delconf        = lang('deleteconfirm', $r);

Re: Guestbook error: Warning: vsprintf(): Too few arguments in /home/httpd/vhost

Posted: Fri Sep 07, 2007 11:37 am
by Gregor
Update to version 1.1.1 and made the mentioned fix: problem solved :) Anyone who would like to upgrade svn?

Re: Guestbook error: Warning: vsprintf(): Too few arguments in /home/httpd/vhosts/ca

Posted: Fri Sep 07, 2007 11:51 am
by RonnyK
I'll post the solution in the QA-area. Someone then can change it in the SVN version.

Ronny

Re: Guestbook error: Warning: vsprintf(): Too few arguments in /home/httpd/vhosts/ca

Posted: Fri Sep 07, 2007 3:51 pm
by tobik
It is already in the SVN

Re: Guestbook error: Warning: vsprintf(): Too few arguments in /home/httpd/vhosts/ca

Posted: Fri Sep 07, 2007 9:13 pm
by tobik
Ronny, where is this QA area?

Re: Guestbook error: Warning: vsprintf(): Too few arguments in /home/httpd/vhosts/ca

Posted: Sat Sep 08, 2007 6:49 am
by RonnyK
The other post was in the QA area, where you replied  that you put it in SVN.

Ronny

Re: Guestbook error: Warning: vsprintf(): Too few arguments in /home/httpd/vhosts/ca

Posted: Sat Sep 08, 2007 7:17 am
by tobik
Ah, I see. Thanks