Skip to content

compile warning messages on SassMediaNode.php #188

@joejoseph00

Description

@joejoseph00

Compiling our scss gives us this message repeated for many of our @media during compile of .scss :
`Undefined offset: 1 in SassMediaNode->__construct() (line 55 of core/sites/all/libraries/phpsass/tree/SassMediaNode.php).

Based on our .scss, we have @media used about 10 times.
`

I debugged by writing to a text file the key variables involved at the line 55 and a few lines up before line 55 of phpsass/tree/SassMediaNode.php.

cat /www/debug2.txt

token->source=@media(max-width:374px)
self::MEDIA=1
matches[self::MEDIA]=
token->source=@media(max-width:420px)
self::MEDIA=1
matches[self::MEDIA]=
token->source=@media(max-width:461px)
self::MEDIA=1
matches[self::MEDIA]=
token->source=@media(max-width:480px)
self::MEDIA=1
matches[self::MEDIA]=
token->source=@media(max-width:540px)
self::MEDIA=1
matches[self::MEDIA]=
token->source=@media(max-width:767px)
self::MEDIA=1
matches[self::MEDIA]=
token->source=@media(min-width:768px) and (max-width:991px)
self::MEDIA=1
matches[self::MEDIA]=
token->source=@media(min-width:768px)
self::MEDIA=1
matches[self::MEDIA]=
token->source=@media(min-width:992px) and (max-width:1199px)
self::MEDIA=1
matches[self::MEDIA]=
token->source=@media(min-width:1200px)
self::MEDIA=1
matches[self::MEDIA]=
token->source=@media(max-width:1024px)
self::MEDIA=1
matches[self::MEDIA]=

Here is the useful debug code that was used to generate the above message.

diff --git a/tree/SassMediaNode.php b/tree/SassMediaNode.php
index 616f389..5b3006e 100644
--- a/tree/SassMediaNode.php
+++ b/tree/SassMediaNode.php
@@ -52,6 +52,18 @@ class SassMediaNode extends SassNode

     preg_match(self::MATCH, $token->source, $matches);
     $this->token = $token;
+
+if (!isset($matches[self::MEDIA])) {
+  $file = 'debug2.txt';
+  // Open the file to get existing content
+  $current = file_get_contents($file);
+  // Append a new person to the file
+  $current .= 'token->source=' . $token->source . "\n";
+  $current .= 'self::MEDIA=' . self::MEDIA . "\n";
+  $current .= 'matches[self::MEDIA]=' . $matches[self::MEDIA] . "\n";
+  // Write the contents back to the file
+  file_put_contents($file, $current);
+}
     $this->media = $matches[self::MEDIA];
   }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions