aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--application/FileUtils.php2
-rw-r--r--application/LinkDB.php3
-rw-r--r--application/Updater.php1
-rw-r--r--application/config/ConfigJson.php2
-rw-r--r--application/config/ConfigManager.php2
-rw-r--r--application/config/ConfigPhp.php2
-rw-r--r--application/exceptions/IOException.php5
-rw-r--r--composer.json1
-rw-r--r--tests/FileUtilsTest.php8
-rw-r--r--tests/LinkDBTest.php4
-rw-r--r--tests/config/ConfigJsonTest.php4
11 files changed, 24 insertions, 10 deletions
diff --git a/application/FileUtils.php b/application/FileUtils.php
index b89ea12b..ba409821 100644
--- a/application/FileUtils.php
+++ b/application/FileUtils.php
@@ -1,5 +1,7 @@
1<?php 1<?php
2 2
3use Shaarli\Exceptions\IOException;
4
3require_once 'exceptions/IOException.php'; 5require_once 'exceptions/IOException.php';
4 6
5/** 7/**
diff --git a/application/LinkDB.php b/application/LinkDB.php
index 4bbc2950..87a53e2e 100644
--- a/application/LinkDB.php
+++ b/application/LinkDB.php
@@ -1,4 +1,7 @@
1<?php 1<?php
2
3use Shaarli\Exceptions\IOException;
4
2/** 5/**
3 * Data storage for links. 6 * Data storage for links.
4 * 7 *
diff --git a/application/Updater.php b/application/Updater.php
index 6b94c5e3..c0d541b4 100644
--- a/application/Updater.php
+++ b/application/Updater.php
@@ -2,6 +2,7 @@
2use Shaarli\Config\ConfigJson; 2use Shaarli\Config\ConfigJson;
3use Shaarli\Config\ConfigPhp; 3use Shaarli\Config\ConfigPhp;
4use Shaarli\Config\ConfigManager; 4use Shaarli\Config\ConfigManager;
5use Shaarli\Exceptions\IOException;
5use Shaarli\Thumbnailer; 6use Shaarli\Thumbnailer;
6 7
7/** 8/**
diff --git a/application/config/ConfigJson.php b/application/config/ConfigJson.php
index 8c8d5610..4509357c 100644
--- a/application/config/ConfigJson.php
+++ b/application/config/ConfigJson.php
@@ -47,7 +47,7 @@ class ConfigJson implements ConfigIO
47 $print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0; 47 $print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0;
48 $data = self::getPhpHeaders() . json_encode($conf, $print) . self::getPhpSuffix(); 48 $data = self::getPhpHeaders() . json_encode($conf, $print) . self::getPhpSuffix();
49 if (!file_put_contents($filepath, $data)) { 49 if (!file_put_contents($filepath, $data)) {
50 throw new \IOException( 50 throw new \Shaarli\Exceptions\IOException(
51 $filepath, 51 $filepath,
52 t('Shaarli could not create the config file. '. 52 t('Shaarli could not create the config file. '.
53 'Please make sure Shaarli has the right to write in the folder is it installed in.') 53 'Please make sure Shaarli has the right to write in the folder is it installed in.')
diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php
index 32aaea48..e6c35073 100644
--- a/application/config/ConfigManager.php
+++ b/application/config/ConfigManager.php
@@ -207,7 +207,7 @@ class ConfigManager
207 * 207 *
208 * @throws MissingFieldConfigException: a mandatory field has not been provided in $conf. 208 * @throws MissingFieldConfigException: a mandatory field has not been provided in $conf.
209 * @throws UnauthorizedConfigException: user is not authorize to change configuration. 209 * @throws UnauthorizedConfigException: user is not authorize to change configuration.
210 * @throws \IOException: an error occurred while writing the new config file. 210 * @throws \Shaarli\Exceptions\IOException: an error occurred while writing the new config file.
211 */ 211 */
212 public function write($isLoggedIn) 212 public function write($isLoggedIn)
213 { 213 {
diff --git a/application/config/ConfigPhp.php b/application/config/ConfigPhp.php
index 9625fe1a..9ed5d31f 100644
--- a/application/config/ConfigPhp.php
+++ b/application/config/ConfigPhp.php
@@ -124,7 +124,7 @@ class ConfigPhp implements ConfigIO
124 if (!file_put_contents($filepath, $configStr) 124 if (!file_put_contents($filepath, $configStr)
125 || strcmp(file_get_contents($filepath), $configStr) != 0 125 || strcmp(file_get_contents($filepath), $configStr) != 0
126 ) { 126 ) {
127 throw new \IOException( 127 throw new \Shaarli\Exceptions\IOException(
128 $filepath, 128 $filepath,
129 t('Shaarli could not create the config file. '. 129 t('Shaarli could not create the config file. '.
130 'Please make sure Shaarli has the right to write in the folder is it installed in.') 130 'Please make sure Shaarli has the right to write in the folder is it installed in.')
diff --git a/application/exceptions/IOException.php b/application/exceptions/IOException.php
index 18e46b77..2aa25e5c 100644
--- a/application/exceptions/IOException.php
+++ b/application/exceptions/IOException.php
@@ -1,4 +1,7 @@
1<?php 1<?php
2namespace Shaarli\Exceptions;
3
4use Exception;
2 5
3/** 6/**
4 * Exception class thrown when a filesystem access failure happens 7 * Exception class thrown when a filesystem access failure happens
@@ -17,6 +20,6 @@ class IOException extends Exception
17 { 20 {
18 $this->path = $path; 21 $this->path = $path;
19 $this->message = empty($message) ? t('Error accessing') : $message; 22 $this->message = empty($message) ? t('Error accessing') : $message;
20 $this->message .= ' "' . $this->path .'"'; 23 $this->message .= ' "' . $this->path . '"';
21 } 24 }
22} 25}
diff --git a/composer.json b/composer.json
index dccf83b6..027203f4 100644
--- a/composer.json
+++ b/composer.json
@@ -36,6 +36,7 @@
36 "Shaarli\\Api\\Exceptions\\": "application/api/exceptions", 36 "Shaarli\\Api\\Exceptions\\": "application/api/exceptions",
37 "Shaarli\\Config\\": "application/config/", 37 "Shaarli\\Config\\": "application/config/",
38 "Shaarli\\Config\\Exception\\": "application/config/exception", 38 "Shaarli\\Config\\Exception\\": "application/config/exception",
39 "Shaarli\\Exceptions\\": "application/exceptions",
39 "Shaarli\\Security\\": "application/security" 40 "Shaarli\\Security\\": "application/security"
40 } 41 }
41 } 42 }
diff --git a/tests/FileUtilsTest.php b/tests/FileUtilsTest.php
index d764e495..9596dba9 100644
--- a/tests/FileUtilsTest.php
+++ b/tests/FileUtilsTest.php
@@ -1,5 +1,7 @@
1<?php 1<?php
2 2
3use Shaarli\Exceptions\IOException;
4
3require_once 'application/FileUtils.php'; 5require_once 'application/FileUtils.php';
4 6
5/** 7/**
@@ -48,7 +50,7 @@ class FileUtilsTest extends PHPUnit_Framework_TestCase
48 /** 50 /**
49 * File not writable: raise an exception. 51 * File not writable: raise an exception.
50 * 52 *
51 * @expectedException IOException 53 * @expectedException Shaarli\Exceptions\IOException
52 * @expectedExceptionMessage Error accessing "sandbox/flat.db" 54 * @expectedExceptionMessage Error accessing "sandbox/flat.db"
53 */ 55 */
54 public function testWriteWithoutPermission() 56 public function testWriteWithoutPermission()
@@ -61,7 +63,7 @@ class FileUtilsTest extends PHPUnit_Framework_TestCase
61 /** 63 /**
62 * Folder non existent: raise an exception. 64 * Folder non existent: raise an exception.
63 * 65 *
64 * @expectedException IOException 66 * @expectedException Shaarli\Exceptions\IOException
65 * @expectedExceptionMessage Error accessing "nopefolder" 67 * @expectedExceptionMessage Error accessing "nopefolder"
66 */ 68 */
67 public function testWriteFolderDoesNotExist() 69 public function testWriteFolderDoesNotExist()
@@ -72,7 +74,7 @@ class FileUtilsTest extends PHPUnit_Framework_TestCase
72 /** 74 /**
73 * Folder non writable: raise an exception. 75 * Folder non writable: raise an exception.
74 * 76 *
75 * @expectedException IOException 77 * @expectedException Shaarli\Exceptions\IOException
76 * @expectedExceptionMessage Error accessing "sandbox" 78 * @expectedExceptionMessage Error accessing "sandbox"
77 */ 79 */
78 public function testWriteFolderPermission() 80 public function testWriteFolderPermission()
diff --git a/tests/LinkDBTest.php b/tests/LinkDBTest.php
index c763c0cb..9b2f35e6 100644
--- a/tests/LinkDBTest.php
+++ b/tests/LinkDBTest.php
@@ -3,6 +3,8 @@
3 * Link datastore tests 3 * Link datastore tests
4 */ 4 */
5 5
6use Shaarli\Exceptions\IOException;
7
6require_once 'application/Cache.php'; 8require_once 'application/Cache.php';
7require_once 'application/FileUtils.php'; 9require_once 'application/FileUtils.php';
8require_once 'application/LinkDB.php'; 10require_once 'application/LinkDB.php';
@@ -100,7 +102,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
100 /** 102 /**
101 * Attempt to instantiate a LinkDB whereas the datastore is not writable 103 * Attempt to instantiate a LinkDB whereas the datastore is not writable
102 * 104 *
103 * @expectedException IOException 105 * @expectedException Shaarli\Exceptions\IOException
104 * @expectedExceptionMessageRegExp /Error accessing "null"/ 106 * @expectedExceptionMessageRegExp /Error accessing "null"/
105 */ 107 */
106 public function testConstructDatastoreNotWriteable() 108 public function testConstructDatastoreNotWriteable()
diff --git a/tests/config/ConfigJsonTest.php b/tests/config/ConfigJsonTest.php
index d237bc80..99c1ea56 100644
--- a/tests/config/ConfigJsonTest.php
+++ b/tests/config/ConfigJsonTest.php
@@ -111,7 +111,7 @@ class ConfigJsonTest extends \PHPUnit_Framework_TestCase
111 /** 111 /**
112 * Write to invalid path. 112 * Write to invalid path.
113 * 113 *
114 * @expectedException \IOException 114 * @expectedException \Shaarli\Exceptions\IOException
115 */ 115 */
116 public function testWriteInvalidArray() 116 public function testWriteInvalidArray()
117 { 117 {
@@ -122,7 +122,7 @@ class ConfigJsonTest extends \PHPUnit_Framework_TestCase
122 /** 122 /**
123 * Write to invalid path. 123 * Write to invalid path.
124 * 124 *
125 * @expectedException \IOException 125 * @expectedException \Shaarli\Exceptions\IOException
126 */ 126 */
127 public function testWriteInvalidBlank() 127 public function testWriteInvalidBlank()
128 { 128 {