From ae534f69ffee64c844e3e2470e08acfa82ee75d5 Mon Sep 17 00:00:00 2001
From: pookey
Date: Sun, 3 Sep 2006 21:32:56 +0000
Subject: [PATCH] minor changes to Doctrine::compile(), adding extra error
handling and improving docs
---
Doctrine.php | 32 ++++++++++++---------
manual/docs/Getting started - Compiling.php | 8 ++++++
2 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/Doctrine.php b/Doctrine.php
index 75ed25811..61e77bf69 100644
--- a/Doctrine.php
+++ b/Doctrine.php
@@ -386,7 +386,6 @@ final class Doctrine {
}
/**
* method for making a single file of most used doctrine runtime components
- *
* including the compiled file instead of multiple files (in worst
* cases dozens of files) can improve performance by an order of magnitude
*
@@ -449,28 +448,35 @@ final class Doctrine {
$end = $refl -> getEndLine();
$ret = array_merge($ret,
- array_slice($lines,
- $start,
- ($end - $start)));
-
+ array_slice($lines,
+ $start,
+ ($end - $start)));
}
$file = self::$path.DIRECTORY_SEPARATOR.'Doctrine.compiled.php';
+ if (!is_writable($file))
+ throw new Doctrine_Exception("Couldn't write compiled data. $file is not writable");
- $fp = fopen($file, 'w+');
- fwrite($fp, "");
+ // first write the 'compiled' data to a text file, so
+ // that we can use php_strip_whitespace (which only works on files)
+ $fp = fopen($file, 'w');
+ if ($fp === false)
+ throw new Doctrine_Exception("Couldn't write compiled data. Failed to open $file");
+ fwrite($fp, "
+ Compiling is a method for making a single file of most used doctrine runtime components
+ including the compiled file instead of multiple files (in worst cases dozens of files)
+ can improve performance by an order of magnitude.
+
+
+ In cases where this might fail, a Doctrine_Exception is throw detailing the error.
+