Completed
Push — master ( bc0916...92f140 )
by cam
04:43
created

v31.php ➔ ranger_cache_gd2()   B

Complexity

Conditions 9
Paths 7

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
nc 7
nop 0
dl 0
loc 21
rs 8.0555
c 0
b 0
f 0
1
<?php
2
3
/***************************************************************************\
4
 *  SPIP, Système de publication pour l'internet                           *
5
 *                                                                         *
6
 *  Copyright © avec tendresse depuis 2001                                 *
7
 *  Arnaud Martin, Antoine Pitrou, Philippe Rivière, Emmanuel Saint-James  *
8
 *                                                                         *
9
 *  Ce programme est un logiciel libre distribué sous licence GNU/GPL.     *
10
 *  Pour plus de détails voir le fichier COPYING.txt ou l'aide en ligne.   *
11
\***************************************************************************/
12
13
/**
14
 * Gestion des mises à jour de bdd de SPIP
15
 * 
16
 * Mises à jour en 3.1
17
 *
18
 * @package SPIP\Core\SQL\Upgrade
19
 **/
20
if (!defined('_ECRIRE_INC_VERSION')) {
21
	return;
22
}
23
24
25
$GLOBALS['maj'][21676] = array(
26
	array('ranger_cache_gd2'),
27
);
28
29
/**
30
 * Ranger les images de local/cache-gd2 dans des sous-rep
31
 *
32
 * https://core.spip.net/issues/3277
33
 */
34
function ranger_cache_gd2() {
35
	spip_log("ranger_cache_gd2");
36
	$base = _DIR_VAR . "cache-gd2/";
37
	if (is_dir($base) and is_readable($base)) {
38
		if ($dir = opendir($base)) {
39
			while (($f = readdir($dir)) !== false) {
40
				if (!is_dir($base . $f) and strncmp($f, ".", 1) !== 0
41
					and preg_match(",[0-9a-f]{32}\.\w+,", $f)
42
				) {
43
					$sub = substr($f, 0, 2);
44
					$sub = sous_repertoire($base, $sub);
45
					@rename($base . $f, $sub . substr($f, 2));
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
46
					@unlink($base . $f); // au cas ou le rename a foire (collision)
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
47
				}
48
				if (time() >= _TIME_OUT) {
49
					return;
50
				}
51
			}
52
		}
53
	}
54
}
55
56
57
$GLOBALS['maj'][21742] = array(
58
	array('sql_alter', "TABLE spip_articles CHANGE url_site url_site text DEFAULT '' NOT NULL"),
59
	array('sql_alter', "TABLE spip_articles CHANGE virtuel virtuel text DEFAULT '' NOT NULL"),
60
);
61