Skip to content

Fixes to phar stub #10706

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

Open
wants to merge 2 commits into
base: PHP-8.1
Choose a base branch
from
Open

Fixes to phar stub #10706

wants to merge 2 commits into from

Conversation

nielsdos
Copy link
Member

There were a couple of issues with the phar stub. It seems that in the past people did not realise they had to change shortarc.php and run makestub.php to generate the stubfile and instead they modified stub.h manually. This meant that there were a couple of mistakes in the stub which are fixed in this patch. In particular:

  • The title tag was not closed
  • The length of the stub was wrong in stub.h
  • This PR syncs previous changes to stub.h back to shortarc.php and vice versa.
  • Adds a note such that hopefully no mistakes against updating the stubs are made in the future (hopefully).
  • The makestub.php script was actually broken because the expected signature of the stub got changed in b874f1a

There were a couple of issues with the phar stub. It seems that in the
past people did not realise they had to change shortarc.php and run
makestub.php to generate the stubfile and instead they modified stub.h
manually. This meant that there were a couple of mistakes in the stub
which are fixed in this patch. In particular:

* The title tag was not closed
* The length of the stub was wrong in stub.h
* This PR syncs previous changes to stub.h back to shortarc.php
  and vice versa.
* Adds a note such that hopefully no mistakes against updating the stubs
  are made in the future (hopefully).
* The makestub.php script was actually broken because the expected
  signature of the stub got changed in b874f1a
@mvorisek
Copy link
Contributor

It seems that in the past people did not realise they had to change shortarc.php and run makestub.php to generate the stubfile and instead they modified stub.h manually.

assert that in https://github.com/php/php-src/blob/master/.github/actions/verify-generated-files/action.yml with CI

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

This looks sensible but I don't know anything about phar tbh.

One question, is the change in file permission in makestub.php intended?

@nielsdos
Copy link
Member Author

This looks sensible but I don't know anything about phar tbh.

I don't know a lot about phar too tbh, so best to let someone with more knowledge about phar double check I guess... 😅

One question, is the change in file permission in makestub.php intended?

Yes. This is needed so we can conveniently run it from the command line and from the CI script (see my second commit) :)

@medabkari
Copy link

I don't know a lot about phar too tbh, so best to let someone with more knowledge about phar double check I guess... 😅

This PR has been stale for almost a year. I remember Bishop was the maintainer of ext/phar, so if someone could ping him for a quick review, that would be helpful.

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

This looks okay after a rebase to 8.2


static const int newstub_len = 6623;
static const int newstub_len = 6625;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
static const int newstub_len = 6625;
static const size_t newstub_len = 6625;

For master maybe?

@@ -48,8 +49,10 @@
+----------------------------------------------------------------------+
*/

static inline void phar_get_stub(const char *index_php, const char *web, size_t *len, char **stub, const int name_len, const int web_len)
static inline zend_string *phar_get_stub(const char *index_php, const char *web, const int name_len, const int web_len)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
static inline zend_string *phar_get_stub(const char *index_php, const char *web, const int name_len, const int web_len)
static inline zend_string *phar_get_stub(const char *index_php, const char *web, size_t name_len, size_t web_len)

It could make sense to also rearrange the parameter order in master alongside this.

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

Successfully merging this pull request may close these issues.

5 participants