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

Install drush with composer #714

Merged
merged 12 commits into from
Feb 12, 2019
Merged

Install drush with composer #714

merged 12 commits into from
Feb 12, 2019

Conversation

whikloj
Copy link
Member

@whikloj whikloj commented Jan 26, 2019

JIRA Ticket: n/a

Discussed at the January 24, 2019 committer's call.

What does this Pull Request do?

Due to PEAR issues, this PR installs drush using composer. It also installs coder and PHP Codesniffer this way.

For PHP 5.3.3 it installs:

  1. Drush 6.*
  2. Coder 7.*

For all newer PHP version it installs:

  1. Drush 7.*
  2. Latest Coder version

Finally it updates the travis_scripts.sh to ensure appropriate response in the case that the final test (phpcpd) passes but previous have failed.

What's new?

There are 2 commits here.

The first commit contains the setup changes.

The second commit contains all the code updates to account for the new coder sniffs.

How should this be tested?

Travis should pass.

Additional Notes:

There are two things of concern in the DublinCore class.

d0d9d16#diff-e8e5de937161791c32db421e1faec58c

These were required by the sniffer, but I am wondering if they will cause failure to others using these functions?

I'm not sure if PHP is case sensitive for function names, but my IDE warned my about adding in the old function names to pass along with deprecation notices.

If they are case-sensitive, perhaps nothing needs to be done. If they aren't case-sensitive we could ignore these functions for the code sniffer. 🤷‍♂️

  • Does this change the interface, add a new feature, or otherwise change behaviours that would require updating documentation? no
  • Does this change add any new dependencies? no
  • Does this change require any other modifications to be made to the repository (ie. Regeneration activity, etc.)? no
  • Could this change impact execution of existing code? possibly (see DublinCore discussion)

Interested parties

@Islandora/7-x-1-x-committers specifically @dannylamb, @jonathangreen and @adam-vessey

Install drush with composer

Split out phpcs

Try to get 5.3.3 working

Clean up symlinks

Use older drush for 5.3.3

Fix script
callable is really a string

Fix tests
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.

Ok, this sounds weird. The code is good, but there are implications here we need to deal as a community. Can we ask TAG to go through the functions that got their signatures bumped to actual type casted arguments and make sure calls match from other modules? A spreadsheet with links to its use in the code base could do wonders (grep-ing). I added some comments in the code. I feel we can not merge this until we decide how much of the code (like every islandora module) are we going to touch?

