[MediaWiki-commits] [Gerrit] Tweaked wfThumbIsStandard() to recognize handler-specific de... - change (mediawiki/core)

2014-04-30 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Tweaked wfThumbIsStandard() to recognize handler-specific 
default parameters
..


Tweaked wfThumbIsStandard() to recognize handler-specific default parameters

* Now thumbnails with default lossy/lossless values will still count as 
standard,
  for example. This makes use of the file media handler.

Change-Id: Ia69301dfbf85bb26a17f8eee0939d690021343ec
(cherry picked from commit b0de7c7c60eb2f8464d6b6eb653331bdf80e34b0)
---
M thumb.php
1 file changed, 21 insertions(+), 6 deletions(-)

Approvals:
  Aaron Schulz: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/thumb.php b/thumb.php
index 707f1e2..e5037b4 100644
--- a/thumb.php
+++ b/thumb.php
@@ -427,16 +427,13 @@
  * of possible files with standard parameters is far less than that of all
  * possible combinations; rate-limiting for them can thus be more generious.
  *
- * @param File $img
+ * @param File $file
  * @param array $params
  * @return bool
  */
-function wfThumbIsStandard( File $img, array $params ) {
+function wfThumbIsStandard( File $file, array $params ) {
global $wgThumbLimits, $wgImageLimits;
-   // @TODO: use polymorphism with media handler here
-   if ( array_diff( array_keys( $params ), array( 'width', 'page' ) ) ) {
-   return false; // extra parameters present
-   }
+
if ( isset( $params['width'] ) ) {
$widths = $wgThumbLimits;
foreach ( $wgImageLimits as $pair ) {
@@ -446,6 +443,24 @@
return false;
}
}
+
+   $handler = $file-getHandler();
+   if ( $handler ) {
+   // Standard thumbnails use a standard width and any page number
+   $normalParams = array( 'width' = $params['width'] );
+   if ( isset( $params['page'] ) ) {
+   $normalParams['page'] = $params['page'];
+   }
+   // Append any default values to the map (e.g. lossy, 
lossless, seek...)
+   $handler-normaliseParams( $file, $normalParams );
+   // Check that the given values for non-page, non-width, params 
are just defaults
+   foreach ( $params as $key = $value ) {
+   if ( !isset( $normalParams[$key] ) || 
$normalParams[$key] !== $value ) {
+   return false;
+   }
+   }
+   }
+
return true;
 }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/130558
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia69301dfbf85bb26a17f8eee0939d690021343ec
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.24wmf2
Gerrit-Owner: Aaron Schulz asch...@wikimedia.org
Gerrit-Reviewer: Aaron Schulz asch...@wikimedia.org
Gerrit-Reviewer: jenkins-bot 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Tweaked wfThumbIsStandard() to recognize handler-specific de... - change (mediawiki/core)

2014-04-29 Thread Aaron Schulz (Code Review)
Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/130501

Change subject: Tweaked wfThumbIsStandard() to recognize handler-specific 
default parameters
..

Tweaked wfThumbIsStandard() to recognize handler-specific default parameters

* Now thumbnails with default lossy/lossless values will still count as 
standard,
  for example. This makes use of the file media handler.

Change-Id: Ia69301dfbf85bb26a17f8eee0939d690021343ec
---
M thumb.php
1 file changed, 21 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/01/130501/1

diff --git a/thumb.php b/thumb.php
index a5bdc5b..c5da918 100644
--- a/thumb.php
+++ b/thumb.php
@@ -429,16 +429,13 @@
  * of possible files with standard parameters is far less than that of all
  * possible combinations; rate-limiting for them can thus be more generious.
  *
- * @param File $img
+ * @param File $file
  * @param array $params
  * @return bool
  */
-function wfThumbIsStandard( File $img, array $params ) {
+function wfThumbIsStandard( File $file, array $params ) {
global $wgThumbLimits, $wgImageLimits;
-   // @TODO: use polymorphism with media handler here
-   if ( array_diff( array_keys( $params ), array( 'width', 'page' ) ) ) {
-   return false; // extra parameters present
-   }
+
if ( isset( $params['width'] ) ) {
$widths = $wgThumbLimits;
foreach ( $wgImageLimits as $pair ) {
@@ -448,6 +445,24 @@
return false;
}
}
+
+   $handler = $file-getHandler();
+   if ( $handler ) {
+   // Standard thumbnails use a standard width and any page number
+   $normalParams = array( 'width' = $params['width'] );
+   if ( isset( $params['page'] ) ) {
+   $normalParams['page'] = $params['page'];
+   }
+   // Append any default values to the map (e.g. lossy, 
lossless, seek...)
+   $handler-normaliseParams( $file, $normalParams );
+   // Check that the given values for non-page, non-width, params 
are just defaults
+   foreach ( $params as $key = $value ) {
+   if ( !isset( $normalParams[$key] ) || 
$normalParams[$key] !== $value ) {
+   return false;
+   }
+   }
+   }
+
return true;
 }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/130501
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia69301dfbf85bb26a17f8eee0939d690021343ec
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz asch...@wikimedia.org

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Tweaked wfThumbIsStandard() to recognize handler-specific de... - change (mediawiki/core)

2014-04-29 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Tweaked wfThumbIsStandard() to recognize handler-specific 
default parameters
..


Tweaked wfThumbIsStandard() to recognize handler-specific default parameters

* Now thumbnails with default lossy/lossless values will still count as 
standard,
  for example. This makes use of the file media handler.

Change-Id: Ia69301dfbf85bb26a17f8eee0939d690021343ec
---
M thumb.php
1 file changed, 21 insertions(+), 6 deletions(-)

Approvals:
  Chad: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/thumb.php b/thumb.php
index a5bdc5b..c5da918 100644
--- a/thumb.php
+++ b/thumb.php
@@ -429,16 +429,13 @@
  * of possible files with standard parameters is far less than that of all
  * possible combinations; rate-limiting for them can thus be more generious.
  *
- * @param File $img
+ * @param File $file
  * @param array $params
  * @return bool
  */
-function wfThumbIsStandard( File $img, array $params ) {
+function wfThumbIsStandard( File $file, array $params ) {
global $wgThumbLimits, $wgImageLimits;
-   // @TODO: use polymorphism with media handler here
-   if ( array_diff( array_keys( $params ), array( 'width', 'page' ) ) ) {
-   return false; // extra parameters present
-   }
+
if ( isset( $params['width'] ) ) {
$widths = $wgThumbLimits;
foreach ( $wgImageLimits as $pair ) {
@@ -448,6 +445,24 @@
return false;
}
}
+
+   $handler = $file-getHandler();
+   if ( $handler ) {
+   // Standard thumbnails use a standard width and any page number
+   $normalParams = array( 'width' = $params['width'] );
+   if ( isset( $params['page'] ) ) {
+   $normalParams['page'] = $params['page'];
+   }
+   // Append any default values to the map (e.g. lossy, 
lossless, seek...)
+   $handler-normaliseParams( $file, $normalParams );
+   // Check that the given values for non-page, non-width, params 
are just defaults
+   foreach ( $params as $key = $value ) {
+   if ( !isset( $normalParams[$key] ) || 
$normalParams[$key] !== $value ) {
+   return false;
+   }
+   }
+   }
+
return true;
 }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/130501
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia69301dfbf85bb26a17f8eee0939d690021343ec
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz asch...@wikimedia.org
Gerrit-Reviewer: Chad ch...@wikimedia.org
Gerrit-Reviewer: jenkins-bot 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Tweaked wfThumbIsStandard() to recognize handler-specific de... - change (mediawiki/core)

2014-04-29 Thread Aaron Schulz (Code Review)
Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/130558

Change subject: Tweaked wfThumbIsStandard() to recognize handler-specific 
default parameters
..

Tweaked wfThumbIsStandard() to recognize handler-specific default parameters

* Now thumbnails with default lossy/lossless values will still count as 
standard,
  for example. This makes use of the file media handler.

Change-Id: Ia69301dfbf85bb26a17f8eee0939d690021343ec
(cherry picked from commit b0de7c7c60eb2f8464d6b6eb653331bdf80e34b0)
---
M thumb.php
1 file changed, 21 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/58/130558/1

diff --git a/thumb.php b/thumb.php
index 707f1e2..e5037b4 100644
--- a/thumb.php
+++ b/thumb.php
@@ -427,16 +427,13 @@
  * of possible files with standard parameters is far less than that of all
  * possible combinations; rate-limiting for them can thus be more generious.
  *
- * @param File $img
+ * @param File $file
  * @param array $params
  * @return bool
  */
-function wfThumbIsStandard( File $img, array $params ) {
+function wfThumbIsStandard( File $file, array $params ) {
global $wgThumbLimits, $wgImageLimits;
-   // @TODO: use polymorphism with media handler here
-   if ( array_diff( array_keys( $params ), array( 'width', 'page' ) ) ) {
-   return false; // extra parameters present
-   }
+
if ( isset( $params['width'] ) ) {
$widths = $wgThumbLimits;
foreach ( $wgImageLimits as $pair ) {
@@ -446,6 +443,24 @@
return false;
}
}
+
+   $handler = $file-getHandler();
+   if ( $handler ) {
+   // Standard thumbnails use a standard width and any page number
+   $normalParams = array( 'width' = $params['width'] );
+   if ( isset( $params['page'] ) ) {
+   $normalParams['page'] = $params['page'];
+   }
+   // Append any default values to the map (e.g. lossy, 
lossless, seek...)
+   $handler-normaliseParams( $file, $normalParams );
+   // Check that the given values for non-page, non-width, params 
are just defaults
+   foreach ( $params as $key = $value ) {
+   if ( !isset( $normalParams[$key] ) || 
$normalParams[$key] !== $value ) {
+   return false;
+   }
+   }
+   }
+
return true;
 }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/130558
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia69301dfbf85bb26a17f8eee0939d690021343ec
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.24wmf2
Gerrit-Owner: Aaron Schulz asch...@wikimedia.org

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits