Skip to content

Commit

Permalink
deal with PHP bug 55701 (LogicException on GlobIterator)
Browse files Browse the repository at this point in the history
related #253, related 30dcb1f
  • Loading branch information
WanWizard committed Mar 17, 2018
1 parent 815f28c commit 4df97c7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 39 deletions.
2 changes: 1 addition & 1 deletion classes/cell.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ protected static function _download_package_zip($zip_url, $package, $version)
$files = $unzip->extract($zip_file, $tmp_folder);

// Grab the first folder out of it (we dont know what it's called)
foreach($pkgfolders = new \GlobIterator($tmp_folder.DS.'*') as $pkgfolder)
foreach(new \GlobIterator($tmp_folder.DS.'*') as $pkgfolder)
{
if ($pkgfolder->isDir())
{
Expand Down
54 changes: 18 additions & 36 deletions classes/generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -874,31 +874,22 @@ public static function migration($args, $build = true)
}
}

$migrations = new \GlobIterator($base_path.'migrations/*_'.$migration_name.'*');

try
$duplicates = array();
foreach($migrations = new \GlobIterator($base_path.'migrations/*_'.$migration_name.'*') as $migration)
{
$duplicates = array();
foreach($migrations as $migration)
// check if it's really a duplicate
$part = explode('_', basename($migration->getFilename(), '.php'), 2);
if ($part[1] != $migration_name)
{
// check if it's really a duplicate
$part = explode('_', basename($migration->getFilename(), '.php'), 2);
if ($part[1] != $migration_name)
$part = substr($part[1], strlen($migration_name)+1);
if ( ! is_numeric($part))
{
$part = substr($part[1], strlen($migration_name)+1);
if ( ! is_numeric($part))
{
// not a numbered suffix, but the same base classname
continue;
}
// not a numbered suffix, but the same base classname
continue;
}

$duplicates[] = $migration->getPathname();
}
}
catch (\LogicException $e)
{
throw new Exception("Unable to read existing migrations. Path does not exist, or you may have an 'open_basedir' defined");

$duplicates[] = $migration->getPathname();
}

// save the migration name, it's also used as table name
Expand Down Expand Up @@ -2033,23 +2024,14 @@ private static function _find_migration_number()
}
}

$files = new \GlobIterator($base_path .'migrations/*_*.php');
if ($files->count())
foreach(new \GlobIterator($base_path .'migrations/*_*.php') as $file)
{
try
{
$migrations = array();
foreach($files as $file)
{
$migrations[] = $file->getPathname();
}
sort($migrations);
list($last) = explode('_', basename(end($migrations)));
}
catch (\LogicException $e)
{
throw new Exception("Unable to read existing migrations. Path does not exist, or you may have an 'open_basedir' defined");
}
$migrations[] = $file->getPathname();
}
if ( ! empty($migrations))
{
sort($migrations);
list($last) = explode('_', basename(end($migrations)));
}
else
{
Expand Down
3 changes: 1 addition & 2 deletions views/admin/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
</li>

<?php
$files = new GlobIterator(APPPATH.'classes/controller/admin/*.php');
foreach($files as $file)
foreach(new GlobIterator(APPPATH.'classes/controller/admin/*.php') as $file)
{
$section_segment = $file->getBasename('.php');
$section_title = Inflector::humanize($section_segment);
Expand Down

0 comments on commit 4df97c7

Please sign in to comment.