summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2009-11-27 19:00:20 +0100
committerDerek Jones <derek.jones@ellislab.com>2009-11-27 19:00:20 +0100
commit788b00f7eaad969120079acedc82e8d60b0e2a46 (patch)
treefe7e91590e76a4a27b5aaefdda45e9180f56366e
parentde27adfa84600ea863e8737d60861991ff2bbb62 (diff)
non-backwards compatible change to get_dir_file_info() for performance reasons, as well as fixing recursive bug
-rw-r--r--system/helpers/file_helper.php14
-rw-r--r--user_guide/changelog.html5
-rw-r--r--user_guide/helpers/file_helper.html5
-rw-r--r--user_guide/installation/upgrade_173.html106
4 files changed, 121 insertions, 9 deletions
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index cb3d60ee9..41ec2648e 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -220,7 +220,7 @@ if ( ! function_exists('get_filenames'))
*/
if ( ! function_exists('get_dir_file_info'))
{
- function get_dir_file_info($source_dir, $include_path = FALSE, $_recursion = FALSE)
+ function get_dir_file_info($source_dir, $top_level_only = TRUE, $_recursion = FALSE)
{
static $_filedata = array();
$relative_path = $source_dir;
@@ -234,18 +234,20 @@ if ( ! function_exists('get_dir_file_info'))
$source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
}
+ // foreach (scandir($source_dir, 1) as $file) // In addition to being PHP5+, scandir() is simply not as fast
while (FALSE !== ($file = readdir($fp)))
{
- if (@is_dir($source_dir.$file) && strncmp($file, '.', 1) !== 0)
- {
- get_dir_file_info($source_dir.$file.DIRECTORY_SEPARATOR, $include_path, TRUE);
- }
- elseif (strncmp($file, '.', 1) !== 0)
+ if (@is_dir($source_dir.$file) AND strncmp($file, '.', 1) !== 0 AND $top_level_only === FALSE)
{
+ get_dir_file_info($source_dir.$file.DIRECTORY_SEPARATOR, $top_level_only, TRUE);
+ }
+ elseif (strncmp($file, '.', 1) !== 0)
+ {
$_filedata[$file] = get_file_info($source_dir.$file);
$_filedata[$file]['relative_path'] = $relative_path;
}
}
+
return $_filedata;
}
else
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index c8f16fac9..22a54a25d 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -71,19 +71,22 @@ SVN Revision: </p>
<ul>
<li>Added accept-charset to the list of inserted attributes of <kbd>form_open()</kbd> in the <a href="helpers/form_helper.html">Form Helper</a>.</li>
<li>Deprecated the <kbd>dohash()</kbd> function in favur of <kbd>do_hash()</kbd> for naming consistency.</li>
+ <li>Non-backwards compatible change made to <kbd>get_dir_file_info()</kbd> in the <a href="helpers/file_helper.html">File Helper</a>. No longer recurses
+ by default so as to encourage responsible use (this function can cause server performance issues when used without caution).</li>
</ul>
</li>
</ul>
<h3>Bug fixes for 1.7.3</h3>
<ul>
- <li>Increased randomness with<kbd>is_really_writable()</kbd> to avoid file collisions when hundreds or thousands of requests occur at once.</li>
+ <li>Increased randomness with <kbd>is_really_writable()</kbd> to avoid file collisions when hundreds or thousands of requests occur at once.</li>
<li>Fixed or clarified assorted user guide typos or examples.</li>
<li>Made <kbd>get_mime_by_extension()</kbd> case insensitive.</li>
<li>Fixed a bug in the Form Validation library where fields passed as rule parameters were not being translated (#9132)</li>
<li>Switched some DIR_WRITE_MODE constant uses to FILE_WRITE_MODE where files and not directories are being operated on.</li>
<li>Modified inflector helper to properly pluralize words that end in 'ch' or 'sh'</li>
<li>Fixed a bug in xss_clean() that was not allowing hyphens in query strings of submitted URLs.</li>
+ <li>Fixed bugs in get_dir_file_info() and get_file_info() in the File Helper with recursion, and file paths on Windows.</li>
</ul>
<h2>Version 1.7.2</h2>
diff --git a/user_guide/helpers/file_helper.html b/user_guide/helpers/file_helper.html
index d4b1f20b4..b3f81be1a 100644
--- a/user_guide/helpers/file_helper.html
+++ b/user_guide/helpers/file_helper.html
@@ -125,9 +125,10 @@ CodeIgniter uses a front controller so paths are always relative to the main sit
<p>Takes a server path as input and returns an array containing the names of all files contained within it. The file path
can optionally be added to the file names by setting the second parameter to TRUE.</p>
-<h2>get_dir_file_info('<var>path/to/directory/</var>')</h2>
+<h2>get_dir_file_info('<var>path/to/directory/</var>', <kbd>$top_level_only</kbd> = TRUE)</h2>
-<p>Reads the specified directory and builds an array containing the filenames, filesize, dates, and permissions. Any sub-folders contained within the specified path are read as well.</p>
+<p>Reads the specified directory and builds an array containing the filenames, filesize, dates, and permissions. Sub-folders contained within the specified path are only read if forced
+ by sending the second parameter, <kbd>$top_level_only</kbd> to <samp>FALSE</samp>, as this can be an intensive operation.</p>
<h2>get_file_info('<var>path/to/file</var>', <kbd>$file_information</kbd>)</h2>
diff --git a/user_guide/installation/upgrade_173.html b/user_guide/installation/upgrade_173.html
new file mode 100644
index 000000000..d395c1fd6
--- /dev/null
+++ b/user_guide/installation/upgrade_173.html
@@ -0,0 +1,106 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Upgrading from 1.7.2 to 1.7.3 : CodeIgniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../nav/nav.js"></script>
+<script type="text/javascript" src="../nav/prototype.lite.js"></script>
+<script type="text/javascript" src="../nav/moo.fx.js"></script>
+<script type="text/javascript" src="../nav/user_guide_menu.js"></script>
+
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='ExpressionEngine Dev Team' />
+<meta name='description' content='CodeIgniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>CodeIgniter User Guide Version 1.7.2</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://codeigniter.com/">CodeIgniter Home</a> &nbsp;&#8250;&nbsp;
+<a href="../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;
+Upgrading from 1.7.2 to 1.7.3
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+<h1>Upgrading from 1.7.2 to 1.7.3</h1>
+
+<p>Before performing an update you should take your site offline by replacing the index.php file with a static one.</p>
+
+
+
+<h2>Step 1: Update your CodeIgniter files</h2>
+
+<p>Replace these files and directories in your "system" folder with the new versions:</p>
+
+<ul>
+
+<li><dfn>system/codeigniter</dfn></li>
+<li><dfn>system/database</dfn></li>
+<li><dfn>system/helpers</dfn></li>
+<li><dfn>system/language</dfn></li>
+<li><dfn>system/libraries</dfn></li>
+</ul>
+
+<p class="important"><strong>Note:</strong> If you have any custom developed files in these folders please make copies of them first.</p>
+
+<h2>Step 2: Adjust get_dir_file_info() where necessary</h2>
+
+<p>Version 1.7.3 brings a non-backwards compatible change to <kbd>get_dir_file_info()</kbd> in the <a href="../helpers/file_helper.html">File Helper</a>. Non-backwards compatible changes are extremely rare
+ in CodeIgniter, but this one we feel was warranted due to how easy it was to create serious server performance issues. If you <em>need</em>
+ recursiveness where you are using this helper function, change such instances, setting the second parameter, <kbd>$top_level_only</kbd> to FALSE:</p>
+
+<code>get_dir_file_info('/path/to/directory', <kbd>FALSE</kbd>);</code>
+
+<h2>Step 3: Update your user guide</h2>
+<p>Please replace your local copy of the user guide with the new version, including the image files.</p>
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic:&nbsp;&nbsp;<a href="index.html">Installation Instructions</a>
+&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+<a href="../index.html">User Guide Home</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
+Next Topic:&nbsp;&nbsp;<a href="troubleshooting.html">Troubleshooting</a>
+</p>
+<p><a href="http://codeigniter.com">CodeIgniter</a> &nbsp;&middot;&nbsp; Copyright &#169; 2006-2009 &nbsp;&middot;&nbsp; <a href="http://ellislab.com/">Ellislab, Inc.</a></p>
+</div>
+
+</body>
+</html> \ No newline at end of file