@@ -152,7 +152,7 @@ class DublinCore {
* @return DublinCore
* The instantiated object.
*/
public static function importFromXMLString($dc_xml) {
public static function importFromXmlString($dc_xml) {

Choose a reason for hiding this comment

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

This change affects (nominally because php is case insensitive for functions/methods http://fr.php.net/manual/en/functions.user-defined.php). I tracked this use to almost every SP that we have. (webarchive, large image, pdf, you name it)

@@ -899,7 +902,7 @@ function islandora_ingest_form_get_object(array &$form_state) {
*
* @param array $form_state
* The Drupal form state.
* @param array $step_id
* @param string $step_id

Choose a reason for hiding this comment

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

WOHO! good catch

includes/metadata.inc Outdated Show resolved Hide resolved
@jonathangreen
Copy link

I'm wondering what the implications of using 2 different code sniffer versions are here? Is it possible we will get into a case where one code sniffer says one thing, and the other code sniffer says something else or is it all using the same sniffs?

@whikloj
Copy link
Member Author

whikloj commented Jan 29, 2019

@DiegoPino am I correct that you would like TAG to go through all the code and look for any occurrence of the methods changed here? That seems a little outside the mandate of TAG, though I guess we can throw the decision on whether we should do that to them. But I think the work will need to be distributed. Also as this will probably have the effect of revealing alot of new coder violations each module will need some clean up.

@DiegoPino
Copy link

@whikloj i like TAG to do whatever TAG is in charge of (organizing this, saying yes it needs to be done or even finding a workflow that allows us to keep getting contributions) . That way it is a community/foundation effort and we do have agreement. TAG is the only instance out of the committers calls that have that attribution/tech role. I was (i hope so) not implying you all doing the work. As you correctly stated this will reveal a lot of mess in our code, specially in our use of PHPdocs and variable naming and to be honest it needs to happen all in a pretty close period of time. And the function argument thing could even expose bugs(fatalist). Could be a release task for the upcoming one or a sprint, i just know this can't come from the same 5 suspects (you are one of them) that normally do all the heavy work (and we all are grateful). Also, could someone add a @islandora/tag group so we can talk to TAG as an individual here? Merci

@whikloj
Copy link
Member Author

whikloj commented Jan 29, 2019

@jonathangreen That is a good question, I had to go with the different version of coder as PHP 5.3.3 needed an older version of PHP_codesniffer which couldn't support the (IDK "format" 🤷‍♂️ ) of the newer sniffs. I did have one situation where this appeared here where one wanted a space around the unary operator and the other...wanted something else. So I modified the code as I found this more readable anyways.

@dannylamb
Copy link

@DiegoPino I'm not a fan of that function rename either (case insensitivity in function names seems like a terrible idea in the first place), but this will sort itself out over time as we push up compliant code. By next release it's a given that phpcbf will have taken care of it.

I'm more worried about @jonathangreen's concern, because I'm sure drift is inevitable. But if we want to support 5.3 then we gotta live with the two versions. Just another tally mark against 5.3 at this stage in the game.

But are we ok to move ahead with this one? 7.x is pretty much at a standstill until this gets resolved 😢

@DiegoPino DiegoPino dismissed their stale review January 29, 2019 21:02

Tech lead says we will deal with lower/upper case and code sniffer interpretation of the drupal coding standards on a pull by pull basis. So my concerns are gone. I don't feel super prepared to do a full review here, could i get a second pair of eyes?

@DiegoPino
Copy link

@whikloj @jonathangreen @dannylamb ok, i dismissed my review. Seems like there is consensus on fixing this in every repo as we go?.I did not see any TAG interaction so i will assume this is it. Can do a full code review tomorrow but if someone has some better skilled eyes and can do it sooner feel free to open the gates and give it a green light. Thanks!

Copy link

@jonathangreen jonathangreen left a comment

Choose a reason for hiding this comment

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

Made a few comments as I read though the PR.

tests/scripts/travis_scripts.sh Show resolved Hide resolved
tests/scripts/travis_scripts.sh Outdated Show resolved Hide resolved
tests/scripts/travis_setup.sh Show resolved Hide resolved
tests/scripts/travis_setup.sh Show resolved Hide resolved
@jonathangreen
Copy link

jonathangreen commented Jan 30, 2019

So we don't have old versions of PHPCS sniffs conflicting with new versions, I would like to propose that we don't bother with PHPCS on PHP 5.3. We can still run the tests, just not run code sniffer.

Thanks for all the hard work on this @whikloj.

@DiegoPino
Copy link

DiegoPino commented Jan 30, 2019 via email

@dannylamb
Copy link

I concur. It's better in the long run to just jettison the 5.3 sniffs now.

@whikloj
Copy link
Member Author

whikloj commented Jan 30, 2019

Ok just to be clear we don't want to run phpcs for PHP 5.3.3?

@whikloj
Copy link
Member Author

whikloj commented Jan 30, 2019

Also should I make PHP 5.3.3 try to install the latest version of coder too?

@DiegoPino
Copy link

What is coder used for (in our setup) other than providing the DCS? If just that and we are not doing sniffing then maybe not needed?

@whikloj
Copy link
Member Author

whikloj commented Jan 30, 2019

@DiegoPino it does these checks, previously it also ran the code sniffs.
https://github.com/Islandora/islandora/pull/714/files#diff-3dc9561b09fd3ea9fd5f0921c5a99dd4R22

@adam-vessey
Copy link

adam-vessey commented Feb 7, 2019

@whikloj @jonathangreen: I suspect there may be issues with the object access callbacks as well; for example:

Could end up with PHP errors popping up when attempting to access non-existent objects? Not sure of actual behaviour, but HTTP 500 kind of things instead of the expected 400s, possibly?

@jonathangreen
Copy link

I tested on my site going to a non-existent object with this code, and I do properly receive a 401.

I also tested putting a policy on an object to restrict it to a user, then accessing it as anonymous, in that case I get:

TypeError: Argument 2 passed to islandora_object_access_callback() must be an instance of AbstractObject, string given, called in /var/www/drupal/includes/menu.inc on line 648 in islandora_object_access_callback() (line 876 of /var/www/drupal/sites/all/modules/islandora/islandora/islandora.module).

@whikloj
Copy link
Member Author

whikloj commented Feb 7, 2019

That seems to be a bug or this existing documentation for that function was disregarded at some point.
https://github.com/Islandora/islandora/blob/7.x/islandora.module#L867-L869

@jonathangreen
Copy link

Digging deep here, its been a long while, but we use Auto-Loader Wildcards in the hook_menu calls to load the object with object_load. If the object can be loaded then the Drupal menu system passes around a tuque object, if it can't be loaded then the string get passed to the functions called by the menu system. I think that is what is happening here. So the documentation is wrong... but its probably been wrong since basically forever. 😥

@whikloj
Copy link
Member Author

whikloj commented Feb 8, 2019

So I was not getting the same FITS problem in my test vagrant. I tried to remove the TECHMD datastream and still the object seemed okay. I must have been missing something.

So I removed the hint and @param documentation from the two previously discussed functions. If you want to try it again.

We do need to maintain some standards as this is an OSS community, but I'm not sure how much we can expect. Maybe this is good enough and we worry about doing better in Islandora 8?

Copy link

@jonathangreen jonathangreen left a comment

Choose a reason for hiding this comment

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

I totally agree, we do need to maintain some sort of standards here, but we do have to try not to break things as well. It's a tough line to walk.

islandora.module Outdated Show resolved Hide resolved
@whikloj
Copy link
Member Author

whikloj commented Feb 8, 2019

Rather than delete the documentation (as I did in this commit) I'm trying to just expand it, so I re-added the docs and (hopefully) corrected them.

Let me know if you hit any others, we don't embargo anything so that is one I never think of.

Copy link

@jonathangreen jonathangreen left a comment

Choose a reason for hiding this comment

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

This is a big commit to core, and its changes (especially the type hints) may still break things, in custom modules or other modules. However I think its important to keep it moving along, as it also is important to get travis fixed in our codebase, and it doesn't seem like pear is coming back anytime soon. I also think its great work on @whikloj part to take on fixing travis and modernize the code-sniffer tool chain we are using.

This addresses my concerns and works on my test site, so I'm going to approve it and start the 24 hour clock 🕐 for merging. Since it's a Friday, I'd like to wait until Tuesday to merge, assuming there are no more comments. If any @Islandora/7-x-1-x-committers are interested, I would encourage them to take a look and give it a test in their environment.

@jonathangreen jonathangreen merged commit a46936c into Islandora:7.x Feb 12, 2019
@jonathangreen
Copy link

Rock out

@DonRichards
Copy link
Member

@whikloj @jonathangreen
I believe this is causing the TN regenerate function to fail. I tested basic image and large image with the same result.
TN Regenerate

@jonathangreen
Copy link

@DonRichards if you want to submit a fix PR with testing instructions I will review and merge.

@DonRichards
Copy link
Member

Created a ticket. I'll look at what changed and see if I can identify the point failure (missing var in function call). https://jira.duraspace.org/browse/ISLANDORA-2387

@DonRichards
Copy link
Member

And just like that, it started working. Not sure what changed. I assume my vm didn't pull in the changes from other solution packs that were related. Looks fine now. Sorry for that.

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.

6 participants