Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-11776

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

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Trivial
    • Resolution: Duplicate
    • Affects Version/s: 3.0.11
    • Fix Version/s: 3.0.12-RC3
    • Component/s: None
    • Labels:
      None
    • Environment:
      php 5.5.0

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: