Skip to content

Commit

Permalink
BackwardsCompatibilityBreak - Changed the second parameter of fFile::…
Browse files Browse the repository at this point in the history
…output() from `$ignore_output_buffer` to `$filename`
  • Loading branch information
wbond committed Apr 12, 2012
1 parent 322743e commit ff14fd2
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions classes/fFile.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
* @package Flourish * @package Flourish
* @link http://flourishlib.com/fFile * @link http://flourishlib.com/fFile
* *
* @version 1.0.0b11 * @version 1.0.0b12
* @changes 1.0.0b12 Backwards compatibility break - Changed the second parameter of ::output() from `$ignore_output_buffer` to `$filename` [wb, 2009-03-05]
* @changes 1.0.0b11 Changed ::__clone() and ::duplicate() to copy file permissions to the new file [wb, 2009-01-05] * @changes 1.0.0b11 Changed ::__clone() and ::duplicate() to copy file permissions to the new file [wb, 2009-01-05]
* @changes 1.0.0b10 Fixed ::duplicate() so an exception is not thrown when no parameters are passed [wb, 2009-01-05] * @changes 1.0.0b10 Fixed ::duplicate() so an exception is not thrown when no parameters are passed [wb, 2009-01-05]
* @changes 1.0.0b9 Removed the dependency on fBuffer [wb, 2009-01-05] * @changes 1.0.0b9 Removed the dependency on fBuffer [wb, 2009-01-05]
Expand Down Expand Up @@ -915,25 +916,26 @@ public function next()
* This method is primarily intended for when PHP is used to control access * This method is primarily intended for when PHP is used to control access
* to files. * to files.
* *
* @param boolean $headers If HTTP headers for the file should be included * @param boolean $headers If HTTP headers for the file should be included
* @param boolean $ignore_output_buffer If the current state of the output buffer should be ignored * @param string $filename Present the file as an attachment with this filename instead of just outputting type headers
* @return fFile The file object, to allow for method chaining * @return fFile The file object, to allow for method chaining
*/ */
public function output($headers, $ignore_output_buffer=FALSE) public function output($headers, $filename=NULL)
{ {
$this->tossIfException(); $this->tossIfException();


if (!$ignore_output_buffer) { if (ob_get_level() > 0) {
if (ob_get_level() > 0) { throw new fProgrammerException(
throw new fProgrammerException( 'The method requested, %s(), should not normally be used when output buffering is turned off, due to memory issues. If it is neccessary to have output buffering on, please pass %s as the second parameter to this method.',
'The method requested, %s(), should not normally be used when output buffering is turned off, due to memory issues. If it is neccessary to have output buffering on, please pass %s as the second parameter to this method.', 'output',
'output', 'TRUE'
'TRUE' );
);
}
} }


if ($headers) { if ($headers) {
if ($filename !== NULL) {
header('Content-Disposition: attachment; filename="' . $filename . '"');
}
header('Cache-Control: '); header('Cache-Control: ');
header('Content-Length: ' . $this->getFilesize()); header('Content-Length: ' . $this->getFilesize());
header('Content-Type: ' . $this->getMimeType()); header('Content-Type: ' . $this->getMimeType());
Expand Down Expand Up @@ -1141,4 +1143,4 @@ public function write($data)
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */

0 comments on commit ff14fd2

Please sign in to comment.