Page MenuHomePhabricator

DrawioEditor undefined property $img_timestamp
Closed, ResolvedPublic

Description

Windows 2008 R2
IIS 7.5
MediaWiki 1.35.1
PHP 7.3.25
MariaDB 10.3.27


After upgrade to MW 1.35.1 the DrawioEditor is crashing when saving the page in VisualEditor with the following error returned from MW api.php:

PHP Notice: Undefined property: stdClass::$img_timestamp in D:\some_path\extensions\DrawioEditor\src\DrawioEditor.php on line 95

This line:
https://github.com/wikimedia/mediawiki-extensions-DrawioEditor/blob/60b4ce3558ee9f934fa35c18a02f5bd2ab6ef698/src/DrawioEditor.php#L95

The page is saved, but VisualEditor stops with error dialog:

image.png (245×516 px, 8 KB)

Event Timeline

The problem is caused by Line 91

L91: $img = $this->services->getRepoGroup()->findFile( $img_name );

The first history retrieval will have those properties such as img_PROPERTYNAME, every subsequent access has oi_PROPERTYNAME leading to the error in this ticket.

A simple work around can be had by inserting a reset like below

$img = $this->services->getRepoGroup()->findFile( $img_name );       
if ( $img ) {
    // REF; https://doc.wikimedia.org/mediawiki-core/REL1_35/php/LocalFile_8php_source.html#l01332
    $img->resetHistory();

I see the issue and can recreate it, I had not quite realized the cause with my previous fix.

MediaWiki Test Page Should be like follows;

Copy 1:  {{drawio:ChartName5|type=png}}
Copy 2: {{drawio:ChartName5|type=png}}

The re-use of a ChartName5 twice, or more results in re-use of the findFile access to successive history data I think.

Change 655224 had a related patch set uploaded (by Lucien Murray-Pitts; owner: Lucien Murray-Pitts):
[mediawiki/extensions/DrawioEditor@master] Fixes img_timestamp exception for same charts

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

The patch works and fixes the issue. Thanks

Note: In my case I have 2 charts on the page, BUT with different names. However, it fixes it too.

Change 656910 had a related patch set uploaded (by Robert Vogel; owner: Lucien Murray-Pitts):
[mediawiki/extensions/DrawioEditor@REL1_35] Fixes img_timestamp exception for same charts

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

Change 656950 had a related patch set uploaded (by Robert Vogel; owner: Lucien Murray-Pitts):
[mediawiki/extensions/DrawioEditor@REL1_31] Fixes img_timestamp exception for same charts

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

Change 655224 merged by jenkins-bot:
[mediawiki/extensions/DrawioEditor@master] Fixes img_timestamp exception for same charts

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

Change 656910 merged by jenkins-bot:
[mediawiki/extensions/DrawioEditor@REL1_35] Fixes img_timestamp exception for same charts

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

Osnard claimed this task.

Change 656950 merged by jenkins-bot:
[mediawiki/extensions/DrawioEditor@REL1_31] Fixes img_timestamp exception for same charts

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