Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Islandora 2136 #95

Open
wants to merge 4 commits into
base: 7.x
Choose a base branch
from
Open

Islandora 2136 #95

wants to merge 4 commits into from

Conversation

robyj
Copy link

@robyj robyj commented Oct 19, 2018

JIRA Ticket: https://jira.duraspace.org/browse/ISLANDORA-2136

  • Other Relevant Links (Google Groups discussion, related pull requests, Release pull requests, etc.)

What does this Pull Request do?

This pull request adds default values to the book and newspaper variable_get() alls in the install script

What's new?

I pulled the default values from the book and newspaper modules, modified them slightly as the lines after the variable_get calls modify the values anyway

How should this be tested?

A description of what steps someone could take to:
Test by having a system with OCR enabled and book/newspaper modules disabled/missing?

Additional Notes:

Its shouldn't change how the software operates and not sure documentation changes are needed

Interested parties

Tag (@ mention) interested parties or, if unsure, @Islandora/7-x-1-x-committers

- Added default values at the two locations, using values from the book & newspaper modules

Resolves: https://jira.duraspace.org/browse/ISLANDORA-2136
- Added default values at the two locations, using default values from the book & newspaper modules

Resolves: https://jira.duraspace.org/browse/ISLANDORA-2136
@bondjimbond
Copy link

Thanks for these new contributions, @robyj. Can you please fill out the PR template (which is now the opening comment on this pull)? It's an important piece for reviewers so that we know what we're looking at and how to test.

@robyj
Copy link
Author

robyj commented Oct 19, 2018

Comment block at the start of this ticket has been modified. Sorry, wasn't sure how things are done for the project.

$book['ocr'] = FALSE;
variable_set('islandora_book_ingest_derivatives', $book);
}

if (module_exists('islandora_newspaper')) {
$newspaper = variable_get('islandora_newspaper_ingest_derivatives');
$newspaper = variable_get('islandora_newspaper_ingest_derivatives', array('ocr' => FALSE));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robyj Based on the above change and the default from the newspaper solution pack's admin page I think you should just do that same as above and set

array (
  'pdf' => 'pdf',
  'image' => 'image',
  'ocr' => FALSE
)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

- modified the default values for the newspaper array to be the same
as the book array, as per @whikloj's comment
@whikloj
Copy link
Member

whikloj commented Oct 19, 2018

FYI @robyj and I both work at the U of Manitoba, so I won't be merging this to avoid any conflicts of interest.

Copy link

@DiegoPino DiegoPino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some concerns, not a blocker but something to think about...

$book = variable_get('islandora_book_ingest_derivatives', array(
'pdf' => 'pdf',
'image' => 'image',
'ocr' => FALSE));
$book['ocr'] = FALSE;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is ocr being defaulted to FALSE and then set to FALSE again?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, checked code and I know why! but, as my
#95 (comment) says this should be defaulted to array('ocr') to make sure code is more portable.

$newspaper = variable_get('islandora_newspaper_ingest_derivatives', array(
'pdf' => 'pdf',
'image' => 'image',
'ocr' => FALSE));
$newspaper['ocr'] = FALSE;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also happens here. Now I wonder if the issue is different. Do we have something in islandora_newspaper or 'islandora_book' that helps us set those defaults, quick look tells me this is hardcoded in some form options? What if someone changes those defaults or allows a new one?. Will we ever remember we need to change them here too? So if this piece of code only cares about ocr, would it be not better to default to variable_get('islandora_newspaper_ingest_derivatives', array('ocr')) ? Seems safer... thoughts @Islandora/7-x-1-x-committers

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robyj sorry this seem to conflict with @whikloj review 😭 . Weird enough we do default to array(ocr) in at least some other place... Islandora lacks of consistency sometimes... anyway. Mine are just comments.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I pulled that default value of just array('ocr') from what seemed to be another place it was being set by default. I'd just like it to be correct.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robyj totally. I get it!, I also saw it as only array('ocr') somewhere else (zip importer for newspapers?). The issue is, defaulting here makes almost little sense. Defaulting makes sense when load of variable needs to be consistent with the whole expectation and the logic that comes after. In this case you only want to set ocr to false if the variable is set at all right? So i dare to question, why to even save in case the variable was not set? @whikloj thoughts? In any case nothing here is life or dead, but still this needs to A) respect what was set, B) reset the OCR to false C) if nothing was there, better leave it like that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those settings of array('pdf' => 'pdf', 'image' => 'image', 'ocr' => FALSE) are just defaults, if the user has ever set their own options that array would be returned instead.

However in this case because we are unsure if we are getting the default or the users setting we have to do the $newspaper['ocr'] = FALSE; a second time.

If that makes this too confusing then perhaps just doing a drupal_map_assoc(array('ocr', 'image', 'pdf')) would be better.

That would match how the default is set in the newspaper solution pack. https://github.com/Islandora/islandora_solution_pack_newspaper/blob/7.x/includes/admin.form.inc#L36-L37

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have said that we would then still explicitly set the $newspaper['ocr'] = FALSE;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I pulled that default value of just array('ocr') from what seemed to be another place it was being set by default. I'd just like it to be correct.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DiegoPino you're thinking something like this?

$newspaper = variable_get('islandora_newspaper_ingest_derivatives', array());
if (isset($newspaper['ocr'])) {
  $newspaper['ocr'] = FALSE;
  variable_set('islandora_newspaper_ingest_derivatives, $newspaper);
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there any more work for me to do for this?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. This gone slipped under my radar (radar is off-line, forgot to pay the bill)

$newspaper = variable_get('islandora_newspaper_ingest_derivatives', array(
'pdf' => 'pdf',
'image' => 'image',
'ocr' => FALSE));
$newspaper['ocr'] = FALSE;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just needs the second 'false' to be removed, right? for newspaper and ocr? @whikloj that was your comment right?

@whikloj
Copy link
Member

whikloj commented Feb 21, 2020

@DiegoPino this is an old one, but wondering if you've had a chance to review it again?

@DiegoPino
Copy link

@whikloj gosh. time travel. Yes. Ok, trying to catch up with the review.

I feel what you said here is right

$newspaper = variable_get('islandora_newspaper_ingest_derivatives', array());
if (isset($newspaper['ocr'])) {
$newspaper['ocr'] = FALSE;
variable_set('islandora_newspaper_ingest_derivatives, $newspaper);
} That seems to be exactly the best approach.

But that said, i'm also OK with the code as it is (me older == me more tolerant) The fact is it just sets it to false if no ocr module enable. Good enough You got my 👍 for a merge

Sorry @robyj, its me Diego, saying all is good, from the past.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants