[MediaWiki-commits] [Gerrit] mediawiki...Score[master]: Add variables to score hash

2017-12-23 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/399893 )

Change subject: Add variables to score hash
..


Add variables to score hash

This change adds the versions of both the extension and of Lilypond to
the hash options, so that updates, such as Ieb1345582, that will
affect the appearance of a score, will propagate better.

Bug: T49448
Change-Id: Iad119d53e4f25ac66e3aa1d553580f0097b6c395
---
M includes/Score.php
1 file changed, 7 insertions(+), 0 deletions(-)

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



diff --git a/includes/Score.php b/includes/Score.php
index e3b76c8..e6df438 100644
--- a/includes/Score.php
+++ b/includes/Score.php
@@ -35,6 +35,11 @@
const DEFAULT_PLAYER_WIDTH = 300;
 
/**
+* Version for cache invalidation.
+*/
+   const CACHE_VERSION = 0;
+
+   /**
 * Supported score languages.
 */
private static $supportedLangs = [ 'lilypond', 'ABC' ];
@@ -274,6 +279,8 @@
'code' => $code,
'lang' => $options['lang'],
'raw'  => $options['raw'],
+   'ExtVersion' => self::CACHE_VERSION,
+   'LyVersion' => self::getLilypondVersion(),
];
// Doing this separately to not invalidate too many 
existing keys.
if ( $options['raw'] && ( $options['generate_ogg']

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iad119d53e4f25ac66e3aa1d553580f0097b6c395
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Score
Gerrit-Branch: master
Gerrit-Owner: Ebe123 
Gerrit-Reviewer: Brion VIBBER 
Gerrit-Reviewer: Ebe123 
Gerrit-Reviewer: Jforrester 
Gerrit-Reviewer: Legoktm 
Gerrit-Reviewer: Matanya 
Gerrit-Reviewer: Reedy 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] mediawiki...Score[master]: Add variables to score hash

2017-12-22 Thread Ebe123 (Code Review)
Ebe123 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399893 )

Change subject: Add variables to score hash
..

Add variables to score hash

This change adds the versions of both the extension and of Lilypond to
the hash options, so that updates, such as Ieb1345582, that will
affect the appearance of a score, will propagate better.

Bug: T49448
Change-Id: Iad119d53e4f25ac66e3aa1d553580f0097b6c395
---
M includes/Score.php
1 file changed, 3 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Score 
refs/changes/93/399893/1

diff --git a/includes/Score.php b/includes/Score.php
index e3b76c8..7eea37e 100644
--- a/includes/Score.php
+++ b/includes/Score.php
@@ -270,10 +270,13 @@
}
 
// Input for cache key
+   $LYversion = json_decode( file_get_contents( __DIR__ . 
'extension.json' ), true )['version'];
$cacheOptions = [
'code' => $code,
'lang' => $options['lang'],
'raw'  => $options['raw'],
+   'ExtVersion' => $LYversion,
+   'LyVersion' => self::getLilypondVersion(),
];
// Doing this separately to not invalidate too many 
existing keys.
if ( $options['raw'] && ( $options['generate_ogg']

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iad119d53e4f25ac66e3aa1d553580f0097b6c395
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Score
Gerrit-Branch: master
Gerrit-Owner: Ebe123 

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


[MediaWiki-commits] [Gerrit] mediawiki...Score[master]: Add variables to score hash and add purging

2017-08-06 Thread Ebe123 (Code Review)
Ebe123 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/370428 )

Change subject: Add variables to score hash and add purging
..

Add variables to score hash and add purging

This change enables the use of `?action=purge` on scores. As with math
equations, the purge of a page with a score will also cascade identical
scores on other pages.

The versions of both the extension and of Lilypond has also been added
to the hash options, so that updates, such as Ieb1345582, that will
affect the appearance of a score, will propagate better.

Bug: T49448
Change-Id: Id2dd37f476a3bd0ff2ab69f9900b87f9e859f87f
---
M Score.body.php
1 file changed, 29 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Score 
refs/changes/28/370428/1

diff --git a/Score.body.php b/Score.body.php
index 0a6517f..e005f7a 100644
--- a/Score.body.php
+++ b/Score.body.php
@@ -275,10 +275,13 @@
}
 
// Input for cache key
+   $version = json_decode( file_get_contents( __DIR__ . 
'extension.json' ), true )['version'];
$cacheOptions = [
'code' => $code,
'lang' => $options['lang'],
'raw'  => $options['raw'],
+   'ExtVersion' => $version,
+   'LyVersion' => self::getLilypondVersion(),
];
// Doing this separately to not invalidate too many 
existing keys.
if ( $options['raw'] && ( $options['generate_ogg']
@@ -356,8 +359,15 @@
$fileIter = $backend->getFileList(
[ 'dir' => $options['dest_storage_path'], 
'topOnly' => true ] );
$existingFiles = [];
-   foreach ( $fileIter as $file ) {
-   $existingFiles[$file] = true;
+
+   if ( self::purgeScores() ) {
+   foreach ( $fileIter as $file ) {
+   $existingFiles[$file] = false;
+   }
+   } else {
+   foreach ( $fileIter as $file ) {
+   $existingFiles[$file] = true;
+   }
}
 
/* Generate PNG and MIDI files if necessary */
@@ -913,6 +923,23 @@
}
 
/**
+* Determines whether to re-render the score tags
+* Set true when purging requested with ?action=purge
+*
+* @return Bool true if purging requested
+*/
+   private static function purgeScores() {
+   $refererHeader = 
RequestContext::getMain()->getRequest()->getHeader( 'REFERER' );
+   if ( $refererHeader ) {
+   parse_str( parse_url( $refererHeader, PHP_URL_QUERY ), 
$refererParam );
+   if ( isset( $refererParam['action'] ) && 
$refererParam['action'] === 'purge' ) {
+   return true;
+   }
+   }
+   return false;
+   }
+
+   /**
 * Deletes a local directory with no subdirectories with all files in 
it.
 *
 * @param $dir string Local path to the directory that is to be deleted.

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id2dd37f476a3bd0ff2ab69f9900b87f9e859f87f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Score
Gerrit-Branch: master
Gerrit-Owner: Ebe123 

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