diff options
Diffstat (limited to 'engine')
-rw-r--r-- | engine/lib/annotations.php | 14 | ||||
-rw-r--r-- | engine/lib/database.php | 1 | ||||
-rw-r--r-- | engine/lib/filestore.php | 10 | ||||
-rw-r--r-- | engine/lib/group.php | 16 | ||||
-rw-r--r-- | engine/lib/metadata.php | 2 | ||||
-rw-r--r-- | engine/lib/plugins.php | 11 | ||||
-rw-r--r-- | engine/lib/relationships.php | 2 | ||||
-rw-r--r-- | engine/lib/tags.php | 2 | ||||
-rw-r--r-- | engine/tests/regression/trac_bugs.php | 51 |
9 files changed, 76 insertions, 33 deletions
diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php index 0bb29c408..c960da014 100644 --- a/engine/lib/annotations.php +++ b/engine/lib/annotations.php @@ -18,7 +18,8 @@ require_once('extender.php'); /** * ElggAnnotation * - * An annotation is similar to metadata each entity can contain more than one of each annotation. + * An annotation is similar to metadata. + * Each entity can have more than one of each type of annotation. * * @package Elgg * @subpackage Core @@ -27,7 +28,7 @@ require_once('extender.php'); class ElggAnnotation extends ElggExtender { /** - * Construct a new site object, optionally from a given id value or db row. + * Construct a new annotation, optionally from a given id value or db object. * * @param mixed $id */ @@ -87,14 +88,14 @@ class ElggAnnotation extends ElggExtender { $this->value_type, $this->owner_guid, $this->access_id); if (!$this->id) { - throw new IOException(sprintf(elgg_new('IOException:UnableToSaveNew'), get_class())); + throw new IOException(sprintf(elgg_echo('IOException:UnableToSaveNew'), get_class())); } return $this->id; } } /** - * Delete a given site. + * Delete the annotation. */ function delete() { return delete_annotation($this->id); @@ -125,7 +126,7 @@ class ElggAnnotation extends ElggExtender { * Convert a database row to a new ElggAnnotation * * @param stdClass $row - * @return stdClass or ElggAnnotation + * @return ElggAnnotation */ function row_to_elggannotation($row) { if (!($row instanceof stdClass)) { @@ -139,6 +140,7 @@ function row_to_elggannotation($row) { * Get a specific annotation. * * @param int $annotation_id + * @return ElggAnnotation */ function get_annotation($annotation_id) { global $CONFIG; @@ -158,6 +160,7 @@ function get_annotation($annotation_id) { * @param string $value_type * @param int $owner_guid * @param int $access_id + * @return int|bool id on success or false on failure */ function create_annotation($entity_guid, $name, $value, $value_type, $owner_guid, $access_id = ACCESS_PRIVATE) { global $CONFIG; @@ -220,6 +223,7 @@ function create_annotation($entity_guid, $name, $value, $value_type, $owner_guid * @param string $value_type * @param int $owner_guid * @param int $access_id + * @return bool */ function update_annotation($annotation_id, $name, $value, $value_type, $owner_guid, $access_id) { global $CONFIG; diff --git a/engine/lib/database.php b/engine/lib/database.php index 58685bb82..c8945e2d1 100644 --- a/engine/lib/database.php +++ b/engine/lib/database.php @@ -280,6 +280,7 @@ function get_data($query, $callback = "") { if (empty($resultarray)) { elgg_log("DB query \"$query\" returned no results."); + // @todo consider changing this to return empty array #1242 return false; } diff --git a/engine/lib/filestore.php b/engine/lib/filestore.php index 4e92fee21..0a30f5551 100644 --- a/engine/lib/filestore.php +++ b/engine/lib/filestore.php @@ -951,13 +951,7 @@ function get_image_resize_parameters($width, $height, $options) { } // check for upscaling - // @todo This ignores squares, coordinates, and cropping. It's probably not the best idea. - // Size checking should be done in action code, but for backward compatibility - // this duplicates the previous behavior. if (!$upscale && ($height < $new_height || $width < $new_width)) { - // zero out offsets - $widthoffset = $heightoffset = 0; - // determine if we can scale it down at all // (ie, if only one dimension is too small) // if not, just use original size. @@ -968,10 +962,9 @@ function get_image_resize_parameters($width, $height, $options) { } elseif ($width < $new_width) { $ratio = $new_height / $height; } + $selection_height = $height; $selection_width = $width; - $new_height = floor($height * $ratio); - $new_width = floor($width * $ratio); } $params = array( @@ -986,7 +979,6 @@ function get_image_resize_parameters($width, $height, $options) { return $params; } - // putting these here for now function file_delete($guid) { if ($file = get_entity($guid)) { diff --git a/engine/lib/group.php b/engine/lib/group.php index 68829dafb..474baf609 100644 --- a/engine/lib/group.php +++ b/engine/lib/group.php @@ -460,15 +460,11 @@ function remove_object_from_group($group_guid, $object_guid) { * @param unknown_type $offset Where to start, by default 0. * @param unknown_type $count Whether to return the entities or a count of them. */ -function get_objects_in_group($group_guid, $subtype = "", $owner_guid = 0, $site_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false) { - global $CONFIG; - - if ($subtype === false || $subtype === null || $subtype === 0) { - return false; +function get_objects_in_group($group_guid, $subtype = "", $owner_guid = 0, $site_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = FALSE) { + if ($subtype === FALSE || $subtype === null || $subtype === 0) { + return FALSE; } - $subtype = get_subtype_id('object', $subtype); - if ($order_by == "") { $order_by = "e.time_created desc"; } @@ -488,7 +484,11 @@ function get_objects_in_group($group_guid, $subtype = "", $owner_guid = 0, $site $where = array(); $where[] = "e.type='object'"; - if ($subtype!=="") { + + if (!empty($subtype)) { + if (!$subtype = get_subtype_id('object', $subtype)) { + return FALSE; + } $where[] = "e.subtype=$subtype"; } if ($owner_guid != "") { diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index a6843e598..a07b0958d 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -88,7 +88,7 @@ class ElggMetadata extends ElggExtender { } else { $this->id = create_metadata($this->entity_guid, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id); if (!$this->id) { - throw new IOException(sprintf(elgg_new('IOException:UnableToSaveNew'), get_class())); + throw new IOException(sprintf(elgg_echo('IOException:UnableToSaveNew'), get_class())); } return $this->id; } diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php index b8cf5c2d2..66b22a0aa 100644 --- a/engine/lib/plugins.php +++ b/engine/lib/plugins.php @@ -131,10 +131,10 @@ function get_plugin_list() { * @param array $pluginorder Optionally, a list of existing plugins and their orders * @return array The new list of plugins and their orders */ -function regenerate_plugin_list($pluginorder = false) { +function regenerate_plugin_list($pluginorder = FALSE) { global $CONFIG; - $CONFIG->pluginlistcache = null; + $CONFIG->pluginlistcache = NULL; if ($site = get_entity($CONFIG->site_guid)) { if (empty($pluginorder)) { @@ -187,15 +187,10 @@ function regenerate_plugin_list($pluginorder = false) { $site->pluginorder = $plugins; - // Regenerate caches - elgg_view_regenerate_simplecache(); - elgg_filepath_cache_reset(); - return $plugins; - } - return false; + return FALSE; } diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php index dd59b8d3f..bf55a8932 100644 --- a/engine/lib/relationships.php +++ b/engine/lib/relationships.php @@ -91,7 +91,7 @@ class ElggRelationship implements $this->id = add_entity_relationship($this->guid_one, $this->relationship, $this->guid_two); if (!$this->id) { - throw new IOException(sprintf(elgg_new('IOException:UnableToSaveNew'), get_class())); + throw new IOException(sprintf(elgg_echo('IOException:UnableToSaveNew'), get_class())); } return $this->id; diff --git a/engine/lib/tags.php b/engine/lib/tags.php index ce1fbbf93..1d2b552ad 100644 --- a/engine/lib/tags.php +++ b/engine/lib/tags.php @@ -229,7 +229,7 @@ function elgg_get_tags(array $options = array()) { $query .= get_access_sql_suffix('e'); $threshold = sanitise_int($options['threshold']); - $query .= " GROUP BY msv.string HAVING total > {$threshold} "; + $query .= " GROUP BY msv.string HAVING total >= {$threshold} "; $query .= " ORDER BY total DESC "; $limit = sanitise_int($options['limit']); diff --git a/engine/tests/regression/trac_bugs.php b/engine/tests/regression/trac_bugs.php index 01900b849..5765c9c3d 100644 --- a/engine/tests/regression/trac_bugs.php +++ b/engine/tests/regression/trac_bugs.php @@ -63,4 +63,55 @@ class ElggCoreRegressionBugsTest extends ElggCoreUnitTest { // clean up $this->entity->delete(); } + + /** + * #2063 - get_resized_image_from_existing_file() fails asked for image larger than selection and not scaling an image up + * Test get_image_resize_parameters(). + */ + public function testElggResizeImage() { + $orig_width = 100; + $orig_height = 150; + + // test against selection > max + $options = array( + 'maxwidth' => 50, + 'maxheight' => 50, + 'square' => TRUE, + 'upscale' => FALSE, + + 'x1' => 25, + 'y1' => 75, + 'x2' => 100, + 'y2' => 150 + ); + + // should get back the same x/y offset == x1, y1 and an image of 50x50 + $params = get_image_resize_parameters($orig_width, $orig_height, $options); + + $this->assertEqual($params['newwidth'], $options['maxwidth']); + $this->assertEqual($params['newheight'], $options['maxheight']); + $this->assertEqual($params['xoffset'], $options['x1']); + $this->assertEqual($params['yoffset'], $options['y1']); + + // test against selection < max + $options = array( + 'maxwidth' => 50, + 'maxheight' => 50, + 'square' => TRUE, + 'upscale' => FALSE, + + 'x1' => 75, + 'y1' => 125, + 'x2' => 100, + 'y2' => 150 + ); + + // should get back the same x/y offset == x1, y1 and an image of 50x50 + $params = get_image_resize_parameters($orig_width, $orig_height, $options); + + $this->assertEqual($params['newwidth'], $options['maxwidth']); + $this->assertEqual($params['newheight'], $options['maxheight']); + $this->assertEqual($params['xoffset'], $options['x1']); + $this->assertEqual($params['yoffset'], $options['y1']); + } } |