Commit Graph

4555 Commits

Author SHA1 Message Date
Bharat Mediratta
8d15e5cb2e Follow-in to cff1e76e8d for #1978
Restrict which album cover ids we swap over to the hierarchy of the
current album, otherwise we can wind up in sticky situations with
hierarchical album cover chains.

Eg, you have a hierarchy like this:

root -> A1 -> A2 --> A3 -> P1
                     A4 -> P2

P1 is the album cover for its entire hierarchy.  But then you
swap A2's album cover for A3 making this:

root -> A1 -> A2 +   A3 -> P1
                 \-> A4 -> P2

Since A1, A2 and A3 all had P1 as their album cover item id.  Now
we're swapping it over to P2 but we want to leave P1 as A3's album
cover item id.  So only look at A4's hierarchy and ignore its peers.
2013-01-30 21:42:47 -05:00
Bharat Mediratta
71cf911649 Support additional where tuples in ORM_MPTT::parents. Fixes #1980. 2013-01-30 21:38:32 -05:00
Bharat Mediratta
075b95f0ed Actually disable the "make album cover" option when the item is already the album cover. Fixes #1979. 2013-01-30 21:18:26 -05:00
Bharat Mediratta
cff1e76e8d When changing the album cover, find and retarget any other albums which were using the old item as their album cover. Fixes #1978. 2013-01-30 21:08:36 -05:00
Bharat Mediratta
d8d01e0aa0 Merge pull request #112 from shadlaws/fix_1968
#1968 - Improve album cover generation/removal/etc.
2013-01-30 17:17:06 -08:00
Bharat Mediratta
49dd0994df Follow-on to 1e4d75c120 for #1975.
Create a siblings() function which pulls together the siblings_callback
function and makes it a more palatable API.
2013-01-30 19:32:35 -05:00
Bharat Mediratta
9ef891858c Protect admins from themselves - in case an admin changed the
watermark.name setting to something terrible by accident via Admin >
Advanced, we'll just use the basename.  Fixes #1977.
2013-01-30 18:45:49 -05:00
Bharat Mediratta
92c264033a Don't concatenate tainted strings in JS. Fixes #1976. 2013-01-30 14:19:44 -05:00
Bharat Mediratta
1e4d75c120 Improve the display context API to return a "siblings_callback" field
containing a callback that returns all the siblings.  Fixes #1975.
2013-01-30 12:10:18 -05:00
Bharat Mediratta
6e609c249a Merge pull request #110 from mikeage/g2_import
#1973 Handle redirected G2 URLs for tags, including g2_itemId passed
2013-01-30 07:53:56 -08:00
Mike Miller
91acf812a1 #1973 Handle redirected G2 URLs for tags, including g2_itemId passed 2013-01-30 05:59:08 +02:00
shadlaws
cf07742595 #1968 - Improve album cover generation/removal/etc.
- Added stanza to Item_Model::save that handles when cover id is null.
- Added logic to graphics::generate to copy/convert album cover thumbs from their item thumbs to ensure they're always jpg, and eliminate the possibility that we copy/convert a dirty thumb.
- Redirected other places in code where we want to do one of the above two things to use these two functions instead (gallery_event::item_updated_data_file, item::make_album_cover, item::remove_album_cover).
- Improved validation in Item_Model so only albums can have covers and all covers must be non-albums.
- Added unit tests to Graphics_Helper_Test.
2013-01-30 01:07:36 +01:00
Bharat Mediratta
ed7e2d5089 Merge pull request #108 from shadlaws/fix_1970
#1970 - Make add watermarks more secure and add unit tests.
2013-01-29 10:29:25 -08:00
shadlaws
4cf31d8850 #1970 - Make add watermarks more secure and add unit tests.
This follows #1855 and #1951...
- Ensured that invalid or illegal files are not added even if they have valid extensions.
- Added unit tests (currently there aren't any...)
2013-01-29 18:48:39 +01:00
shadlaws
536bdaa4db #1967 - Improve how graphics::generate handles missing/bad images.
- Made missing_photo match the image format (jpg, png, etc.).
- Swapped missing_photo.png for missing_photo.jpg since it's likely to require less conversion to match.
- Improved error messages to user when things go wrong.
- Ensured that missing image placeholders are always copied when there's an error.
- Ensured we don't mistake no file output for a correct file output (delete target before attempt).
- Restructured graphics::generate a bit to work better with above changes.
- Added unit tests for graphics::generate.
2013-01-29 18:35:10 +01:00
Bharat Mediratta
2551b31b8f Merge pull request #106 from shadlaws/fix_1945
#1945 - Extend legal_file helper functions.
2013-01-29 09:10:06 -08:00
Bharat Mediratta
3b0de7791b Merge pull request #107 from shadlaws/fix_1969
#1969 - Give graphics events the ability to override the standard process
2013-01-29 09:01:31 -08:00
shadlaws
5fca371a61 #1945 - Extend legal_file helper functions.
- Added get_types_by_extension function, which is a merged version of get...types_by_extension functions (similar to get_extensions).
- Added optional extension argument to get...extensions functions similar to get...types_by_extension functions.
- Added unit tests.  Now, every legal_file function has one.
- Restructured helper file to include caches.
- Added array_unique to get...types (derived from get...types_by_extension, which can be many-to-one).
- Edited server_add, uploader, and item model to use new functionality.
2013-01-28 23:31:18 +01:00
shadlaws
1313a02bf4 #1971 - Make resequence_child_weights_test unit test more reliable.
- Set the sort_column of the parent album to id, which has no possibility of being identical between the two photos.
- Now, the reweighting will reverse the order even if they were created during the same second.
2013-01-28 14:47:26 +01:00
shadlaws
9e20a30d22 #1969 - Give graphics events the ability to override the standard process.
While graphics_rotate, graphics_resize, and graphics_composite events already exist, they don't have the ability to *override* the standard process.
This makes it a bit tricky when you want to replace the standard procedure with another (e.g. use jpegtran to perform lossless jpg rotation).
Solution:
- make a temp filename.
- tell the events to use it as the output file.
- if an event makes something, use it and skip the standard process.
2013-01-27 21:55:24 +01:00
Bharat Mediratta
e957c97c94 Add a key on relative_path_cache in the items table to improve performance on installs
that use File_Proxy heavily.  Fixes #1920.
2013-01-27 15:35:42 -05:00
Bharat Mediratta
b06c0f4890 Merge pull request #104 from shadlaws/fix_1966
#1966 - "Fix your Gallery" shows 60/59 items completed.
2013-01-26 11:00:56 -08:00
shadlaws
603db40459 #1966 - "Fix your Gallery" shows 60/59 items completed.
- Fixed counter in gallery_task::fix that was often one too many.

For FIX_STATE_RUN_MISSING_ACCESS_CACHES, changed this:
$stack = explode(" ", $task->get("stack"));
To this:
$stack = array_filter(explode(" ", $task->get("stack")));
2013-01-26 09:08:03 +01:00
shadlaws
cc2aed656c #1946, 1947 - Make altered names/slugs more user-friendly, make conflict-finding code check filenames with no extensions
- Reduced from four places that alter names/slugs to two (one to populate empty slugs, one to handle conflicting names/slugs).
- For empty slugs, fill with generic human-readable name (e.g. "photo") instead of random value.
- For conflicting names/slugs, add suffix that's sequential (e.g. "-01"), only using random after 99 conflicts.
- Made conflict-finding code check filenames with no extensions.
- Renamed _randomize_name_or_slug_on_conflict to _check_and_fix_conflicts.
- Added unit tests.  Also cleaned up existing unit tests to reflect new logic and removed a redundant test.
- Added installer logic to correct existing items now considered in conflict.
- Revised gallery_task to look for duplicate names based on new criteria.
2013-01-26 08:38:31 +01:00
Bharat Mediratta
96f4a5ea85 Merge pull request #103 from shadlaws/fix_1965
#1965 - Improve sanity checks and copy/convert/process logic for rotate and resize
2013-01-25 15:26:27 -08:00
shadlaws
212944e1ea #1951 - Make metadata generation more flexible (photo and movie helpers).
- added photo_get_file_metadata and movie_get_file_metadata events
- modified photo::get_file_metadata and movie::get_file_metadata to use them
- ensure that non-readable files throw exceptions
- redirected other photo metadata calls in core to photo::get_file_metadata (the helper function already exists, but in many places getimagesize is still called directly)
- added some unit tests (neither of the functions above had one)
2013-01-26 00:04:55 +01:00
shadlaws
c2d1c2407f #1965 - Improve sanity checks and copy/convert/process logic for rotate and resize.
- resize: ensured that resize is skipped *only* if the metadata is valid or the options are well-defined and would upscale. Then, if resize is skipped, check to see if it still needs to be converted. Previous conditions would allow a small PNG to get copied to a JPG, and would allow a corrupted JPG to be copied to the output.
- rotate: add checks for empty file or empty options.
- use get_file_metadata instead of direct getimagesize call.
- add unit tests for rotate and resize, including some for corrupted input files and missing options.
2013-01-25 23:47:08 +01:00
Bharat Mediratta
21a4341014 Fix an assignment-instead-of-comparison bug. I wish PHP had a better
warning system for this stuff.  In this case it's innocuous because
the UI only allows you to rearrange stuff inside a single album, so
the assignment doesn't do anything.  Fixes #1914.
2013-01-25 15:49:04 -05:00
shadlaws
48bd19808c #1956 - Escape LIKE queries (for _ and %).
In MySQL queries, _ and % characters are treated as wildcards (similar to ? and *, respectively).
- Added escape_for_like function to MY_Database.php
- Added unit test to Database_Test
- Corrected the five unescaped instances in the code using this function.
2013-01-25 08:47:29 +01:00
Bharat Mediratta
e8b7e155d5 Follow-on to b507681427 - add a default
value for lock_timeout so that folks who get the latest code but don't
run the upgrader don't get burned by a SQL error.
2013-01-24 23:48:07 -05:00
Bharat Mediratta
0353578630 Merge branch 'master' of github.com:gallery/gallery3 2013-01-24 18:14:28 -05:00
Bharat Mediratta
86a2759062 If profiling is enabled, dump out profiling data instead of proxied
images so that we can see how efficient our proxying is.  Follow-on
for #1959.
2013-01-24 18:14:14 -05:00
Bharat Mediratta
727a595447 Add back a comment that I accidentally removed in the last commit. 2013-01-24 18:13:26 -05:00
Bharat Mediratta
6830ac4542 Merge pull request #99 from shadlaws/fix_1955
#1955 - Make unit test photos unique.
2013-01-24 12:46:26 -08:00
shadlaws
126727b4f2 #1955 - Make unit test photos unique.
- Added test::random_unique_photo and test::random_unique_photo_unsaved to uniquify test photos.
- Uniquified the black dot of test.jpg by coloring it with the six-digit hex code already used to name the random photos (e.g. "name_a48801.jpg").
- Modified four tests in Item_Model_Test that check photo file contents to use new functions to guarantee uniqueness.
2013-01-24 15:56:13 +01:00
shadlaws
031dd3bd6f #1960 - Add unit test to look for extra spaces at end of line
- Added no_extra_spaces_at_end_of_line_test to File_Structure_Test.
- Updated Gallery_Filters to exclude testing code that isn't ours.
- Removed existing extra spaces.  New test now passes.
2013-01-24 12:03:05 +01:00
Bharat Mediratta
aa8fffcd8f Extract reweighting logic out of Organize_Controller into
item::reweight_all_children as an API and write a test for it.  Work
in progress on #1914.
2013-01-23 21:33:19 -05:00
Bharat Mediratta
34198e71d3 Add a cache buster to all data_rest urls, add caching headers to all
data_rest responses, and check cache validity.  Fixes #1909.
2013-01-23 20:50:54 -05:00
Bharat Mediratta
cc926cb9e1 After finding a test in Item_Model_Test that didn't end in the string "_test" and
fixing it in 9ba9f39531 I decided to write a test to make
sure that we don't have any other overlooked tests.  We don't.
2013-01-23 18:58:37 -05:00
Bharat Mediratta
bc5dbd812a Fix comment typo. 2013-01-23 18:56:30 -05:00
Bharat Mediratta
e6783b7aa7 Update golden files after 80d6a895ed 2013-01-23 18:28:28 -05:00
Bharat Mediratta
9ba9f39531 Add a "can_add" permission bit similar to the "can_edit" bit to the RESTful array
representation of Item_Model.  Fixes #1903.
2013-01-23 18:24:31 -05:00
Bharat Mediratta
1d700bf665 Merge branch 'master' of github.com:gallery/gallery3 2013-01-23 18:06:50 -05:00
Bharat Mediratta
a1a6600457 Enable the profiler and debug output if var/PROFILE exists. This
provides a quick/easy way for server admins to provide profile output.
Fixes #1959.
2013-01-23 18:03:09 -05:00
Bharat Mediratta
937102e888 Merge pull request #97 from mikeage/organize_tag2
Add batch tagging via the organize module
2013-01-23 14:07:59 -08:00
Mike Miller
80d6a895ed #1952 Add bulk tagging to the Organize module.
Allow a user to highlight one or more items (images, videos, or albums), and enter a tag (or tags, comma delimited) and apply it to all of the selected items. The code is based on the batchtag module.

If the tags module is not enabled, no changes to the Organize UI will be shown.
2013-01-23 22:58:45 +02:00
Bharat Mediratta
eefc9d5553 Use the thumb proportion from the first item in an album if the album has children. Fixes #1958. 2013-01-23 14:03:44 -05:00
Bharat Mediratta
e8302ffce5 Merge pull request #98 from shadlaws/fix_1954
#1954 - Skip buffer calls for unit tests of file_proxy and data_rest.
2013-01-22 17:57:58 -08:00
Bharat Mediratta
49f6ce2d94 gallery.menalto.com -> galleryproject.org
codex.gallery2.org -> codex.galleryproject.org

Fixes #1957.
2013-01-22 18:39:24 -05:00
shadlaws
8436e16b2f #1954 - Skip buffer calls for unit tests of file_proxy and data_rest.
Moved the "if (TEST_MODE)" statement before the buffer calls in file_proxy and data_rest.
This has no impact on normal use, but will make the unit tests more compatible with different server/PHP configurations.
Note: We do not have to skip setting the headers, which means we can build unit tests around them if we wish.
2013-01-21 10:45:34 +01:00