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

[Configuration.php] Fix notice of undefined offset when in detached HEAD state. #1569

Merged
merged 1 commit into from
May 27, 2020

Conversation

mibe
Copy link
Contributor

@mibe mibe commented May 23, 2020

When a clone is in a detached HEAD state (e.g. when a tag is checked out), the format of the .git/HEAD file is different and contains an hash only. This means there is nothing to explode() and the array access fails, producing Notice: Undefined offset: 3 in <path>\Configuration.php on line 247. This PR fixes this by checking if the array element exists and is not NULL.

Steps to reproduce:

  • Clone the repo in a folder served by a webserver and having PHP set to report E_NOTICE:
    git clone https://github.com/RSS-Bridge/rss-bridge.git .
  • Check out the latest tag:
    git checkout tags/2020-02-26
    (.git/HEAD contains "0705a2e7bb391d2eac707bb1d195e51f5911b334" now)
  • Open the clone in a browser
  • The notice mentioned above is displayed above the rss-bridge logo

@mibe mibe marked this pull request as ready for review May 23, 2020 23:46
@sabberworm
Copy link

Probably a better solution would be to just use the output of git describe HEAD as the version string, no?

@em92
Copy link
Contributor

em92 commented May 25, 2020

@sabberworm, if using shared hosting, git usually is not installed

@sabberworm
Copy link

Won’t people on shared hosting usually just extract the zip from releases, extract and upload that, in which case they won’t get the .git folder at all…

@em92
Copy link
Contributor

em92 commented May 26, 2020

Also, shared hosting may not allow to execute any commands. Discussed here: #731 (comment)

@teromene teromene merged commit c4422bd into RSS-Bridge:master May 27, 2020
@teromene
Copy link
Member

Thank you for your first contribution !

@mibe mibe deleted the getVersion-notice-fix branch June 2, 2020 20:00
comlaterra pushed a commit to comlaterra/rss-bridge that referenced this pull request Sep 25, 2020
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