summaryrefslogtreecommitdiff
path: root/program/lib
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-03-24 17:30:34 +0100
committerAleksander Machniak <alec@alec.pl>2013-03-24 17:30:34 +0100
commit24e88e91f7ebac132fa356762b0cd544d42cef9f (patch)
tree3b99b6c2237fb26541a133f78405faffcddd5240 /program/lib
parenta26c031621410f030751eae404490a10498583d7 (diff)
parent7889c57b772dbf722639894bd572c767424c8b84 (diff)
Merge branch 'master' of github.com:roundcube/roundcubemail
Diffstat (limited to 'program/lib')
-rw-r--r--program/lib/Roundcube/rcube_db.php7
-rw-r--r--program/lib/Roundcube/rcube_mime.php30
2 files changed, 32 insertions, 5 deletions
diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php
index 49bbe5c6e..4e6684c51 100644
--- a/program/lib/Roundcube/rcube_db.php
+++ b/program/lib/Roundcube/rcube_db.php
@@ -444,17 +444,20 @@ class rcube_db
*
* @param mixed $result Optional query handle
* @return mixed Number of rows or false on failure
+ * @deprecated This method shows very poor performance and should be avoided.
*/
public function num_rows($result = null)
{
if ($result || ($result === null && ($result = $this->last_result))) {
// repeat query with SELECT COUNT(*) ...
- if (preg_match('/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/i', $result->queryString, $m)) {
+ if (preg_match('/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/ims', $result->queryString, $m)) {
$query = $this->dbh->query('SELECT COUNT(*) FROM ' . $m[1], PDO::FETCH_NUM);
return $query ? intval($query->fetchColumn(0)) : false;
}
else {
- return count($result->fetchAll());
+ $num = count($result->fetchAll());
+ $result->execute(); // re-execute query because there's no seek(0)
+ return $num;
}
}
diff --git a/program/lib/Roundcube/rcube_mime.php b/program/lib/Roundcube/rcube_mime.php
index b70d681c9..7cd520752 100644
--- a/program/lib/Roundcube/rcube_mime.php
+++ b/program/lib/Roundcube/rcube_mime.php
@@ -769,11 +769,35 @@ class rcube_mime
// fallback to some well-known types most important for daily emails
if (empty($mime_types)) {
- $mime_extensions = @include(RCUBE_CONFIG_DIR . '/mimetypes.php');
- $mime_extensions += array('gif' => 'image/gif', 'png' => 'image/png', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'tif' => 'image/tiff');
+ $mime_extensions = (array) @include(RCUBE_CONFIG_DIR . '/mimetypes.php');
- foreach ($mime_extensions as $ext => $mime)
+ foreach ($mime_extensions as $ext => $mime) {
$mime_types[$mime][] = $ext;
+ }
+ }
+
+ // Add some known aliases that aren't included by some mime.types (#1488891)
+ // the order is important here so standard extensions have higher prio
+ $aliases = array(
+ 'image/gif' => array('gif'),
+ 'image/png' => array('png'),
+ 'image/x-png' => array('png'),
+ 'image/jpeg' => array('jpg', 'jpeg', 'jpe'),
+ 'image/jpg' => array('jpg', 'jpeg', 'jpe'),
+ 'image/pjpeg' => array('jpg', 'jpeg', 'jpe'),
+ 'image/tiff' => array('tif'),
+ 'message/rfc822' => array('eml'),
+ 'text/x-mail' => array('eml'),
+ );
+
+ foreach ($aliases as $mime => $exts) {
+ $mime_types[$mime] = array_unique(array_merge((array) $mime_types[$mime], $exts));
+
+ foreach ($exts as $ext) {
+ if (!isset($mime_extensions[$ext])) {
+ $mime_extensions[$ext] = $mime;
+ }
+ }
}
return $mimetype ? $mime_types[$mimetype] : $mime_extensions;