Skip to content

Conversation

@hektech
Copy link

@hektech hektech commented May 18, 2017

We are in the process of adopting Archon at Hekman Library, Calvin College. After getting it up an running on a PHP 5.6 test server, we then ran into some compatibility issues with PHP 7 on our production server.

The contents of this pullrequest got us to a working state. There may be more changes lurking in areas of the code we haven't exercised (similar to the small tag fix in the EAD export, included here), but we are now able to browse, search, and do DB imports successfully on our production server.

See the commit comments for much more detail on these changes, and why they are needed.

hektech added 3 commits May 18, 2017 16:39
Archon's object composition technique makes heavy use of a PHP
feature allowing method calls from an incompatible context. However,
this ability was deprecated in PHP 5.6 and removed from PHP 7.0 [1].

Ultimately, it seems like moving over to Traits may be a logical path
forward.  This patch instead attempts to allow current Archon to run
on PHP 7+ with the fewest changes possible.

Rather than simply attempt the method call in the wrong context, we
instead create a closure in the desired class, then insert our current
context into that closure using bindTo.

There may, of course, be a simpler way to do this.  In particular, it
seems messy to need to create an object only to get the closure.  I
do not claim to be an expert in PHP internals, but this functions, and
is decently boiled down.

This new technique should be supported for PHP >= 5.4.0, but this is
untested.  One questionable area would be the use of the getClosure
method call on a parenthesized "new" object statement.  I believe it is
supported syntax on at least 5.6, and would be very easy to work around
in any case.  That said, it may be better to retain the old technique
and branch within the code to suit the running version.

[1] http://php.net/manual/en/migration56.deprecated.php#migration56.deprecated.incompatible-context

Signed-off-by: Dan Wells <dbw2@calvin.edu>
$OutputQueries is not static, so we need $this here.  Older versions
of PHP (<7.0) were more lax about this, particular the way we were
mixing contexts.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
PHP no longer supports "<?" as an opening tag; make it read "<?php"
instead.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
@chrisprom
Copy link

chrisprom commented May 18, 2017 via email

@hektech
Copy link
Author

hektech commented May 19, 2017

Chris, thank you for the quick response. I mostly wanted to get this out there as a place to start. There are a few details regarding PHP 5.6 in the first commit message (summary: it should work), but we haven't been able to test it yet. I'll try to find time to do so in the next day or two and report back.

@chrisprom
Copy link

chrisprom commented May 19, 2017 via email

@hektech
Copy link
Author

hektech commented May 19, 2017

Chris, thanks again for the feedback. I am not terribly familiar with which branches/forks are active, and how the project is moving. Based on what you said, does it make sense to now open a pullrequest for this on archonproject/archon instead? And is that the main repo to track for following this project in the future?

@hektech
Copy link
Author

hektech commented Jun 7, 2017

Closing in favor of archonproject#82

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.

2 participants