Skip to content

Commit ed74003

Browse files
authored
Merge pull request #1 from codeigniter4/develop
Merged
2 parents a5fc95b + db70cf0 commit ed74003

File tree

6 files changed

+77
-11
lines changed

6 files changed

+77
-11
lines changed

system/Cache/Handlers/WincacheHandler.php

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?php namespace CodeIgniter\Cache\Handlers;
1+
<?php
2+
namespace CodeIgniter\Cache\Handlers;
23

34
/**
45
* CodeIgniter
@@ -38,6 +39,11 @@
3839

3940
use CodeIgniter\Cache\CacheInterface;
4041

42+
/**
43+
* Cache handler for WinCache from Microsoft & IIS.
44+
* Windows-only, so not testable on travis-ci.
45+
* Unusable methods flagged for code coverage ignoring.
46+
*/
4147
class WincacheHandler implements CacheInterface
4248
{
4349

@@ -59,6 +65,8 @@ public function __construct($config)
5965

6066
/**
6167
* Takes care of any handler-specific setup that must be done.
68+
*
69+
* @codeCoverageIgnore
6270
*/
6371
public function initialize()
6472
{
@@ -70,6 +78,8 @@ public function initialize()
7078
/**
7179
* Attempts to fetch an item from the cache store.
7280
*
81+
* @codeCoverageIgnore
82+
*
7383
* @param string $key Cache item name
7484
*
7585
* @return mixed
@@ -90,6 +100,8 @@ public function get(string $key)
90100
/**
91101
* Saves an item to the cache store.
92102
*
103+
* @codeCoverageIgnore
104+
*
93105
* @param string $key Cache item name
94106
* @param mixed $value The data to save
95107
* @param integer $ttl Time To Live, in seconds (default 60)
@@ -108,6 +120,8 @@ public function save(string $key, $value, int $ttl = 60)
108120
/**
109121
* Deletes a specific item from the cache store.
110122
*
123+
* @codeCoverageIgnore
124+
*
111125
* @param string $key Cache item name
112126
*
113127
* @return mixed
@@ -124,8 +138,9 @@ public function delete(string $key)
124138
/**
125139
* Performs atomic incrementation of a raw stored value.
126140
*
127-
* @param string $key Cache ID
128-
* @param integer $offset Step/value to increase by
141+
* @codeCoverageIgnore
142+
* @param string $key Cache ID
143+
* @param integer $offset Step/value to increase by
129144
*
130145
* @return mixed
131146
*/
@@ -144,6 +159,8 @@ public function increment(string $key, int $offset = 1)
144159
/**
145160
* Performs atomic decrementation of a raw stored value.
146161
*
162+
* @codeCoverageIgnore
163+
*
147164
* @param string $key Cache ID
148165
* @param integer $offset Step/value to increase by
149166
*
@@ -164,6 +181,8 @@ public function decrement(string $key, int $offset = 1)
164181
/**
165182
* Will delete all items in the entire cache.
166183
*
184+
* @codeCoverageIgnore
185+
*
167186
* @return mixed
168187
*/
169188
public function clean()
@@ -176,6 +195,8 @@ public function clean()
176195
/**
177196
* Returns information on the entire cache.
178197
*
198+
* @codeCoverageIgnore
199+
*
179200
* The information returned and the structure of the data
180201
* varies depending on the handler.
181202
*
@@ -191,7 +212,8 @@ public function getCacheInfo()
191212
/**
192213
* Returns detailed information about the specific item in the cache.
193214
*
194-
* @param string $key Cache item name.
215+
* @codeCoverageIgnore
216+
* @param string $key Cache item name.
195217
*
196218
* @return mixed
197219
*/

system/Model.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ public function chunk($size = 100, \Closure $userFunc)
10051005
throw DataException::forEmptyDataset('chunk');
10061006
}
10071007

1008-
$rows = $rows->getResult();
1008+
$rows = $rows->getResult($this->tempReturnType);
10091009

10101010
$offset += $size;
10111011

tests/system/Cache/CacheFactoryTest.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
<?php namespace CodeIgniter\Cache;
1+
<?php
2+
namespace CodeIgniter\Cache;
23

34
class CacheFactoryTest extends \CIUnitTestCase
45
{
6+
57
private static $directory = 'CacheFactory';
68
private $cacheFactory;
79
private $config;
@@ -90,4 +92,28 @@ public function testGetDummyHandler()
9092
$this->config = new \Config\Cache();
9193
$this->config->storePath .= self::$directory;
9294
}
95+
96+
public function testHandlesBadHandler()
97+
{
98+
if (! is_dir($this->config->storePath))
99+
{
100+
mkdir($this->config->storePath, 0555, true);
101+
}
102+
103+
$this->config->handler = 'dummy';
104+
105+
if (stripos('win', php_uname()) === 0)
106+
{
107+
$this->assertTrue(true); // can't test properly if we are on Windows
108+
}
109+
else
110+
{
111+
$this->assertInstanceOf(\CodeIgniter\Cache\Handlers\DummyHandler::class, $this->cacheFactory->getHandler($this->config, 'wincache', 'wincache'));
112+
}
113+
114+
//Initialize path
115+
$this->config = new \Config\Cache();
116+
$this->config->storePath .= self::$directory;
117+
}
118+
93119
}

