Skip to content

Add is_cacheable() stream wrapper operation #976

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

Closed
wants to merge 1 commit into from

Conversation

flaupretre
Copy link
Contributor

@reeze
Copy link
Contributor

reeze commented Jan 4, 2015

Big 👍

static int phar_wrapper_is_cacheable(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context) /* {{{ */
{
/* Phar URLs are always cacheable */
return 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Indention:)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@smalyshev smalyshev added the RFC label Jan 4, 2015
@@ -44,7 +44,11 @@ php_stream_wrapper_ops phar_stream_wops = {
phar_wrapper_unlink, /* unlink */
phar_wrapper_rename, /* rename */
phar_wrapper_mkdir, /* create directory */
phar_wrapper_rmdir, /* remove directory */
phar_wrapper_rmdir /* remove directory */
#ifdef PHP_STREAMS_SUPPORT_IS_CACHEABLE
Copy link
Member

Choose a reason for hiding this comment

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

I don't see why you need this ifdef if it's always going to be available... now you also have to mess up the codeing standards (, goes at the end).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did it this way because I imagined that the phar code had to be kept compatible with previous PHP versions (but maybe the phar reference is not here, or development for PHP7 has been split).

If we consider that this code is synchronized with is_cacheable() support, yes, we can drop the conditionals.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, having this define looks pointless - if we accept this RFC, this is part of PHP 7 and should be checked against as "is this PHP 7?" if somebody needs to maintain cross-version extensions. We don't have separate defines for every PHP 7 feature, and it's not configurable in any way, so it should be just there - or, if version portability is needed (not sure for phar, it's a core module, why would it need that?) use PHP version checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your comments. Now that it is clear that the feature is for PHP7, I’ll remove the define and enclose phar changes in a PHP_VERSION-based ifdef.

@flaupretre flaupretre force-pushed the streams_is_cacheable branch from 50c7a8b to 195d9d0 Compare January 4, 2015 20:06

if (call_result == SUCCESS) {
/* We got the info we needed */
convert_to_long(&zretval);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why long? You just documented it as being true/false. Then you should use zend_is_true or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@flaupretre flaupretre force-pushed the streams_is_cacheable branch 3 times, most recently from 058403d to 920a85f Compare January 7, 2015 12:00
@marcioAlmada
Copy link
Contributor

@flaupretre Any news? This would be very useful.

@flaupretre
Copy link
Contributor Author

@marcioAlmada Sure. The feature missed the 7.0 deadline, but is planned for 7.1. An additional reason to implement it is that it is required by PCS, which I'll also propose for inclusion in 7.1. Of course, both features will go through the RFC process first and the result is unpredictable ;) but the first returns I got are positive.

Instead of is_cacheable(), I will propose a cache_key() operation which will return NULL if the URL is not cacheable, and a zend_string to use as a key if the URL can be cached.

@flaupretre
Copy link
Contributor Author

Follow-up: #1711

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

Successfully merging this pull request may close these issues.

None yet

5 participants