CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • on submit str_repeat error (w/ blank credit card number)
Pages: [1]

Author Topic: on submit str_repeat error (w/ blank credit card number)  (Read 2416 times)

redgar

  • I’m new here
  • *
  • Posts: 26
  • Karma: 2
    • NJ Libertarian Party
  • CiviCRM version: 4.5.0
  • CMS version: Joomla 2.5.27
on submit str_repeat error (w/ blank credit card number)
October 25, 2007, 12:45:48 pm
I found that if the user presses submit on a donation page and the credit card number is blank I would get an warning on the top of the page:

Warning: str_repeat() [function.str-repeat]: Second argument has to be greater than or equal to 0. in $BASE/administrator/components/com_civicrm/civicrm/CRM/Utils/System.php on line 597

I've modified System.php as follows:

Change from:
    static function mungeCreditCard( $number, $keep = 4 ) {
        $replace = str_repeat( '*' , strlen( $number ) - $keep );
        return substr_replace( $number, $replace, 0, -$keep );
    }

Change to:

    static function mungeCreditCard( $number, $keep = 4 ) {
        $leng = strlen( $number );
        if ($leng < $keep ) {
           $leng = $keep;
        }
        $replace = str_repeat( '*' , $leng - $keep );
        return substr_replace( $number, $replace, 0, -$keep );
    }

I'm assuming the payment page will catch the blank credit card number (haven't gotten that part complete yet).

Warning - I'm new at this!  :D

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: on submit str_repeat error (w/ blank credit card number)
October 25, 2007, 05:41:25 pm

Can you reproduce this on demo.civicrm.org/drupal/

There is a form rule that ensure credit card is a valid cc number etc, so not sure how you are getting into that state. Someone else also reported this, but we cannot reproduce it :(

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

redgar

  • I’m new here
  • *
  • Posts: 26
  • Karma: 2
    • NJ Libertarian Party
  • CiviCRM version: 4.5.0
  • CMS version: Joomla 2.5.27
Re: on submit str_repeat error (w/ blank credit card number)
October 26, 2007, 09:15:55 am
I couldn't get the same error on the demo site.  I just reverted the code in System.php back to see if I still get the same error and it still occurs.

Some additonal info:

I have selected Pay Pal Pro with a paypal sandbox account.

As long as I fillout the other required info (email address, firstname, lastname) and leave the credit card blank I get the error.

NOTE:  I'm using php version 5.2.3.  According to

http://wiki.civicrm.org/confluence/display/CRMDOC/PayPal+Website+Payments+Pro+and+Express+Configuration

5.2.3 is NOT compatible with PayPal Pro.  (I couldn't find ANY verification of this on pay pal's site).  Could it be that PayPal Pro is fine with 5.2.3, however they System.php current use of str_repeat is the problem?  Did str_repeat change from php 5.2.0 to 5.2.3?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: on submit str_repeat error (w/ blank credit card number)
October 26, 2007, 11:01:12 am

we have noticed that php dumps core with paypal pro in versions greater than php 5.2.0 and drupal. If it works on your setup, great :)

I'll try reproducing this on joomla sometime soon

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviContribute (Moderator: Donald Lobo) »
  • on submit str_repeat error (w/ blank credit card number)

This forum was archived on 2017-11-26.