Skip to content

Conversation

@siwinski
Copy link
Member

Besides removing the constant, addPsr4() is also called with $prepend = true.

Validated on all Fedora/EPEL dists' Koji scratch builds.

@siwinski siwinski changed the title Remove self-autoload constant Remove self-autoload constant and prepend self-autoload PSR-4 register Oct 27, 2016
@remicollet
Copy link
Collaborator

remicollet commented Oct 28, 2016

Ok for constant removal.

But adding the preprend is not the correct way to use the built version (in buildroot).

Try adding

echo 'die("=== Autoload from sources ===");' >> src/Autoload.php;
echo 'die("=== Autoload from buildroot ===");' >> %{buildroot}%{phpdir}/Fedora/Autoloader/Autoload.php;
echo 'die("=== Dep from sources ===");' >> src/Dependencies.php;
echo 'die("=== Dep from buildroot ===");' >> %{buildroot}%{phpdir}/Fedora/Autoloader/Dependencies.php;

Only the DependenciesTest fails, with "Dep from sources" which is not expected.
Because PHPUnit (5.6.2 in rawhide only for now) have already loaded the class (from system) as it uses it.

Without the preprend, and using

%{_bindir}/php -d include_path=.:%{buildroot}%{_datadir}/php:%{_datadir}/php:%{_datadir}/pear \
%{_bindir}/phpunit --verbose

Works (aka, die with "Autoload from buildroot")

@remicollet
Copy link
Collaborator

Notice, I think we also need to pass --bootstrap option to PHPUnit, for older version (which doesn't load the autoloader from the include_path).

# include_path for PHPUnit using fedora/autoloader
# bootstrap for older PHPUnit
%{_bindir}/php -d include_path=.:%{buildroot}%{_datadir}/php:%{_datadir}/php:%{_datadir}/pear \
%{_bindir}/phpunit --bootstrap %{buildroot}%{phpdir}/Fedora/Autoloader/autoload.php --verbose

@siwinski
Copy link
Member Author

@remicollet I am a little distracted today so I would like to make sure I understand correctly. I believe I have 2 items to do:

  1. Remove prepend in library autoload.php
  2. Update RPM spec to use:
%{_bindir}/php -d include_path=.:%{buildroot}%{_datadir}/php:%{_datadir}/php:%{_datadir}/pear \
%{_bindir}/phpunit --bootstrap %{buildroot}%{phpdir}/Fedora/Autoloader/autoload.php --verbose

@remicollet
Copy link
Collaborator

remicollet commented Oct 28, 2016

@siwinski right, only these 2 changes.

(aka, the "die" stuff was only given as a way to ensure correct classes are used during the build)

@siwinski siwinski changed the title Remove self-autoload constant and prepend self-autoload PSR-4 register Remove self-autoload constant Oct 28, 2016
@siwinski
Copy link
Member Author

@remicollet updated. If you approve, I will merge, tag 0.2.1, update the RPM spec, build, and release.

@remicollet remicollet merged commit df34897 into master Oct 28, 2016
remicollet added a commit that referenced this pull request Dec 23, 2016
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.

3 participants