tests/system/Cache/Handlers/FileHandlerTest.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
<?php namespace CodeIgniter\Cache\Handlers;
1+
<?php
2+
namespace CodeIgniter\Cache\Handlers;
23

34
set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline, array $errcontext) {
45
//throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
56
});
67

78
class FileHandlerTest extends \CIUnitTestCase
89
{
10+
911
private static $directory = 'FileHandler';
1012
private static $key1 = 'key1';
1113
private static $key2 = 'key2';
@@ -127,7 +129,9 @@ public function testDecrement()
127129
{
128130
$this->fileHandler->save(self::$key1, 10);
129131
$this->fileHandler->save(self::$key2, 'value');
130-
$this->fileHandler->save(self::$key3, 0);
132+
133+
// Line following commented out to force the cache to add a zero entry for key3
134+
// $this->fileHandler->save(self::$key3, 0);
131135

132136
$this->assertSame(9, $this->fileHandler->decrement(self::$key1, 1));
133137
$this->assertFalse($this->fileHandler->decrement(self::$key2, 1));
@@ -158,6 +162,17 @@ public function testGetMetaData()
158162
$this->assertSame('value', $actual['data']);
159163
}
160164

165+
public function testGetCacheInfo()
166+
{
167+
$time = time();
168+
$this->fileHandler->save(self::$key1, 'value');
169+
170+
$actual = $this->fileHandler->getCacheInfo();
171+
$this->assertArrayHasKey(self::$key1, $actual);
172+
$this->assertEquals(self::$key1, $actual[self::$key1]['name']);
173+
$this->assertArrayHasKey('server_path', $actual[self::$key1]);
174+
}
175+
161176
public function testIsSupported()
162177
{
163178
$this->assertTrue($this->fileHandler->isSupported());
@@ -179,10 +194,12 @@ public function testFileHandler()
179194
$this->assertArrayHasKey('executable', $actual);
180195
$this->assertArrayHasKey('fileperms', $actual);
181196
}
197+
182198
}
183199

184200
final class BaseTestFileHandler extends FileHandler
185201
{
202+
186203
private static $directory = 'FileHandler';
187204
private $config;
188205

@@ -210,4 +227,5 @@ public function getFileInfoTest()
210227
'fileperms',
211228
]);
212229
}
230+
213231
}

user_guide_src/source/database/examples.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Standard Insert
8787

8888
$sql = "INSERT INTO mytable (title, name) VALUES (".$db->escape($title).", ".$db->escape($name).")";
8989
$db->query($sql);
90-
echo $db->getAffectedRows();
90+
echo $db->affectedRows();
9191

9292
Query Builder Query
9393
===================

user_guide_src/source/libraries/files.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ Once you have an instance, you have the full power of the SplFileInfo class at t
3030
echo $file->getBasename();
3131
// Get last modified time
3232
echo $file->getMTime();
33-
// Get the true realpath
34-
echo $file->getRealpath();
33+
// Get the true real path
34+
echo $file->getRealPath();
3535
// Get the file permissions
3636
echo $file->getPerms();
3737

0 commit comments

Comments
 (0)