Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-11776

strtr will issue a notice in user->format_date on at least php 5.5.0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Trivial Trivial
    • 3.0.12-RC3
    • 3.0.11
    • None
    • None
    • php 5.5.0

      I'm not entirely sure when this started, but it must be in between php 5.3.2 and 5.5.0. Anyway, the thing is php will now output a notice when strtr is called with multidimensional $replace_pairs array, even if the array entries are not used.

      And this is precisely what occurs in includes/sessions.php, where format_date will call strtr with one array in the $date_cache[$format]['lang'] entry (the AGO key).

      From my experience, the result is not altered, strtr works just as before, but throws a notice on recent versions.

      <?php
      $str = 'hi all, I said hello';
      $replace_pairs = array(
      	'all' => 'everybody',
      	'unused' => array('somtehing', 'something else'),
      	'hello' => 'hey',
      );
      // php 5.5.0 Notice: Array to string conversion in test.php on line 9
      echo strtr($str, $replace_pairs); // hi everybody, I said hey
      

      Replacing strtr with @strtr seems a working solution.

            bantu Andreas Fischer [X] (Inactive)
            dcz dcz [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: