[glotpress-updates] [GlotPress] #211: Relying on glob()'s sorting is not reliable.

GlotPress glotpress-updates at lists.automattic.com
Mon Jul 23 04:41:53 UTC 2012


#211: Relying on glob()'s sorting is not reliable.
-------------------------+----------------------
 Reporter:  markjaquith  |      Owner:  somebody
     Type:  defect       |     Status:  new
 Priority:  critical     |  Milestone:
Component:  general      |    Version:
 Keywords:  needs-patch  |
-------------------------+----------------------
 {{{
 PHP Fatal error:  Class 'GP_Route_Main' not found in /gp-
 includes/routes/index.php on line 2
 }}}

 Apparently you can't rely on {{{glob()}}} to return files in a predictable
 order.

 Locally, it is fine:

 {{{
 gp-includes/routes $ php -r 'var_export( glob( "*.php" ) );'
 array (
   0 => '_main.php',
   1 => 'index.php',
   2 => 'login.php',
   3 => 'original.php',
   4 => 'project.php',
   5 => 'translation-set.php',
   6 => 'translation.php',
 )
 }}}

 On my server, _main does not load first:

 {{{
 gp-includes/routes $ php -r 'var_export( glob( "*.php" ) );'
 array (
   0 => 'index.php',
   1 => 'login.php',
   2 => '_main.php',
   3 => 'original.php',
   4 => 'project.php',
   5 => 'translation.php',
   6 => 'translation-set.php',
 )
 }}}

 My suggestion is to pass those {{{glob()}}} calls through a sorting
 function so you know you're getting the ordering you want. Alternatively,
 just list out the includes and save the FS some wear and tear.

-- 
Ticket URL: <http://glotpress.trac.wordpress.org/ticket/211>
GlotPress <http://trac.glotpress.org>
Easy comin', easy goin'


More information about the glotpress-updates mailing list