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 <beauleetien...@gmail.com>

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

Reply via email to