Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / lib / Drupal / Component / Gettext / PoStreamWriter.php
index 5419b210aafbd29bd34d05a144063b561fcb55c7..1e3f3871e3991a77c9cd015f2f1bc56d0ee9622e 100644 (file)
@@ -81,7 +81,7 @@ class PoStreamWriter implements PoWriterInterface, PoStreamInterface {
   /**
    * Implements Drupal\Component\Gettext\PoStreamInterface::close().
    *
-   * @throws Exception
+   * @throws \Exception
    *   If the stream is not open.
    */
   public function close() {
@@ -89,7 +89,7 @@ class PoStreamWriter implements PoWriterInterface, PoStreamInterface {
       fclose($this->_fd);
     }
     else {
-      throw new Exception('Cannot close stream that is not open.');
+      throw new \Exception('Cannot close stream that is not open.');
     }
   }
 
@@ -100,13 +100,13 @@ class PoStreamWriter implements PoWriterInterface, PoStreamInterface {
    *   Piece of string to write to the stream. If the value is not directly a
    *   string, casting will happen in writing.
    *
-   * @throws Exception
+   * @throws \Exception
    *   If writing the data is not possible.
    */
   private function write($data) {
     $result = fwrite($this->_fd, $data);
-    if ($result === FALSE) {
-      throw new Exception('Unable to write data: ' . substr($data, 0, 20));
+    if ($result === FALSE || $result != strlen($data)) {
+      throw new \Exception('Unable to write data: ' . substr($data, 0, 20));
     }
   }
 
@@ -137,12 +137,12 @@ class PoStreamWriter implements PoWriterInterface, PoStreamInterface {
   /**
    * Implements Drupal\Component\Gettext\PoStreamInterface::getURI().
    *
-   * @throws Exception
+   * @throws \Exception
    *   If the URI is not set.
    */
   public function getURI() {
     if (empty($this->_uri)) {
-      throw new Exception('No URI set.');
+      throw new \Exception('No URI set.');
     }
     return $this->_uri;
   }